mnot / I-D

My Internet-Drafts
https://mnot.github.io/I-D/
Other
98 stars 38 forks source link

How to serialize multiple "item" links? #322

Closed gabesullice closed 2 months ago

gabesullice commented 3 years ago

Assume that my HTTP API provides a collection link, like so:

"_links": {
  "collection": {
    "href": "/posts",
    "links": {
      "item": {
        "href": "/posts/1
      }
    }
}

Since the links hint described in section 3.3 must be an object, it seems impossible to serialize multiple links with the same link relation type. I.e. if my HTTP API wanted to hint that there is more than one item link on the collection resource, it wouldn't be able to do so.

Should the links hint value be an array of objects instead?

If so, should the draft's examples move away from using object keys to serialize link relation types and instead place them inside the link object itself under a rel object key?

This would match the serialization proposed here: https://tools.ietf.org/html/draft-pot-json-link-01