Given an object has an owner
association (relation), when expanded by default it will be exposed as:
{
"name": "service-production",
"owner": {
"id": "5d8201b0...",
"name": "Alice",
"email": "[email protected]"
},
...
}
If, for performance reason, an association (relation) is not included but made available via expansion or a subsequent HTTP request, it will be referenced as:
{
"name": "service-production",
"owner_id": "5d8201b0...",
"links": [
{ "name": "Owner", "rel": "https://api.example.com/rels/owner", "href": "https://api.example.com/users/01234567-89ab-cdef-0123-456789abcdef" }
]
...
}
If the owner
key is not present, then we know a subsequent request is needed.
If owner
is always present, then the client would need to inspect the owner
object to see if it has the name
and email
.
What is the reason for separating the link from the owner?
How about:
This would have 3 advantages: