Problem/Motivation

When run ie

curl --user admin:admin --header "Accept: application/hal+json" --request GET http://drupal.d8/node/1

the response has invalid (not compliant with ) _links items

- http://stateless.co/hal_specification.html
- http://tools.ietf.org/html/draft-kelly-json-hal-06

{
  "_links": {
    "self": {
      "href": "http://drupal.d8/node/1"
    },
    "type": {
      "href": "http://drupal.d8/rest/type/node/article"
    },
    "http://drupal.d8/rest/relation/node/article/uid": [
      {
        "href": "http://drupal.d8/user/1",
        "lang": "und"
      }
    ],
    "http://drupal.d8/rest/relation/node/article/revision_uid": [
      {
        "href": "http://drupal.d8/user/1"
      }
    ],
    "http://drupal.d8/rest/relation/node/article/field_image": [
      {
        "href": "http://drupal.d8/sites/default/files/field/image/imagefield_L6OxTz.jpeg",
        "lang": "und"
      }
    ]
  },

Proposed resolution

The _links ID should not contains URIs but 'rel' names.

{
  "_links": {
    "self": {
      "href": "http://drupal.d8/node/1",
      "type": "node/article"

    },
    "uid": [
      {
        "href": "http://drupal.d8/user/1",
        "lang": "und"
      }
    ],
    "revision_uid": [
      {
        "href": "http://drupal.d8/user/1"
      }
    ],
    "field_image": [
      {
        "href": "http://drupal.d8/sites/default/files/field/image/imagefield_L6OxTz.jpeg",
        "lang": "und",
        "type": "image"
      }
    ]
  },
}

Remaining tasks

- Find other inconsistencies.

User interface changes

API changes

Comments

clemens.tolboom’s picture

Issue summary: View changes
damien tournoud’s picture

This is actually correct. Relation types are absolute URIs in general, other than the handful of standardized ones. We should curie them, but that's a different issue, and doesn't make the current representation invalid.

clemens.tolboom’s picture

Regarding _links keys:

Reading http://tools.ietf.org/html/draft-kelly-json-hal-06#section-4.1.1

It is an object whose property names are link relation types (as
defined by [RFC5988])

leads to http://tools.ietf.org/html/rfc5988#section-4

In the simplest case, a link relation type identifies the semantics
of a link. For example, a link with the relation type "copyright"
indicates that the resource identified by the target IRI is a
statement of the copyright terms applying to the current context IRI.

so I expect

- "author" instead of "http://drupal.d8/rest/relation/node/article/uid"

"http://drupal.d8/rest/relation/node/article/uid": [
      {
        "href": "http://drupal.d8/user/1",
        "lang": "und"
      }
    ],
clemens.tolboom’s picture

Types

I think I was to quick with move type into the self link. Type seems to be a media type http://tools.ietf.org/html/draft-kelly-json-hal-06#section-5.3

So for article image it could have a type.

    "http://drupal.d8/rest/relation/node/article/field_image": [
      {
        "href": "http://drupal.d8/sites/default/files/field/image/dreditor-triage.png",
        "type": "image/png",
        "lang": "en"
      }
    ]

hreflang

We must change 'lang' into 'hreflang'.

damien tournoud’s picture

@clemens.tolboom: continue reading RFC5988, especially the part right after what you quoted named "Extension Relation Types":

Applications that don't wish to register a relation type can use an
extension relation type, which is a URI [RFC3986] that uniquely
identifies the relation type.

There might be registered relation types that better apply to some particular links, but that's a different issue completely.

clemens.tolboom’s picture

@Damien Tournoud thanks.

Did I report duplicates in #4 ?

Shall I change title and update summary then change component to serialization.module?

clemens.tolboom’s picture

Status: Active » Closed (works as designed)