Skip to content

application/hal+json is used, but it's non-standard #2276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tachi107 opened this issue Jan 4, 2025 · 3 comments
Closed

application/hal+json is used, but it's non-standard #2276

Tachi107 opened this issue Jan 4, 2025 · 3 comments
Assignees
Labels
in: mediatypes Media type related functionality type: enhancement
Milestone

Comments

@Tachi107
Copy link

Tachi107 commented Jan 4, 2025

Hi,

spring-hateoas uses the application/hal+json media type, but no such media type is registered with IANA. The standard media type is application/vnd.hal+json (note the "vnd." prefix).

The docs mention that if the client sets the Accept header to application/hal+json, Spring will return the HAL representation of the resource. In my opinion, such representation should be returned also if the (registered) application/vnd.hal+json media type is used instead.

Here's the relevant documentation section:

If you returned such an instance from a Spring MVC or WebFlux controller and the client sent an `Accept` header set to `application/hal+json`, the response would look as follows:

Bye!

@odrotbohm odrotbohm self-assigned this Jan 17, 2025
@odrotbohm odrotbohm added type: enhancement in: mediatypes Media type related functionality labels Jan 17, 2025
@odrotbohm odrotbohm added this to the 2.5.0-M1 milestone Jan 17, 2025
@odrotbohm
Copy link
Member

I've been following the RFC primarily and that only mentions the application/hal+json. I think we can introduce an additional constant VND_HAL_JSON to capture the registered media type.

@Tachi107
Copy link
Author

Tachi107 commented Jan 17, 2025 via email

odrotbohm added a commit that referenced this issue Jan 17, 2025
The media type identifier for HAL registered with the IANA is application/vnd.hal+json, notably different from application/hal+json used in the RFC document. This commit adds a constant for that media type identifier and updates the configuration spots necessary to additionally consider it.

[0] https://www.iana.org/assignments/media-types/application/vnd.hal+json
[1] https://datatracker.ietf.org/doc/html/draft-kelly-json-hal
@odrotbohm
Copy link
Member

This is now in. Configuration, we apply is augmented to also support the new official media type (link discoverers etc.). I've also tweaked Spring Data REST accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: mediatypes Media type related functionality type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants