Im implementing a hal/json api.
The root object (soldier) has a related object (sword), that is mapped under /soldier/{object_id}/sword
{
"id": 12345,
"name": "Sir SmokeALot",
"_links": {
"self": {
"href": "http://soldier.local:8080/soldier/12345"
},
"sword": {
"href": "http://soldier.local:8080/soldier/12345/sword"
}
}
}
But not every soldier has a sword. Imagine the poor soldier without a sword.
if i retrieve the
soldier
-object, should the link/soldier/{object_id}/sword
appear in the_links
-array?And if it should, what would i get back from this link? An empty object or a 404? Is it even allowed by hal/json RFC to have links in the
_links
-array that lead to a 404?
I don't ask how to solve this, i want to know whats right.