Class AbstractHeadersSnippet
java.lang.Object
org.springframework.restdocs.snippet.TemplatedSnippet
org.springframework.restdocs.headers.AbstractHeadersSnippet
- All Implemented Interfaces:
Snippet
- Direct Known Subclasses:
RequestHeadersSnippet,ResponseHeadersSnippet
Abstract
TemplatedSnippet subclass that provides a base for snippets that
document a RESTful resource's request or response headers.- Author:
- Andreas Evers
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractHeadersSnippet(String type, List<HeaderDescriptor> descriptors, Map<String, Object> attributes) Creates a newAbstractHeadersSnippetthat will produce a snippet named<type>-headers. -
Method Summary
Modifier and TypeMethodDescriptioncreateModel(Operation operation) Create the model that should be used during template rendering to document the givenoperation.createModelForDescriptor(HeaderDescriptor descriptor) Returns a model for the givendescriptor.extractActualHeaders(Operation operation) Extracts the names of the headers from the request or response of the givenoperation.protected List<HeaderDescriptor>findMissingHeaders(Operation operation) Finds the headers that are missing from the operation.protected final List<HeaderDescriptor>Returns the list ofHeaderDescriptorsthat will be used to generate the documentation.Methods inherited from class org.springframework.restdocs.snippet.TemplatedSnippet
document, getAttributes, getSnippetName
-
Constructor Details
-
AbstractHeadersSnippet
protected AbstractHeadersSnippet(String type, List<HeaderDescriptor> descriptors, Map<String, Object> attributes) Creates a newAbstractHeadersSnippetthat will produce a snippet named<type>-headers. The headers will be documented using the givendescriptorsand the givenattributeswill be included in the model during template rendering.- Parameters:
type- the type of the headersdescriptors- the header descriptorsattributes- the additional attributes
-
-
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
-
findMissingHeaders
Finds the headers that are missing from the operation. A header is missing if it is described by one of theheaderDescriptorsbut is not present in the operation.- Parameters:
operation- the operation- Returns:
- descriptors for the headers that are missing from the operation
-
extractActualHeaders
Extracts the names of the headers from the request or response of the givenoperation.- Parameters:
operation- the operation- Returns:
- the header names
-
getHeaderDescriptors
Returns the list ofHeaderDescriptorsthat will be used to generate the documentation.- Returns:
- the header descriptors
-
createModelForDescriptor
Returns a model for the givendescriptor.- Parameters:
descriptor- the descriptor- Returns:
- the model
-