You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/asciidoc/client.adoc
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -77,7 +77,7 @@ Instead of fetching a single resource, this one deserializes a collection into `
77
77
78
78
When working with hypermedia enabled representations, a common task is to find a link with a particular relation type in it. Spring HATEOAS provides https://code.google.com/p/json-path[JSONPath]-based implementations of the `LinkDiscoverer` interface for either the default representation rendering or HAL out of the box. When using `@EnableHypermediaSupport`, we automatically expose an instance supporting the configured hypermedia type as a Spring bean.
79
79
80
-
Alternatively, you can setup and use an instance as follows:
80
+
Alternatively, you can set up and use an instance as follows:
Copy file name to clipboardExpand all lines: src/main/asciidoc/configuration.adoc
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ This section describes how to configure Spring HATEOAS.
6
6
[[configuration.at-enable]]
7
7
== Using `@EnableHypermediaSupport`
8
8
9
-
To let the `RepresentationModel` subtypes be rendered according to the specification of various hypermedia representations types, you can activate support for a particular hypermedia representation format through `@EnableHypermediaSupport`. The annotation takes a `HypermediaType` enumeration as its argument. Currently, we support https://tools.ietf.org/html/draft-kelly-json-hal[HAL] as well as a default rendering. Using the annotation triggers the following:
9
+
To let the `RepresentationModel` subtypes be rendered according to the specification of various hypermedia representation types, you can activate support for a particular hypermedia representation format through `@EnableHypermediaSupport`. The annotation takes a `HypermediaType` enumeration as its argument. Currently, we support https://tools.ietf.org/html/draft-kelly-json-hal[HAL] as well as a default rendering. Using the annotation triggers the following:
10
10
11
11
* It registers necessary Jackson modules to render `EntityModel` and `CollectionModel` in the hypermedia specific format.
12
12
* If JSONPath is on the classpath, it automatically registers a `LinkDiscoverer` instance to look up links by their `rel` in plain JSON representations (see <<client.link-discoverer>>).
@@ -18,7 +18,7 @@ To let the `RepresentationModel` subtypes be rendered according to the specifica
18
18
19
19
By default, `@EnableHypermediaSupport` will reflectively detect the web application stack you're using and hook into the Spring components registered for those to enable support for hypermedia representations.
20
20
However, there are situations in which you'd only explicitly want to activate support for a particular stack.
21
-
E.g. if your Spring WebMVC based application uses WebFlux' `WebClient` to make outgoing requests and that one is not supposed to work with hypermedia elements, you can restrict the functionality to be enabled by explicitly declaring WebMvc in the configuration:
21
+
E.g. if your Spring WebMVC based application uses WebFlux' `WebClient` to make outgoing requests and that one is not supposed to work with hypermedia elements, you can restrict the functionality to be enabled by explicitly declaring WebMVC in the configuration:
22
22
23
23
.Explicitly activating hypermedia support for a particular web stack
`Link` exposes other attributes as defined in https://tools.ietf.org/html/rfc5988[RFC-5988].
43
43
You can set them by calling the corresponding wither method on a `Link` instance.
44
44
45
-
Find more information on how to create links pointing to Spring MVC and Spring WebFlux controllers in <<server.link-builder>>.
45
+
Find more information on how to create links pointing to Spring MVC and Spring WebFlux controllers in <<server.link-builder.webmvc>> and <<server.link-builder.webflux>>.
Checkout the https://rwcbook.github.io/hal-forms/[HAL-FORMS spec] to understand the details of the *_templates* attribute.
204
+
Check out the https://rwcbook.github.io/hal-forms/[HAL-FORMS spec] to understand the details of the *_templates* attribute.
205
205
Read about the <<server.affordances,Affordances API>> to augment your controllers with this extra metadata.
206
206
207
207
As for single-item (`EntityModel`) and aggregate root collections (`CollectionModel`), Spring HATEOAS renders them
@@ -217,7 +217,7 @@ Spring HATEOAS allows to customize those by shaping the model type for the input
217
217
|Attribute|Description
218
218
|`readOnly`| Set to `true` if there's no setter method for the property. If that is present, use Jackson's `@JsonProperty(Access.READ_ONLY)` on the accessors or field explicitly. Not rendered by default, thus defaulting to `false`.
219
219
|`regex`| Can be customized by using JSR-303's `@Pattern` annotation either on the field or a type. In case of the latter the pattern will be used for every property declared as that particular type. Not rendered by default.
220
-
|`required`| Can be customized by using JSR-303's `@NotNull`. Not rendered by default and thus defaulting to `false`. Templates using `PATCH` as method will automatically have set all properties to not required.
220
+
|`required`| Can be customized by using JSR-303's `@NotNull`. Not rendered by default and thus defaulting to `false`. Templates using `PATCH` as method will automatically have all properties set to not required.
221
221
|===============
222
222
223
223
For types that you cannot annotate manually, you can register a custom pattern via a `HalFormsConfiguration` bean present in the application context.
@@ -244,7 +244,7 @@ HAL-FORMS contains attributes that are intended for human interpretation, like a
244
244
These can be defined and internationalized using Spring's resource bundle support and the `rest-messages` resource bundle configured by Spring HATEOAS by default.
245
245
246
246
==== Template titles
247
-
To define a template title use the following pattern: `_templates.$affordanceName.title`. Note, that in HAL-FORMS, the name of a template is `default` if it is the only one.
247
+
To define a template title use the following pattern: `_templates.$affordanceName.title`. Note that in HAL-FORMS, the name of a template is `default` if it is the only one.
248
248
This means that you'll usually have to qualify the key with the local or fully qualified input type name that affordance describes.
<1> All properties named `email` will get "Firstname" rendered, independent of the type they're declared in.
279
+
<1> All properties named `firstName` will get "Firstname" rendered, independent of the type they're declared in.
280
280
<2> The `firstName` property in types named `Employee` will be prompted "Firstname".
281
281
<3> The `firstName` property of `com.acme.Employee` will get a prompt of "Firstname" assigned.
282
282
====
@@ -394,7 +394,7 @@ The previous fragment was lifted from the spec. When Spring HATEOAS renders an `
394
394
395
395
* Put the `self` link into both the document's `href` attribute and the item-level `href` attribute.
396
396
* Put the rest of the model's links into both the top-level `links` as well as the item-level `links`.
397
-
* Extract the properties from the `EntityModel` and turn them into
397
+
* Extract the properties from the `EntityModel` and turn them into ...
398
398
====
399
399
400
400
When rendering a collection of resources, the document is almost the same, except there will be multiple entries inside
@@ -529,10 +529,10 @@ locale-specific message bundles and even internationalize the metadata.
529
529
== Registering a custom media type
530
530
531
531
Spring HATEOAS allows to integrate support for custom media types through a set of SPIs, that third parties can implement.
532
-
The building blocks of an such an implementations are:
532
+
The building blocks of an such an implementation are:
533
533
534
534
1. Some form of Jackson ObjectMapper customization. In its most simple case that's a Jackson `Module` implementation.
535
-
2. A `LinkDiscoverer` implementation so that the clientside support is able to detect links in representations generated.
535
+
2. A `LinkDiscoverer` implementation so that the client-side support is able to detect links in representations generated.
536
536
3. Some configuration infrastructure that will allow Spring HATEOAS to find the custom implementation and pick up its configuration.
537
537
538
538
[[mediatypes.custom.configuration]]
@@ -571,7 +571,7 @@ class MyMediaTypeConfigurationProvider
571
571
The configuration class needs to have a default constructor and expose two methods:
572
572
573
573
<1> A method returning a Spring configuration class that will be included in the application bootstrap when Spring HATEOAS is activated (either implicitly via Spring Boot auto-configuration or via `@EnableHypermediaSupport`).
574
-
<2> A callback method that will get the application selected media types to activate passed. This allows the media type implementation to control, when it it will be activated.
574
+
<2> A callback method that will get passed the application selected media types to activate. This allows the media type implementation to control, when it will be activated.
575
575
====
576
576
577
577
The configuration class has to implement `HypermediaMappingInformation`. It could look as simple as this:
@@ -600,7 +600,7 @@ class MyMediaTypeConfiguration implements HypermediaMappingInformation {
600
600
----
601
601
<1> The configuration class returns the media type it wants to get Spring MVC / Spring WebFlux support set up.
602
602
<2> It overrides `getJacksonModule()` to provide custom serializers to create the media type specific representations.
603
-
<3> It also declares a custom `LinkDiscoverer` implementation for clientside support.
603
+
<3> It also declares a custom `LinkDiscoverer` implementation for client-side support.
604
604
====
605
605
606
606
The Jackson module usually declares `Serializer` and `Deserializer` implementations for the representation model types `RepresentationModel`, `EntityModel`, `CollectionModel` and `PagedModel`.
@@ -610,7 +610,7 @@ In case you need further customization of the Jackson `ObjectMapper` (like a cus
610
610
=== Recommendations
611
611
612
612
The preferred way to implement media type representations is by providing a type hierarchy that matches the expected format and can be serialized by Jackson as is.
613
-
In the `Serializer` and `Deserializer` implementations registered for `RepresentationModel`, convert the instances into the media typespecific model types and then lookup the Jackson serializer for those.
613
+
In the `Serializer` and `Deserializer` implementations registered for `RepresentationModel`, convert the instances into the media type-specific model types and then lookup the Jackson serializer for those.
614
614
615
-
The media types supported by default use the same configuration mechanism as thirdparty implementations would.
615
+
The media types supported by default use the same configuration mechanism as third-party implementations would do.
616
616
So it's worth studying the implementations in https://github.com/spring-projects/spring-hateoas/tree/master/src/main/java/org/springframework/hateoas/mediatype[the `mediatype` package].
0 commit comments