Introduce `HypermediaWebClientConfigurer` with a simple API that registers hypermedia types via `WebClient.Builder`.
Deprecate `WebClientConfigurer`, leveraging the new solution.
Update reference documentation showing how to use it, with and without Spring Boot.
Create a HypermediaRestTemplateConfigurer bean registered as a Spring HATEOAS bean.
Update reference documentation to show how to use it directly and with Spring Boot via RestTemplateCustomizer.
Appears one test case exerted a false positive. Fixing it exposed a gap and how to properly configure an existing WebTestClient (which is now in the reference docs).
This commit adds String constants to IanaLinkRelations, so that IanaLinkRelations can be leveraged in places where compile time constants are required, such as Relation#itemRelation and Relation#collectionRelation.
Switched to a less complicated implementation of the interface method parameter annotation lookup by using Spring's ClassUtils.getInterfaceMethodIfPossible(…).
Simplified test cases to pure unit test on the link builder APIs. We don't need to fully execute a complete MVC/WebFlux request/response cycle to verify the link creation to pick up the parameter annotations from the interfaces.
Original pull request: #1194.
When forming links, look at a controller class's interface definitions for possible Spring Web annotations.
Related issues: spring-projects/spring-framework#15682
Original pull request: #1194.
A bit of Javadoc on the factory methods. Avoiding abbreviations in method names, shorter parameter names. More trailing whitespace removal.
Reformatting of method invocation in test cases.
Original pull request: #1192.
This commit introduces ….of(…) factory methods on all RepresentationModel types as well as Link. RepresentationModel.of(…) transparently creates a EntityModel or CollectionModel depending on the value handed into the method.
Problem has been redesigned for immutability. Extensions to the payload body are now implemented by wrapping a either an object exposing the properties to add in turn or a plain Map.
Added infrastructure configuration to make sure that Problem instances returned from controller methods (even if wrapped into a ResponseEntity<?>) cause the ContentType header to be set to application/problem+json. HyperMediaMappingInformation now allows to customize the root domain type to signal serialization support for.
Few cleanups regarding the ObjectMapper setup in test cases.
RestTemplateHateoasConfiguration is a BeanPostProcessor and previously used a direct reference to WebConverters which caused downstream dependencies to be initialized once Spring Framework looks up BeanPostProcessors. This renders all of those dependencies ineligible of being post-processed by other BeanPostProcessors in turn.
This is now fixed by using an ObjectProvider<WebConverters> from within RestTemplateHateoasConfiguration instead, so that the initialization is delayed until the processing of the first bean is triggered.
Using a custom serializer seems to break downstream projects that also register serializers for EntityModel. We're now using extra methods on EntityModel itself that do the trick as well.
The flag to control this had been directly configured on the HalHandlerInstantiator which wasn't accessible to users in the first place. Refined the setup and forwarding of the bean factory into HalHandlerInstantiator so that non-Spring-HATEOAS Jackson serializer lookups are routed through the Spring container potentially picking up prototype bean definitions.
We now keep internal methods in EntityModel that are configured using Jackson annotations so that it'd populate the content with a Map in case Map<String, Content> is defined as payload type.
We now register a custom serializer to massage EntityModel instances into dedicated types that – in case of a Map being the content of the entity model – wrap the model into a type that applies the necessary Jackson tweaks to properly unwrap a Map.
The rendering of HAL's link relations now applies Jackson's PropertyNamingStrategy if one is configured except it's a IANA link relation. This behavior can be opt out from by setting HalConfiguration.withApplyPropertyNamingStrategy(false).
LinkRelation now has a ….map(…) method allowing the post-processing of it given a Function<String, String>. By default, that's applied to all relations that are not IANA ones. HalLinkRelation applies this transformation to only the local part of the relation. Tweaked IanaLinkRelations.isIanaLinkRelation(…) to do a simple ….contains(…) check first before we stream over all values to apply a case insensitive check.
The base URI we create now consists of the requests root URI plus the context path concatenated. On actual UriComponentsBuilder creation we then simply append the path discovered from the method mapping.