Class RequestFieldsSnippet
java.lang.Object
org.springframework.restdocs.snippet.TemplatedSnippet
org.springframework.restdocs.payload.AbstractFieldsSnippet
org.springframework.restdocs.payload.RequestFieldsSnippet
- All Implemented Interfaces:
Snippet
A
Snippet
that documents the fields in a request.- Author:
- Andy Wilkinson
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
RequestFieldsSnippet
(List<FieldDescriptor> descriptors) Creates a newRequestFieldsSnippet
that will document the fields in the request using the givendescriptors
.protected
RequestFieldsSnippet
(List<FieldDescriptor> descriptors, boolean ignoreUndocumentedFields) Creates a newRequestFieldsSnippet
that will document the fields in the request using the givendescriptors
.protected
RequestFieldsSnippet
(List<FieldDescriptor> descriptors, Map<String, Object> attributes) Creates a newRequestFieldsSnippet
that will document the fields in the request using the givendescriptors
.protected
RequestFieldsSnippet
(List<FieldDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedFields) Creates a newRequestFieldsSnippet
that will document the fields in the request using the givendescriptors
.protected
RequestFieldsSnippet
(PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors) Creates a newRequestFieldsSnippet
that will document the fields in the subsection of the request extracted by the givensubsectionExtractor
using the givendescriptors
.protected
RequestFieldsSnippet
(PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, boolean ignoreUndocumentedFields) Creates a newRequestFieldsSnippet
that will document the fields in the subsection of the request extracted by the givensubsectionExtractor
using the givendescriptors
.protected
RequestFieldsSnippet
(PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, Map<String, Object> attributes) Creates a newRequestFieldsSnippet
that will document the fields in the subsection of the request extracted by the givensubsectionExtractor
using the givendescriptors
.protected
RequestFieldsSnippet
(PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedFields) Creates a newRequestFieldsSnippet
that will document the fields in the subsection of the request extracted by the givensubsectionExtractor
using the givendescriptors
. -
Method Summary
Modifier and TypeMethodDescriptionfinal RequestFieldsSnippet
and
(List<FieldDescriptor> additionalDescriptors) Returns a newRequestFieldsSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.final RequestFieldsSnippet
and
(FieldDescriptor... additionalDescriptors) Returns a newRequestFieldsSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.final RequestFieldsSnippet
andWithPrefix
(String pathPrefix, List<FieldDescriptor> additionalDescriptors) Returns a newRequestFieldsSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.final RequestFieldsSnippet
andWithPrefix
(String pathPrefix, FieldDescriptor... additionalDescriptors) Returns a newRequestFieldsSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.protected byte[]
getContent
(Operation operation) Returns the content of the request or response extracted form the givenoperation
.protected org.springframework.http.MediaType
getContentType
(Operation operation) Returns the content type of the request or response extracted from the givenoperation
.Methods inherited from class org.springframework.restdocs.payload.AbstractFieldsSnippet
createModel, createModelForDescriptor, getFieldDescriptors, getSubsectionExtractor, isIgnoredUndocumentedFields
Methods inherited from class org.springframework.restdocs.snippet.TemplatedSnippet
document, getAttributes, getSnippetName
-
Constructor Details
-
RequestFieldsSnippet
Creates a newRequestFieldsSnippet
that will document the fields in the request using the givendescriptors
. Undocumented fields will trigger a failure.- Parameters:
descriptors
- the descriptors
-
RequestFieldsSnippet
Creates a newRequestFieldsSnippet
that will document the fields in the request using the givendescriptors
. IfignoreUndocumentedFields
istrue
, undocumented fields will be ignored and will not trigger a failure.- Parameters:
descriptors
- the descriptorsignoreUndocumentedFields
- whether undocumented fields should be ignored
-
RequestFieldsSnippet
Creates a newRequestFieldsSnippet
that will document the fields in the request using the givendescriptors
. The givenattributes
will be included in the model during template rendering. Undocumented fields will trigger a failure.- Parameters:
descriptors
- the descriptorsattributes
- the additional attributes
-
RequestFieldsSnippet
protected RequestFieldsSnippet(List<FieldDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedFields) Creates a newRequestFieldsSnippet
that will document the fields in the request using the givendescriptors
. The givenattributes
will be included in the model during template rendering. IfignoreUndocumentedFields
istrue
, undocumented fields will be ignored and will not trigger a failure.- Parameters:
descriptors
- the descriptorsattributes
- the additional attributesignoreUndocumentedFields
- whether undocumented fields should be ignored
-
RequestFieldsSnippet
protected RequestFieldsSnippet(PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors) Creates a newRequestFieldsSnippet
that will document the fields in the subsection of the request extracted by the givensubsectionExtractor
using the givendescriptors
. Undocumented fields will trigger a failure.- Parameters:
subsectionExtractor
- the subsection extractordescriptors
- the descriptors- Since:
- 1.2.0
-
RequestFieldsSnippet
protected RequestFieldsSnippet(PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, boolean ignoreUndocumentedFields) Creates a newRequestFieldsSnippet
that will document the fields in the subsection of the request extracted by the givensubsectionExtractor
using the givendescriptors
. IfignoreUndocumentedFields
istrue
, undocumented fields will be ignored and will not trigger a failure.- Parameters:
subsectionExtractor
- the subsection extractor documentdescriptors
- the descriptorsignoreUndocumentedFields
- whether undocumented fields should be ignored- Since:
- 1.2.0
-
RequestFieldsSnippet
protected RequestFieldsSnippet(PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, Map<String, Object> attributes) Creates a newRequestFieldsSnippet
that will document the fields in the subsection of the request extracted by the givensubsectionExtractor
using the givendescriptors
. The givenattributes
will be included in the model during template rendering. Undocumented fields will trigger a failure.- Parameters:
subsectionExtractor
- the subsection extractordescriptors
- the descriptorsattributes
- the additional attributes- Since:
- 1.2.0
-
RequestFieldsSnippet
protected RequestFieldsSnippet(PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedFields) Creates a newRequestFieldsSnippet
that will document the fields in the subsection of the request extracted by the givensubsectionExtractor
using the givendescriptors
. The givenattributes
will be included in the model during template rendering. IfignoreUndocumentedFields
istrue
, undocumented fields will be ignored and will not trigger a failure.- Parameters:
subsectionExtractor
- the path identifying the subsection of the payload to documentdescriptors
- the descriptorsattributes
- the additional attributesignoreUndocumentedFields
- whether undocumented fields should be ignored- Since:
- 1.2.0
-
-
Method Details
-
getContentType
Description copied from class:AbstractFieldsSnippet
Returns the content type of the request or response extracted from the givenoperation
.- Specified by:
getContentType
in classAbstractFieldsSnippet
- Parameters:
operation
- the operation- Returns:
- the content type
-
getContent
Description copied from class:AbstractFieldsSnippet
Returns the content of the request or response extracted form the givenoperation
.- Specified by:
getContent
in classAbstractFieldsSnippet
- Parameters:
operation
- the operation- Returns:
- the content
- Throws:
IOException
- if the content cannot be extracted
-
and
Returns a newRequestFieldsSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.- Parameters:
additionalDescriptors
- the additional descriptors- Returns:
- the new snippet
-
and
Returns a newRequestFieldsSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.- Parameters:
additionalDescriptors
- the additional descriptors- Returns:
- the new snippet
-
andWithPrefix
public final RequestFieldsSnippet andWithPrefix(String pathPrefix, FieldDescriptor... additionalDescriptors) Returns a newRequestFieldsSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
. The givenpathPrefix
is applied to the path of each additional descriptor.- Parameters:
pathPrefix
- the prefix to apply to the additional descriptorsadditionalDescriptors
- the additional descriptors- Returns:
- the new snippet
-
andWithPrefix
public final RequestFieldsSnippet andWithPrefix(String pathPrefix, List<FieldDescriptor> additionalDescriptors) Returns a newRequestFieldsSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
. The givenpathPrefix
is applied to the path of each additional descriptor.- Parameters:
pathPrefix
- the prefix to apply to the additional descriptorsadditionalDescriptors
- the additional descriptors- Returns:
- the new snippet
-