public abstract class HypermediaDocumentation extends Object
Modifier and Type | Method and Description |
---|---|
static LinkExtractor |
atomLinks()
Returns a
LinkExtractor capable of extracting links in Atom format where
the links are found in an array named links . |
static LinkExtractor |
halLinks()
Returns a
LinkExtractor capable of extracting links in Hypermedia
Application Language (HAL) format where the links are found in a map named
_links . |
static Snippet |
links(LinkDescriptor... descriptors)
Returns a new
Snippet that will document the links in the API operation's
response. |
static Snippet |
links(LinkExtractor linkExtractor,
LinkDescriptor... descriptors)
Returns a new
Snippet that will document the links in the API operation's
response. |
static Snippet |
links(LinkExtractor linkExtractor,
Map<String,Object> attributes,
LinkDescriptor... descriptors)
Returns a new
Snippet that will document the links in the API operation's
response. |
static Snippet |
links(Map<String,Object> attributes,
LinkDescriptor... descriptors)
Returns a new
Snippet that will document the links in the API call's
response. |
static LinkDescriptor |
linkWithRel(String rel)
Creates a
LinkDescriptor that describes a link with the given rel . |
public static LinkDescriptor linkWithRel(String rel)
LinkDescriptor
that describes a link with the given rel
.rel
- The rel of the linkLinkDescriptor
ready for further configurationpublic static Snippet links(LinkDescriptor... descriptors)
Snippet
that will document the links in the API operation's
response. Links will be extracted from the response automatically based on its
content type and will be documented using the given descriptors
.
If a link is present in the response, but is not documented by one of the descriptors, a failure will occur when the snippet is invoked. Similarly, if a link is documented, is not marked as optional, and is not present in the response, a failure will also occur.
If you do not want to document a link, a link descriptor can be marked as
IgnorableDescriptor.ignored
. This will prevent it from appearing in the
generated snippet while avoiding the failure described above.
descriptors
- the descriptions of the response's linkspublic static Snippet links(Map<String,Object> attributes, LinkDescriptor... descriptors)
Snippet
that will document the links in the API call's
response. The given attributes
will be available during snippet generation.
Links will be extracted from the response automatically based on its content type
and will be documented using the given descriptors
.
If a link is present in the response, but is not documented by one of the descriptors, a failure will occur when the snippet is invoked. Similarly, if a link is documented, is not marked as optional, and is not present in the response, a failure will also occur.
If you do not want to document a link, a link descriptor can be marked as
IgnorableDescriptor.ignored
. This will prevent it from appearing in the
generated snippet while avoiding the failure described above.
attributes
- the attributesdescriptors
- the descriptions of the response's linkspublic static Snippet links(LinkExtractor linkExtractor, LinkDescriptor... descriptors)
Snippet
that will document the links in the API operation's
response. Links will be extracted from the response using the given
linkExtractor
and will be documented using the given descriptors
.
If a link is present in the response, but is not documented by one of the descriptors, a failure will occur when the snippet is invoked. Similarly, if a link is documented, is not marked as optional, and is not present in the response, a failure will also occur.
If you do not want to document a link, a link descriptor can be marked as
IgnorableDescriptor.ignored
. This will prevent it from appearing in the
generated snippet while avoiding the failure described above.
linkExtractor
- used to extract the links from the responsedescriptors
- the descriptions of the response's linkspublic static Snippet links(LinkExtractor linkExtractor, Map<String,Object> attributes, LinkDescriptor... descriptors)
Snippet
that will document the links in the API operation's
response. The given attributes
will be available during snippet generation.
Links will be extracted from the response using the given linkExtractor
and
will be documented using the given descriptors
.
If a link is present in the response, but is not documented by one of the descriptors, a failure will occur when the snippet is invoked. Similarly, if a link is documented, is not marked as optional, and is not present in the response, a failure will also occur.
If you do not want to document a link, a link descriptor can be marked as
IgnorableDescriptor.ignored
. This will prevent it from appearing in the
generated snippet while avoiding the failure described above.
attributes
- the attributeslinkExtractor
- used to extract the links from the responsedescriptors
- the descriptions of the response's linkspublic static LinkExtractor halLinks()
LinkExtractor
capable of extracting links in Hypermedia
Application Language (HAL) format where the links are found in a map named
_links
. For example:
{ "_links": { "self": { "href": "http://example.com/foo" } } }
public static LinkExtractor atomLinks()
LinkExtractor
capable of extracting links in Atom format where
the links are found in an array named links
. For example:
{ "links": [ { "rel": "self", "href": "http://example.com/foo" } ] }