Class LinksSnippet
java.lang.Object
org.springframework.restdocs.snippet.TemplatedSnippet
org.springframework.restdocs.hypermedia.LinksSnippet
- All Implemented Interfaces:
Snippet
A
Snippet
that documents a RESTful resource's links.-
Constructor Summary
ModifierConstructorDescriptionprotected
LinksSnippet
(LinkExtractor linkExtractor, List<LinkDescriptor> descriptors) Creates a newLinksSnippet
that will extract links using the givenlinkExtractor
and document them using the givendescriptors
.protected
LinksSnippet
(LinkExtractor linkExtractor, List<LinkDescriptor> descriptors, boolean ignoreUndocumentedLinks) Creates a newLinksSnippet
that will extract links using the givenlinkExtractor
and document them using the givendescriptors
.protected
LinksSnippet
(LinkExtractor linkExtractor, List<LinkDescriptor> descriptors, Map<String, Object> attributes) Creates a newLinksSnippet
that will extract links using the givenlinkExtractor
and document them using the givendescriptors
.protected
LinksSnippet
(LinkExtractor linkExtractor, List<LinkDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedLinks) Creates a newLinksSnippet
that will extract links using the givenlinkExtractor
and document them using the givendescriptors
. -
Method Summary
Modifier and TypeMethodDescriptionfinal LinksSnippet
and
(List<LinkDescriptor> additionalDescriptors) Returns a newLinksSnippet
configured with this snippet's link extractor and attributes, and its descriptors combined with the givenadditionalDescriptors
.final LinksSnippet
and
(LinkDescriptor... additionalDescriptors) Returns a newLinksSnippet
configured with this snippet's link extractor and attributes, and its descriptors combined with the givenadditionalDescriptors
.createModel
(Operation operation) Create the model that should be used during template rendering to document the givenoperation
.createModelForDescriptor
(LinkDescriptor descriptor) Returns a model for the givendescriptor
.protected final Map<String,
LinkDescriptor> Methods inherited from class org.springframework.restdocs.snippet.TemplatedSnippet
document, getAttributes, getSnippetName
-
Constructor Details
-
LinksSnippet
Creates a newLinksSnippet
that will extract links using the givenlinkExtractor
and document them using the givendescriptors
. Undocumented links will trigger a failure.- Parameters:
linkExtractor
- the link extractordescriptors
- the link descriptors
-
LinksSnippet
protected LinksSnippet(LinkExtractor linkExtractor, List<LinkDescriptor> descriptors, boolean ignoreUndocumentedLinks) Creates a newLinksSnippet
that will extract links using the givenlinkExtractor
and document them using the givendescriptors
. IfignoreUndocumentedLinks
istrue
, undocumented links will be ignored and will not trigger a failure.- Parameters:
linkExtractor
- the link extractordescriptors
- the link descriptorsignoreUndocumentedLinks
- whether undocumented links should be ignored
-
LinksSnippet
protected LinksSnippet(LinkExtractor linkExtractor, List<LinkDescriptor> descriptors, Map<String, Object> attributes) Creates a newLinksSnippet
that will extract links using the givenlinkExtractor
and document them using the givendescriptors
. The givenattributes
will be included in the model during template rendering. Undocumented links will trigger a failure.- Parameters:
linkExtractor
- the link extractordescriptors
- the link descriptorsattributes
- the additional attributes
-
LinksSnippet
protected LinksSnippet(LinkExtractor linkExtractor, List<LinkDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedLinks) Creates a newLinksSnippet
that will extract links using the givenlinkExtractor
and document them using the givendescriptors
. The givenattributes
will be included in the model during template rendering. IfignoreUndocumentedLinks
istrue
, undocumented links will be ignored and will not trigger a failure.- Parameters:
linkExtractor
- the link extractordescriptors
- the link descriptorsattributes
- the additional attributesignoreUndocumentedLinks
- whether undocumented links should be ignored
-
-
Method Details
-
createModel
Description copied from class:TemplatedSnippet
Create the model that should be used during template rendering to document the givenoperation
. Any additional attributes that were supplied when thisTemplatedSnippet
were created will be automatically added to the model prior to rendering.- Specified by:
createModel
in classTemplatedSnippet
- Parameters:
operation
- the operation- Returns:
- the model
-
getDescriptorsByRel
- Returns:
- the link descriptors
-
createModelForDescriptor
Returns a model for the givendescriptor
.- Parameters:
descriptor
- the descriptor- Returns:
- the model
-
and
Returns a newLinksSnippet
configured with this snippet's link extractor and attributes, and its descriptors combined with the givenadditionalDescriptors
.- Parameters:
additionalDescriptors
- the additional descriptors- Returns:
- the new snippet
-
and
Returns a newLinksSnippet
configured with this snippet's link extractor and attributes, and its descriptors combined with the givenadditionalDescriptors
.- Parameters:
additionalDescriptors
- the additional descriptors- Returns:
- the new snippet
-