I'm currently developing an API using HAL-forms, and it's been frictionless until now. For this representation, I have some properties deep into it that are related to some other resource.
If I understood well, the main resource is at the top level, and any embedded ones are under _embedded
. For this property, however, extracting the resource to the _embedded
property puts it too far from its usage, and actually makes it hard to discern to what inner property it belongs to.
My current solution is to just embed the resource with its links inside the property it belongs, for example:
{ _links: {"self": {"href": ... } }, _embedded: {"some_resource": {"_links": {"self": {"href": ... } } } },"id": 1,"title": "A title","notes": [ {"title": "First note","date": "2024-04-28","author": {"name": "Some author","id": 1,"_links": {"self": {"href": ... } } } } ]}
Each note's author is the embedded resource on which I want to put links. This is just an example that resembles my resource, but note authors are even more deeply nested in my actual resource.
Is this a good design? Is this allowed in HAL? Or is there a more reasonable alternative?