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
ModifierConstructorDescriptionprotected
AbstractHeadersSnippet
(String type, List<HeaderDescriptor> descriptors, Map<String, Object> attributes) Creates a newAbstractHeadersSnippet
that 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 ofHeaderDescriptors
that 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 newAbstractHeadersSnippet
that will produce a snippet named<type>-headers
. The headers will be documented using the givendescriptors
and the givenattributes
will 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: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
-
findMissingHeaders
Finds the headers that are missing from the operation. A header is missing if it is described by one of theheaderDescriptors
but 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 ofHeaderDescriptors
that 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
-