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
ConstructorsModifierConstructorDescriptionprotectedLinksSnippet(LinkExtractor linkExtractor, List<LinkDescriptor> descriptors) Creates a newLinksSnippetthat will extract links using the givenlinkExtractorand document them using the givendescriptors.protectedLinksSnippet(LinkExtractor linkExtractor, List<LinkDescriptor> descriptors, boolean ignoreUndocumentedLinks) Creates a newLinksSnippetthat will extract links using the givenlinkExtractorand document them using the givendescriptors.protectedLinksSnippet(LinkExtractor linkExtractor, List<LinkDescriptor> descriptors, Map<String, Object> attributes) Creates a newLinksSnippetthat will extract links using the givenlinkExtractorand document them using the givendescriptors.protectedLinksSnippet(LinkExtractor linkExtractor, List<LinkDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedLinks) Creates a newLinksSnippetthat will extract links using the givenlinkExtractorand document them using the givendescriptors. -
Method Summary
Modifier and TypeMethodDescriptionfinal LinksSnippetand(List<LinkDescriptor> additionalDescriptors) Returns a newLinksSnippetconfigured with this snippet's link extractor and attributes, and its descriptors combined with the givenadditionalDescriptors.final LinksSnippetand(LinkDescriptor... additionalDescriptors) Returns a newLinksSnippetconfigured 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 newLinksSnippetthat will extract links using the givenlinkExtractorand 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 newLinksSnippetthat will extract links using the givenlinkExtractorand document them using the givendescriptors. IfignoreUndocumentedLinksistrue, 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 newLinksSnippetthat will extract links using the givenlinkExtractorand document them using the givendescriptors. The givenattributeswill 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 newLinksSnippetthat will extract links using the givenlinkExtractorand document them using the givendescriptors. The givenattributeswill be included in the model during template rendering. IfignoreUndocumentedLinksistrue, 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:TemplatedSnippetCreate the model that should be used during template rendering to document the givenoperation. Any additional attributes that were supplied when thisTemplatedSnippetwere created will be automatically added to the model prior to rendering.- Specified by:
createModelin 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 newLinksSnippetconfigured 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 newLinksSnippetconfigured with this snippet's link extractor and attributes, and its descriptors combined with the givenadditionalDescriptors.- Parameters:
additionalDescriptors- the additional descriptors- Returns:
- the new snippet
-