question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a contentType property to the HAL-FORMS template element automatically or by hand

See original GitHub issue

@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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ingogriebschcommented, Nov 7, 2019

@gregturn I like it! 👍

1reaction
gregturncommented, Nov 1, 2019

I’ve coded a patch that adds incoming and outgoing media types to the AffordanceModelFactory and AffordanceBuilder API. SpringAffordanceBuilder is able to use this to collection consumes/produces details from Spring MVC/WebFlux methods and embed them in the affordance details.

HAL-FORMS can now look up incoming media types and use it to populate contentType. Other media types are free to leverage this additional meta data.

The changes are as backwards compatible as possible, with deprecations in place, which we should be able to then remove in the 1.2 time frame.

The test controller have been updated to demonstrate this, but it’s debatable if we want to keep those changes. We may wish to have a separate WebFluxEmployeeController/WebMvcEmployeeController that exercises and verifies this feature.

Feedback welcome.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring HATEOAS - Reference Documentation
HAL-FORMS contains attributes that are intended for human interpretation, like a template's title or property prompts. These can be defined and ...
Read more >
The HAL-FORMS Media Type
This document describes a simple media type designed to add runtime FORM support for the [HAL] media type. This is an independent backward-compatible ......
Read more >
ContentType Element (ContentType) - Microsoft Learn
Specifies the Windows SharePoint Services 2.0 list template type to which this content type maps. For example, the Document content type maps to ......
Read more >
Untitled
Ozyigit hakan, Marjo nevala facebook, Alcohol hand rub manufacturers india, ... Last remnant caedmon quest, Atronach element collector achievement, ...
Read more >
spring get request headers from context - Neelkanth group of company
JmsTemplate automatically detects such transactional resources and operates ... You can add custom client properties by adding either string properties or ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found