-
Notifications
You must be signed in to change notification settings - Fork 472
Description
It took me a while to reconstruct the entire problem chain.
The problem is that with the update to Spring Boot 3.5.0 and hateoas 2.5.0, the default media type in the web test client changed. Before, it was application/json, and now it's application/hal+json, which is changed if you don't specify an explicit content type in the web test client.
The root of the problem is that MediaTypes.VND_HAL_JSON was added to the HalConfiguration.
See here: https://github.com/spring-projects/spring-hateoas/blob/main/src/main/java/org/springframework/hateoas/mediatype/hal/HalConfiguration.java#L70
With the second type the order is now different and the AutoConfiguration here no longer works:
https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfiguration.java
Because the withMediaType
https://github.com/spring-projects/spring-hateoas/blob/main/src/main/java/org/springframework/hateoas/mediatype/hal/HalConfiguration.java#L237
is setting MediaTypes.APPLICATION+JSON to second position in the new list instead of the first position.
In the end this configurer is now setting application/hal+json as default and not application/json
Is there a reason why HalConfiguration is not adding the new media type to position 0
e.g
newMediaTypes.add(0, mediaType);