pixelhumain / api

0 stars 7 forks source link

JSON-LD serialization is not Linked Open Data #6

Open almereyda opened 7 years ago

almereyda commented 7 years ago

The JSON-LD serialization of a dataset is produced by mixing API and Linked Data design patterns. Currently a ?format=schema parameter is being used to produce an almost desired effect, which breaks the ability to directly link to the document.

$ curl -sH "Accept: application/ld+json" https://www.communecter.org/api/organization/get/id/55cf123fe41d7544778b1451/ | jq .
{
  "meta": {
    "limit": 1
  },
  "entities": {
    "55cf123fe41d7544778b1451": {
      "@type": "Organization",
      "name": "Géo Organique",
      "typeCommunecter": "Group",
      "image": "https://www.communecter.org/upload/communecter/organizations/55cf123fe41d7544778b1451/Photo0552.jpg",
      "url": {
        "website": "http://wiki.cheznous.coop/geoorganique",
        "communecter": "https://www.communecter.org/#organization.detail.id.55cf123fe41d7544778b1451",
        "api": "https://www.communecter.org/api/organization/get/id/55cf123fe41d7544778b1451"
      },
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "12, chemin du Busquet",
        "postalCode": "63340",
        "addressLocality": "VICHEL",
        "codeInsee": "63456",
        "addressCountry": "FR"
      },
      "geo": {
        "@type": "GeoCoordinates",
        "latitude": 45.428634,
        "longitude": 3.242987
      },
      "geoPosition": {
        "@type": "Point",
        "coordinates": [
          3.242987,
          45.428634
        ]
      },
      "shortDescription": "<p class=\"wysiwyg-text-align-justify\">Géo Organique est un Groupe dont l'animateur vise à dessiner un réseau autour de la géographie organique. <br></p><p class=\"wysiwyg-text-align-justify\">Celle-ci est très attachée aux bases, partant de l'idée que les choses doivent rester simple et claires au départ, pour parvenir à faire complexe. <br></p><p class=\"wysiwyg-text-align-justify\">La racine de ce projet est à cette adresse : <a rel=\"nofollow\" target=\"_blank\" href=\"http://wiki.cheznous.coop/geoorganique\">http://wiki.cheznous.coop/geoorganique</a> <br></p><p class=\"wysiwyg-text-align-justify\">Le souhait est aussi de faire quelque chose de participatif et contributif : les adhérents au groupe construisent des témoignages de leurs usages et projets en cartographie.<br></p><br>",
      "description": "Thème de la Géographie organique sur le Pays d'Issoire (<a rel=\"nofollow\" target=\"_blank\" href=\"http://wiki.cheznous.coop/_media/carto_geopoetique_issoire.pdf\">document pdf</a>)<br>",
      "email": "geo@spatiogis.fr",
      "tags": [
        "Education populaire",
        "Biodiversité"
      ],
      "links": {
        "members": [
          {
            "type": "Person",
            "name": "Televb",
            "url": {
              "communecter": "https://www.communecter.org/#person.detail.id.55c85b17e41d75864f8b144f",
              "api": "https://www.communecter.org/api/person/get/id/55c85b17e41d75864f8b144f"
            }
          },
          {
            "type": "Person",
            "name": "Mathieu Coste",
            "url": {
              "communecter": "https://www.communecter.org/#person.detail.id.55901b8fe41d75292e59ce8b",
              "api": "https://www.communecter.org/api/person/get/id/55901b8fe41d75292e59ce8b"
            }
          }
        ]
      }
    }
  }
}

Instead, the route could make use of content negotiation headers to distinguish which serialization is requested. For JSON-LD it is application/ld+json.

Additionally the stable IRIs provided by the returned document of the ?format=schema route cannot be dereferenced and produce 404s:

$ curl -I https://www.communecter.org/data/get/type/organizations/id/55cf123fe41d7544778b1451/format/schema
HTTP/1.0 404 Not Found
Date: Fri, 17 Mar 2017 11:27:32 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.14
Connection: close
Content-Type: text/html

This depends on #5 . Also read https://ruben.verborgh.org/blog/2013/11/29/the-lie-of-the-api/

oceatoon commented 7 years ago

The JSON-LD serialization of a dataset is produced by mixing API and Linked Data design patterns. Currently a ?format=schema parameter is being used to produce an almost desired effect, which breaks the ability to directly link to the document.

We didn't take the time to go to the end by lack of time but what you have seen is a serialisation of json-LD this will be available for in depth data LD parsing our translation engine is generic and makes this changes really easy

Instead, the route could make use of content negotiation headers to distinguish which serialization is requested. For JSON-LD it is application/ld+json.

I think this has been changed , just not available yet in PROD we are aware of the technical features of JSON-LD and we do playground validation but we are mainly focusing on the interfaces at the moment with a great user experience surprise soon to come Therefore we're just lacking time on the api reusability part but it's all part of the roadmap , so no worries, we're on the road Jack (Jon) ;)