#837 - Polish section on affordances and spec links.

This commit is contained in:
Greg Turnquist
2019-03-03 14:24:56 -06:00
parent 7b27f527b4
commit 92120fd755
4 changed files with 19 additions and 20 deletions

View File

@@ -117,10 +117,8 @@ public class EmployeeController {
// Return the affordance + a link back to the entire collection resource.
return new EntityModel<>(EMPLOYEES.get(id), //
findOneLink //
.andAffordance( //
afford(methodOn(controllerClass).updateEmployee(null, id))) // <2>
.andAffordance( //
afford(methodOn(controllerClass).partiallyUpdateEmployee(null, id)))); // <3>
.andAffordance(afford(methodOn(controllerClass).updateEmployee(null, id))) // <2>
.andAffordance(afford(methodOn(controllerClass).partiallyUpdateEmployee(null, id)))); // <3>
}
// end::get[]

View File

@@ -7,14 +7,14 @@
"href" : "http://localhost:8080/employees/1"
}
},
"_templates" : {
"_templates" : { // <1>
"default" : {
"title" : null,
"method" : "put",
"method" : "put", // <2>
"contentType" : "",
"properties" : [ {
"properties" : [ { // <3>
"name" : "firstName",
"required" : true
"required" : true // <4>
}, {
"name" : "lastName",
"required" : true
@@ -23,13 +23,13 @@
"required" : true
} ]
},
"partiallyUpdateEmployee" : {
"partiallyUpdateEmployee" : { // <5>
"title" : null,
"method" : "patch",
"method" : "patch", // <6>
"contentType" : "",
"properties" : [ {
"name" : "firstName",
"required" : false
"required" : false // <7>
}, {
"name" : "lastName",
"required" : false

View File

@@ -1,6 +1,7 @@
[[fundamentals]]
= Fundamentals
:code-dir: ../../../src/docs/java/org/springframework/hateoas
:resource-dir: ../../../src/docs/resources/org/springframework/hateoas
This section covers the basics of Spring HATEOAS and its fundamental domain abstractions.
@@ -284,8 +285,7 @@ include::{resource-dir}/docs/mediatype/hal/forms/hal-forms-sample-with-notes.jso
<7> For `PATCH`, attributes are _not_ `required`.
====
This rich document, consumable by any HAL-FORMS aware client (as well as a HAL client configured to ignore unknown
attributes), includes enough extra details for full interaction with the resource.
This rich document, consumable by any HAL-FORMS aware client includes enough extra details for full interaction with the resource.
In fact, this type of document makes it easy to write custom client-side code to generate an HTML form:

View File

@@ -2,6 +2,7 @@
= Media types
:code-dir: ../../../src/docs/java/org/springframework/hateoas
:resource-dir: ../../../src/docs/resources/org/springframework/hateoas
:linkattrs:
[[mediatypes.hal]]
== HAL Hypertext Application Language
@@ -131,7 +132,7 @@ Since the purpose of the `CurieProvider` API is to allow for automatic curie cre
[[mediatypes.hal-forms]]
== HAL-FORMS
https://rwcbook.github.io/hal-forms/[HAL-FORMS] is designed to add runtime FORM support to the <<mediatypes.hal,HAL media type>>.
https://rwcbook.github.io/hal-forms/[HAL-FORMS, window="_blank"] is designed to add runtime FORM support to the <<mediatypes.hal,HAL media type>>.
[quote, Mike Amundsen, HAL-FORMS spec]
____
@@ -168,11 +169,11 @@ identically to <<mediatypes.hal,HAL documents>>.
[[mediatypes.collection-json]]
== Collection+JSON
http://amundsen.com/media-types/collection/format/[Collection+JSON] is a JSON spec registered with IANA-approved media type `application/vnd.collection+json`.
http://amundsen.com/media-types/collection/format/[Collection+JSON, window="_blank"] is a JSON spec registered with IANA-approved media type `application/vnd.collection+json`.
[quote, Mike Amundsen, Collection+JSON spec]
____
http://amundsen.com/media-types/collection/[Collection+JSON] is a JSON-based read/write hypermedia-type designed to support
http://amundsen.com/media-types/collection/[Collection+JSON, window="_blank"] is a JSON-based read/write hypermedia-type designed to support
management and querying of simple collections.
____
@@ -229,9 +230,7 @@ Spring HATEOAS more specifically will:
[[mediatypes.uber]]
== UBER - Uniform Basis for Exchanging Representations
http://uberhypermedia.org/[UBER] is an experimental JSON spec
NOTE: *UBER media type* is not associated in any way with Uber Technologies Inc., the ride sharing company.
http://uberhypermedia.org/[UBER, window="_blank"] is an experimental JSON spec
[quote, Mike Amundsen, UBER spec]
____
@@ -263,7 +262,9 @@ include::{resource-dir}/docs/mediatype/uber/uber-sample.json[]
====
This media type is still under development as is the spec itself. Feel free to
https://github.com/spring-projects/spring-hateoas/issues[open a ticket] if you run into issues using it.
https://github.com/spring-projects/spring-hateoas/issues[open a ticket, window="_blank"] if you run into issues using it.
NOTE: *UBER media type* is not associated in any way with *Uber Technologies Inc.*, the ride sharing company.
[[mediatypes.custom]]
== Registering a custom media type