HAL-FORMS: problems with the inlining mecanism
See original GitHub issueThe HAL-FORMS specification do not use the inlining mecanism, and rather recommends separating HAL and HAL FORMS documents. If I understood the implementation by Spring HATEOAS in this example, I think it reduces the features that can be offered by an API.
Let’s consider an example with a resource “issue” (/issues/{id}). When performing a GET, I want to see its details + some hypermedia controls to tell me how to “update the details”, how to “assign” it, how to “cancel” it and how to “mark it resolved”. And I want all this actions to be performed in a “command style” resources and not as direct updates of the “issue” resource.
The actual implemented iniling do not allow this design… because there is no way to reference an URI from the _template, it’s all implicitly linked to the self relation.
If the template object was inlined into a link object, then it would be possible to do that.
{
"_links": {
"self": {
"href": "/issues/1",
"_templates": {
"default": {
"title": "update",
"method" : "PUT"
}
}
},
"assignCommand" : {
"href" : "/issues/1/assign-commands",
"_templates": {
"default" : {
"title": "assign",
"method" : "POST",
"other" :" Attributes"
}
}
},
"resolveCommand" : {
"href" : "/issues/1/resolve-commands",
"_templates": {
"default" : {
"title": "resolve",
"method" : "POST",
"other" :" Attributes"
}
}
},
"cancelCommand" : {
"href" : "/issues/1/cancel-commands",
"_templates": {
"default" : {
"title": "cancel",
"method" : "POST",
"other" :" Attributes"
}
}
}
}
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:12 (3 by maintainers)
Inside
HalFormsTemplateBuilder
, if I replace……with…
…then this…
…will yield this HAL-FORMS document…
True, but in a HAL FORMS Document. If we consider that HAL FORMS document is identified by the relation in the Link object of the HAL document, then inlining it should be under the link object it refers to. Not at a global level…