In my API, I have rels that look like this:
For a single item:
{
...
_links: {
...,
"api:activities/activity-resource": {
"href": "..."
}
}
}
On another resource, I have multiple instances of activity-resource
. How should I represent this? Is the following ok:
For a collection:
{
...
_links: {
...,
"api:activities/activity-resource": [{
"href": "..."
}, {
"href": "..."
}]
}
}
It kind of makes sense since they are still instances of activity-resource
, and a human being can look up the documentation for information on how to deal with those resources. However, now my API is a little inconsistent in that in certain representations the api:activities/activity-resource
rel points to a single instance whereas in others it points to a collection.
I can make the argument a developer can figure out what he/she needs to do from the API documentation, but it helps to have a consistent API as well.