spring-projects / spring-projects/spring-hateoas
HAL: the rel for an embedded collection should be singular (the item-resource-rel)
@odrotbohm is already working on this.
Since May 21, 2015.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 476
- PR merge metrics
- No merged PRs in 30d
Description
I think the implementation of the HalEmbeddedBuilder is outdated/wrong in selecting a plural collection link-rel when embedding multiple resources. In my understanding of the spec, linking to items in a collection resource (e.g. "/items") should be regarded as multiple links with the rel "item" (like multiple <a href="/items/1" rel="item">), serialized into an array. The rel should remain "item".
The collection-link-rel "items" should only be used if actually linking to the collection resource (i.e. "/items").
Otherwise it becomes impossible to distinguish between the link to a collection resource and a link to a single resource.
For example:
/items
{
"_links": {
"self": {href: "/items"}
},
"_embedded": {
"item": [
{
"_links": {
"self": {href: "/items/1"}
}
}
]
}
}
/items/1
{
"_links": {
"self": {href: "/items/1"}
"items": {href: "/items"}
},
"id": "1"
}
The targets for "items" and "item" are distinctly different, so they should have distinct rels.
The HAL spec itself is confusing in that regard - the published spec still holds an example using the orders-rel, but it has been corrected on Mike Kelly's website where it now shows the ea:order-rel.
It has also been discussed on the mailing list.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.