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
Display the source diff
Display the rich diff
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
Display the source diff
Display the rich diff
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.
203
+
Check out the https://rwcbook.github.io/hal-forms/[HAL-FORMS spec] to understand the details of the *_templates* attribute.
204
204
Read about the <<server.affordances,Affordances API>> to augment your controllers with this extra metadata.
205
205
206
206
As for single-item (`EntityModel`) and aggregate root collections (`CollectionModel`), Spring HATEOAS renders them
@@ -216,7 +216,7 @@ Spring HATEOAS allows to customize those by shaping the model type for the input
216
216
|Attribute|Description
217
217
|`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`.
218
218
|`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.
219
-
|`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.
219
+
|`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.
220
220
|===============
221
221
222
222
For types that you cannot annotate manually, you can register a custom pattern via a `HalFormsConfiguration` bean present in the application context.
@@ -243,7 +243,7 @@ HAL-FORMS contains attributes that are intended for human interpretation, like a
243
243
These can be defined and internationalized using Spring's resource bundle support and the `rest-messages` resource bundle configured by Spring HATEOAS by default.
244
244
245
245
==== Template titles
246
-
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.
246
+
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
247
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.
278
+
<1> All properties named `firstName` will get "Firstname" rendered, independent of the type they're declared in.
279
279
<2> The `firstName` property in types named `Employee` will be prompted "Firstname".
280
280
<3> The `firstName` property of `com.acme.Employee` will get a prompt of "Firstname" assigned.
281
281
====
@@ -358,7 +358,7 @@ The previous fragment was lifted from the spec. When Spring HATEOAS renders an `
358
358
359
359
* Put the `self` link into both the document's `href` attribute and the item-level `href` attribute.
360
360
* Put the rest of the model's links into both the top-level `links` as well as the item-level `links`.
361
-
* Extract the properties from the `EntityModel` and turn them into
361
+
* Extract the properties from the `EntityModel` and turn them into ...
362
362
====
363
363
364
364
When rendering a collection of resources, the document is almost the same, except there will be multiple entries inside
@@ -493,10 +493,10 @@ locale-specific message bundles and even internationalize the metadata.
493
493
== Registering a custom media type
494
494
495
495
Spring HATEOAS allows to integrate support for custom media types through a set of SPIs, that third parties can implement.
496
-
The building blocks of an such an implementations are:
496
+
The building blocks of an such an implementation are:
497
497
498
498
1. Some form of Jackson ObjectMapper customization. In its most simple case that's a Jackson `Module` implementation.
499
-
2. A `LinkDiscoverer` implementation so that the clientside support is able to detect links in representations generated.
499
+
2. A `LinkDiscoverer` implementation so that the client-side support is able to detect links in representations generated.
500
500
3. Some configuration infrastructure that will allow Spring HATEOAS to find the custom implementation and pick up its configuration.
501
501
502
502
[[mediatypes.custom.configuration]]
@@ -535,7 +535,7 @@ class MyMediaTypeConfigurationProvider
535
535
The configuration class needs to have a default constructor and expose two methods:
536
536
537
537
<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`).
538
-
<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.
538
+
<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.
539
539
====
540
540
541
541
The configuration class has to implement `HypermediaMappingInformation`. It could look as simple as this:
@@ -564,7 +564,7 @@ class MyMediaTypeConfiguration implements HypermediaMappingInformation {
564
564
----
565
565
<1> The configuration class returns the media type it wants to get Spring MVC / Spring WebFlux support set up.
566
566
<2> It overrides `getJacksonModule()` to provide custom serializers to create the media type specific representations.
567
-
<3> It also declares a custom `LinkDiscoverer` implementation for clientside support.
567
+
<3> It also declares a custom `LinkDiscoverer` implementation for client-side support.
568
568
====
569
569
570
570
The Jackson module usually declares `Serializer` and `Deserializer` implementations for the representation model types `RepresentationModel`, `EntityModel`, `CollectionModel` and `PagedModel`.
@@ -574,7 +574,7 @@ In case you need further customization of the Jackson `ObjectMapper` (like a cus
574
574
=== Recommendations
575
575
576
576
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.
577
-
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.
577
+
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.
578
578
579
-
The media types supported by default use the same configuration mechanism as thirdparty implementations would.
579
+
The media types supported by default use the same configuration mechanism as third-party implementations would do.
580
580
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