Hi,
Are there some examples on the links?
I have a very basic question. I think I got myself confused. Is it true that some links should exist for a singular resource, some should exist for collection resource?
Say I have a collection resource under /books. GET /books return all the books, and GET /books/xyz returns one book with a title "xyz". For example:
GET /books returns:
{
"books": [
{"title": xyz, "author": "foo", "linksForMyInstance": [...]},
{"title": abc, "author": "bar", "linksForMyInstance": [...]},
{"title": 123, "author": "foo", "linksForMyInstance": [...]}
],
"linksForMyCollection": [
......
],
"_context": {
"count": 3...
}
}
GET /books/xyz returns:
{"title": xyz, "author": "foo", "linksForMyInstance": [...]}
I could have a schema for /books resource like this:
{
"type": "object",
"properties": {
"books":{
"type": "array",
"items": {
"properties": {
"title": {...},
"author": {...},
"linksForMyInstance": {...}
},
"links":[
{"rel": "self", "href": "{title}"},
{"rel": "instances", "href": "/books"}
]
}
},
"linksForMyCollection": {
......
},
"_context": {
....
}
},
"links":[
{"rel": "self", "href": "/"},
{"rel": "instances", "href": "/books"}
]
}
Does the "instances" link in the inner links section make sense?
What should be the self link in the outer links section?
Thanks.
Ning