Commit Graph

748 Commits

Author SHA1 Message Date
Oliver Drotbohm
c6a6d370ad #1563 - Deprecate PayloadMetadata.getPropertyMetadata(…).
This method is currently used in test cases only and the just introduced ability to rename property makes the method not reliably usable as the way it is named doesn't convey which name is to be used. It currently is the potentially renamed value. Moving to the actual property name as input creates stronger boundaries to assume a type backing the metadata, which we want to avoid.
2021-06-29 16:15:24 +02:00
Oliver Drotbohm
8347554969 #1563 - Consider @JsonProperty-defined property name.
We now consider Jackson's @JsonProperty annotation to rename PropertyMetadata instances accordingly.

Original pull request: #1594.
2021-06-29 16:15:20 +02:00
Florian Cramer
a77c6e1593 #545 - Support for implicitly not required request parameters.
Handler method parameters annotated with @RequestParam(defaultValue = …) are implicitly not required and thus should still be advertised in the URI templated generated. Previously it was necessary to explicitly set @RequestParam(required = …) to false.

Original pull request: #1511.
Related ticket: #331.
2021-06-28 09:34:32 +02:00
Oliver Drotbohm
9702527786 #1548 - Delay request parameter variable lookup until necessary.
We pulled up the parameter name lookup for request parameters to avoid repeated lookups but unfortunately missed that the lookup will fail e.g. for @RequestParam Map<…> as we now strictly tried to find a request parameter name that doesn't actually exist in this case.
2021-06-18 14:48:07 +02:00
Oliver Drotbohm
d22629fd0b #1529 - Make WebConverters public. 2021-05-12 13:04:24 +02:00
Oliver Drotbohm
b03944be91 #1523 - Additional HtmlInputTypes (checkbox, radio, file). 2021-04-20 23:48:42 +02:00
Oliver Drotbohm
5764648adb #1515 - Fix key rendering of embedded resources.
We now also eagerly map the keys for the _embedded map in a HAL response to Strings to make sure they work properly when sorting of map keys is activated for the Jackson ObjectMapper.
2021-04-20 12:51:38 +02:00
Oliver Drotbohm
d7ac32a99d #1521 - Allow HATEOAS bootstrap without any default media type enabled.
@EnableHypermediaSupport(types = {}) was not working anymore as the Comparator implementation working with the selected types rejected an empty list. We now do not reject that anymore to enable applications that solely work with third party media types.
2021-04-19 16:53:46 +02:00
Oliver Drotbohm
91e17f1196 #1516 - Support for NamingBase in property translation for HAL.
We now also support the newly NamingBase introduced in Jackson 2.12 as a replacement for PropertyNamingStrategyBase.
2021-04-14 09:39:31 +02:00
Oliver Drotbohm
e939852362 #1515 - Fix HAL link serialization issues when Jackson map entry sorting is enabled.
Prior to this commit, the map of links to be rendered would key by LinkRelation. Unfortunately, Jackson requires `Map` keys to implement `Comparable` in case `SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS` is enabled. We now use the link relation's value as key right aways as Strings are comparable out of the box.

Switched to use Spring's MultiValueMap to avoid having to deal with the value list initialization ourselves.
2021-04-14 09:33:20 +02:00
Oliver Drotbohm
ebcbaeb7cc #1514 - Prepare changelog. 2021-04-13 19:41:47 +02:00
Oliver Drotbohm
bbb8f426fe #1510 - Support for defining the selected value on HalFormsOptions.
We now expose a HalFormsOptions.withSelectedValue(…) and propagate this into the HAL FORMS property field named "value".
2021-04-08 13:08:50 +02:00
Greg L. Turnquist
39775148dd #1509 - Migrate to main branch.
Move all project references to `main` instead of `master`.
2021-04-08 12:46:06 +02:00
Oliver Drotbohm
43b9f29ee8 #1507 - Fix potential NullPointerException in Jsr303AwarePropertyMetadata.
We now check whether we could really load `@Range`, which is only available in Hibernate Validator. An arrangement in which the Validation API JAR is on the classpath but not Hibernate Validator would let us end up with the relevant instance being `null` and need a check for before being handed into code that requires the type to not be `null`.
2021-04-03 17:16:23 +02:00
Oliver Drotbohm
6f559ad34a #1506 - Prepare 1.3 RC1 release.
Update changelog.
2021-03-31 15:56:45 +02:00
Oliver Drotbohm
01c5fae3f0 #1505 - Improve signatures of HalFormsOptions.inline(…).
A bit of generics ♥️ for HalFormsOptions.inline(…) to avoid compiler warnings.
2021-03-31 15:44:54 +02:00
Oliver Drotbohm
759785f98e #1504 - Add RepresentationModel.mapLinkIf(…). 2021-03-25 17:38:07 +01:00
Oliver Drotbohm
5ec99df255 #1483 - Make HalFormsConfiguration.getHalConfiguration() public again. 2021-03-25 16:47:21 +01:00
Oliver Drotbohm
7ff383b51c #1489 - Adapt changelog after 1.3 M3 release. 2021-03-25 16:46:42 +01:00
Oliver Drotbohm
ca1aebaaf6 #1494 - Improved HAL Link deserialization.
Configuring the Link.of(…) factory method as explicit creator method allows us to get rid of the wither chain previously required in HalLinkListDeserializer.
2021-03-16 09:45:16 +01:00
Oliver Drotbohm
8443bf788b #1492 - Upgrade to Jackson 2.12.2. 2021-03-16 08:59:52 +01:00
Oliver Drotbohm
47486f42d7 #118 - Always default to fallback ConversionService in WebMvcLinkBuilder. 2021-03-11 14:44:46 +01:00
Oliver Drotbohm
8e78cf2275 #1484 - Fix performance regression in WebHandler.
Moved the affordance metadata caching into SpringAffordanceBuilder and separate the caching of the metadata lookup from the assembly of the affordance. The latter is based on the URI resulting from expanding the request mapping with the given value and thus is likely to produce a lot of different values so that they're rather unsuitable as cache key.

That means that we now return fresh Affordance instances for every request which probably causes a tiny hit on performance but still does not need additional metadata lookups. Also, it opens up the door to enrich the affordances with property value providers that would allow us to render affordance fields that refer to a instances property, e.g. to render edit forms.
2021-03-08 14:26:08 +01:00
Oliver Drotbohm
a665388758 #1483 - Reference docs for options support. 2021-03-08 13:50:01 +01:00
Oliver Drotbohm
94a50786f4 #1483 - Support for HAL-FORMS options element.
We now support defining the options element [0] for a HAL-FORMS property by registering a lookup of HalFormsOptions instances on HalFormsConfiguration.

[0] https://rwcbook.github.io/hal-forms/#options-element
2021-03-08 13:50:01 +01:00
Oliver Drotbohm
a4aba5cbed #1477 - DelegatingEntityLinks implements EntityLinks. 2021-02-23 22:55:48 +01:00
Oliver Drotbohm
64254427d9 #1477 - Polishing. 2021-02-23 22:55:48 +01:00
Oliver Drotbohm
538a8a6874 #1477 - DelegatingEntityLinks now overrides linkForItemResource(Class<?>, Object). 2021-02-23 22:55:48 +01:00
Oliver Drotbohm
94fbb0b68b #1461 - Prepare 1.3 M2 release.
Updated changelog.
2021-02-16 14:18:49 +01:00
Oliver Drotbohm
cd927e08a4 #1468 - Mapping discoverer now keeps trailing slashes around. 2021-02-16 12:52:24 +01:00
Oliver Drotbohm
24a99d242b #1445, #1443, #1439, #1438, #1427 - Documentation for HAL-FORMS. 2021-02-15 19:30:54 +01:00
Oliver Drotbohm
919b202856 #1458 - Parsing Link instances now supports unquoted attribute values.
Switched from using regular expressions to a simple manual parsing algorithm for the attributes attached to a link. Adapt a couple of broken tests that previously erroneously worked.
2021-02-15 15:41:22 +01:00
Oliver Drotbohm
6c910adf16 #1457 - Add RepresentationModel.mapLink(LinkRelation, Function<Link, Link>). 2021-02-11 19:00:26 +01:00
Oliver Drotbohm
0aae59a5e3 #1453 - Make sure we only extend the default MappingJackson2HttpMessageConverter.
This is to make sure the custom converters registered by Spring Data REST, which all extend MJ2HMC, do not get the general customizations added as they otherwise trump the explicit configuration that Spring Data REST sets up.
2021-02-11 18:53:12 +01:00
Oliver Drotbohm
bb3ed0add1 #1456 - Properly detect Validation API in 2.0 or newer.
We now check for the presence of @Email to detect validation API in 2.0 or better.
2021-02-11 18:50:39 +01:00
Oliver Drotbohm
0f2ac8ecac #1450 - Fix template variable cleanup for variables using regular expressions.
Switched to manual parsing of template variables as regular expressions can contain { and } characters which makes matching variables using these as delimiters impossible.

Related ticket: #1412.
2021-02-10 21:37:37 +01:00
Oliver Drotbohm
c561822a45 #1453 - Switch to new converter / codec registration APIs in Spring 5.3.4.
Changed the configuration of media type specific representation model rendering to rather use the existing MappingJackson2JsonConverter than registering custom HttpMessageConverters ourselves. The same applies to codecs in WebFlux.

Added HypermediaMappingInformationComparator to be able to sort HypermediaMappingInformation instances by their corresponding media type configuration on @EnableHypermediaSupport.
2021-02-10 19:19:56 +01:00
Oliver Drotbohm
2a0b113a3d #1451 - Upgrade to ArchUnit 0.16.0. 2021-02-10 16:37:37 +01:00
Oliver Drotbohm
a8a8836898 #1253 - Allow custom media type aliases for HAL.
HalConfiguration now exposes a withMediaType(…) that adds custom media types in front of the default of `application/hal+json`. This allows developers to use a project specific media type which is treated like it being HAL in the first place.
2021-02-10 16:23:50 +01:00
Oliver Drotbohm
d0ff83c62e #118 - Use MVC ConversionService for parameter binding in link creation.
We now look up the ConversionService available in the ApplicationContext from Web(Mvc|Flux)LinkBuilder. Some API tweaks to WebHandler to allow the lookup from the current request. The general fallback is now the invocation of …toString() on the parameter value.

Fixes #118, #352, #144, #149.
2021-01-25 22:27:27 +01:00
Oliver Drotbohm
3da23a7d76 #1447 - Overhaul Jackson customizations for HAL FORMS.
Got rid of quite a few custom serializers in Jackson2HalFormsModule. We now rely on the HAL setup mostly and register a virtual bean property to render the _templates field. The Jackson component used for that is registered as Spring bean so that we can now use the HAL HandlerInstantiator with the Jackson2HalFormsModule.

Moved quite a few integration tests to the COntextualMapper API.
2021-01-22 21:58:43 +01:00
Oliver Drotbohm
b7877f2514 #1445 - Support for HAL FORMS type attribute on properties.
We now support rendering the type attribute on HAL FORMS properties derived from either an explicit @InputType annotation, derived from JSR-303 annotations (like @Email, @Range etc.), or the property's type as fallback.

Introduced HtmlInputType in a new 'html' package to capture the HTML input types needed for the implementation. That class is used as the default to derive the type based input types via a newly introduced InputTypeFactory registered via the Spring factories loader mechanism for user potentially plugging in a different strategy.
2021-01-22 12:24:14 +01:00
Oliver Drotbohm
2be404ef04 #1443 - Expose affordance input media type in HAL FORMS contentType attribute.
Fixed the contentType in HalFormsTemplate to only contain a single media type.

Also adapted HalFormsAffordanceModelFactory to the new API introduced for #1441.
2021-01-21 17:39:51 +01:00
Oliver Drotbohm
8557e69fdb #1442 - Exposes consumed media types on affordances.
InputPayloadMetadata now captures and exposes supported media types. SpringAffordanceBuilder obtains them from the newly introduced API available on MappingDiscoverer.
2021-01-21 17:29:28 +01:00
Oliver Drotbohm
7bd414e79a #1441 - Introduce AffordanceModelFactory.getAffordanceModel(ConfiguredAffordance).
Introduce a new overload in AffordanceModelFactory so that implementations get a single object handed to work with for better extensibility in the future.

Introduced ConfigurableAffordance to be used instead of AffordanceBuilder in assignments and ConfiguredAffordance to separate creation and consumption of affordances during setup.
2021-01-21 15:38:31 +01:00
Oliver Drotbohm
60bf4e92ff #1405 - Use ConcurrentLruCache for affordances.
We now use a ConcurrentLruCache limited to 256 entries instead of a ConcurrentReferenceHashMap to cache Affordance instances to prevent the cache from growing unboundedly before GC kicks in.
2021-01-20 20:30:30 +01:00
Oliver Drotbohm
752b000e6c #1427 - Support for the target attribute of HAL FORMS templates.
We now explicitly set the target attribute of HAL FORMS templates if the target of the affordance does not equal the target of the self link.
2021-01-20 19:12:43 +01:00
Oliver Drotbohm
675f9e3895 #1439 - Support for HAL FORMS min, max, minLength and maxLength attributes.
Introduce support for the min, max, minLength and maxLength fields for HAL FORMS property descriptors. Extended PropertyMetadata to capture those based on JSR-303 annotations.

Pulled up InputPayloadMetadata.createProperties(…) into AffordanceModel directly. Deprecated InputPayloadMetadata.applyTo(…).
2021-01-20 17:17:51 +01:00
Oliver Drotbohm
a16c54f7b3 #1438 - Support for HAL FORMS' placeholder template properties.
See the spec [0] for details. Significant rework of how an AffordanceModel and HalFormsAffordanceModel in particular translates into creating a representation that matches the affordance (see InputPayloadMetadata.createProperties(…)).

[0] https://rwcbook.github.io/hal-forms/#_code_placeholder_code
2021-01-19 17:39:22 +01:00
Oliver Drotbohm
6ad9012047 #1428 - Avoid rendering curies if none is available.
If CurieProvider.getCurieInformation(Links) returns an empty list of curies, we now don't render curies at all.
2021-01-18 17:35:58 +01:00