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
Comment #1
clemens.tolboomComment #2
damien tournoud commentedThis 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.
Comment #3
clemens.tolboomRegarding _links keys:
Reading http://tools.ietf.org/html/draft-kelly-json-hal-06#section-4.1.1
leads to http://tools.ietf.org/html/rfc5988#section-4
so I expect
- "author" instead of "http://drupal.d8/rest/relation/node/article/uid"
Comment #4
clemens.tolboomTypes
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.
hreflang
We must change 'lang' into 'hreflang'.
Comment #5
damien tournoud commented@clemens.tolboom: continue reading RFC5988, especially the part right after what you quoted named "Extension Relation Types":
There might be registered relation types that better apply to some particular links, but that's a different issue completely.
Comment #6
clemens.tolboom@Damien Tournoud thanks.
Did I report duplicates in #4 ?
Shall I change title and update summary then change component to serialization.module?
Comment #7
clemens.tolboom