spring-projects / spring-projects/spring-hateoas
Add a contentType property to the HAL-FORMS template element automatically or by hand
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 476
- PR merge metrics
- No merged PRs in 30d
Description
@gregturn asked me on Gitter to create this issue.
We talked about how one could add a 'contentType' property to a HAL-FORMS template element, either automagically or by hand.
@ingogriebsch Trying to understand HAL-FORMS in more detail and currently wondering how I can control to add a 'contentType' to a 'template'.
@gregturn And we haven't (yet) coded support to populate the rest of the HAL-FORMS fields. Spring HATEAOS has sought to capture a vendor neutral format that can be serialized into multiple media types. That avoids having to bake media type awareness into your application. However, when it comes to media type specifics, we may need to consider adding, perhaps, annotations to fill in the bits like contentType. For example, would a @HalForms annotation be useful on a domain object to flesh those details out? Is that the best approach?
@ingogriebsch I expected that the Introspection mechanism checks if the @RequestMapping on the @RestController has defined a 'consumes' or 'produces' and adds a 'contentType' element to the input and/or output without any further ado. I also checked the Affordances API if it allows me to define a contentType through the PayloadMetadata. Another option would be some kind of additional information on the object which represents the payload (maybe through a @HalForms as you mentioned) but it could be hard to add an annotation on every type of payload one wants to use (how about a MultipartFile for example?).
@gregturn That's a good idea. If you captured the consumes/produces idea into an issue, we can pursue that.
Feel free to change/cleanup this ticket as you wish. If I can help in some way, please let me know! :)
Original discussion starts here: https://gitter.im/spring-projects/spring-hateoas?at=5d876bbac77f285fb1c25f86
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Spring HATEOAS's HAL-FORMS support, the affordances API, and PayloadMetadata, then trace how @RequestMapping consumes and produces values are exposed during introspection. The issue leaves the automatic-versus-annotation design unresolved; done should define and implement how a template's contentType can be supplied and verify it for input and output templates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100