Class RequestPartFieldsSnippet
java.lang.Object
org.springframework.restdocs.snippet.TemplatedSnippet
org.springframework.restdocs.payload.AbstractFieldsSnippet
org.springframework.restdocs.payload.RequestPartFieldsSnippet
- All Implemented Interfaces:
Snippet
A
Snippet
that documents the fields in a request part.- Since:
- 1.2.0
- Author:
- Mathieu Pousse, Andy Wilkinson
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
RequestPartFieldsSnippet
(String partName, List<FieldDescriptor> descriptors) Creates a newRequestPartFieldsSnippet
that will document the fields in the request part using the givendescriptors
.protected
RequestPartFieldsSnippet
(String partName, List<FieldDescriptor> descriptors, boolean ignoreUndocumentedFields) Creates a newRequestPartFieldsSnippet
that will document the fields in the request part using the givendescriptors
.protected
RequestPartFieldsSnippet
(String partName, List<FieldDescriptor> descriptors, @Nullable Map<String, Object> attributes) Creates a newRequestFieldsSnippet
that will document the fields in the request using the givendescriptors
.protected
RequestPartFieldsSnippet
(String partName, List<FieldDescriptor> descriptors, @Nullable Map<String, Object> attributes, boolean ignoreUndocumentedFields) Creates a newRequestFieldsSnippet
that will document the fields in the request using the givendescriptors
.protected
RequestPartFieldsSnippet
(String partName, @Nullable PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors) Creates a newRequestPartFieldsSnippet
that will document the fields in a subsection of the request part using the givendescriptors
.protected
RequestPartFieldsSnippet
(String partName, @Nullable PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, boolean ignoreUndocumentedFields) Creates a newRequestPartFieldsSnippet
that will document the fields in a subsection the request part using the givendescriptors
.protected
RequestPartFieldsSnippet
(String partName, @Nullable PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, @Nullable Map<String, Object> attributes) Creates a newRequestPartFieldsSnippet
that will document the fields in a subsection of the request part using the givendescriptors
.protected
RequestPartFieldsSnippet
(String partName, @Nullable PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, @Nullable Map<String, Object> attributes, boolean ignoreUndocumentedFields) Creates a newRequestPartFieldsSnippet
that will document the fields in a subsection of the request part using the givendescriptors
. -
Method Summary
Modifier and TypeMethodDescriptionfinal RequestPartFieldsSnippet
and
(List<FieldDescriptor> additionalDescriptors) Returns a newRequestPartFieldsSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.final RequestPartFieldsSnippet
and
(FieldDescriptor... additionalDescriptors) Returns a newRequestPartFieldsSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.final RequestPartFieldsSnippet
andWithPrefix
(String pathPrefix, List<FieldDescriptor> additionalDescriptors) Returns a newRequestFieldsSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.final RequestPartFieldsSnippet
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 @Nullable 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
-
RequestPartFieldsSnippet
Creates a newRequestPartFieldsSnippet
that will document the fields in the request part using the givendescriptors
. Undocumented fields will trigger a failure.- Parameters:
partName
- the part namedescriptors
- the descriptors
-
RequestPartFieldsSnippet
protected RequestPartFieldsSnippet(String partName, List<FieldDescriptor> descriptors, boolean ignoreUndocumentedFields) Creates a newRequestPartFieldsSnippet
that will document the fields in the request part using the givendescriptors
. IfignoreUndocumentedFields
istrue
, undocumented fields will be ignored and will not trigger a failure.- Parameters:
partName
- the part namedescriptors
- the descriptorsignoreUndocumentedFields
- whether undocumented fields should be ignored
-
RequestPartFieldsSnippet
protected RequestPartFieldsSnippet(String partName, List<FieldDescriptor> descriptors, @Nullable Map<String, Object> attributes) 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:
partName
- the part namedescriptors
- the descriptorsattributes
- the additional attributes
-
RequestPartFieldsSnippet
protected RequestPartFieldsSnippet(String partName, List<FieldDescriptor> descriptors, @Nullable 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:
partName
- the part namedescriptors
- the descriptorsattributes
- the additional attributesignoreUndocumentedFields
- whether undocumented fields should be ignored
-
RequestPartFieldsSnippet
protected RequestPartFieldsSnippet(String partName, @Nullable PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors) Creates a newRequestPartFieldsSnippet
that will document the fields in a subsection of the request part using the givendescriptors
. The subsection will be extracted using the givensubsectionExtractor
. If the extractor isnull
the fields of the entire request part will be documented. Undocumented fields will trigger a failure.- Parameters:
partName
- the part namesubsectionExtractor
- the subsection extractor, ornull
to document the fields of the entire request partdescriptors
- the descriptors
-
RequestPartFieldsSnippet
protected RequestPartFieldsSnippet(String partName, @Nullable PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, boolean ignoreUndocumentedFields) Creates a newRequestPartFieldsSnippet
that will document the fields in a subsection the request part using the givendescriptors
. The subsection will be extracted using the givensubsectionExtractor
. If the extractor isnull
the fields of the entire request part will be documented. IfignoreUndocumentedFields
istrue
, undocumented fields will be ignored and will not trigger a failure.- Parameters:
partName
- the part namesubsectionExtractor
- the subsection extractor, ornull
to document the fields of the entire request partdescriptors
- the descriptorsignoreUndocumentedFields
- whether undocumented fields should be ignored
-
RequestPartFieldsSnippet
protected RequestPartFieldsSnippet(String partName, @Nullable PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, @Nullable Map<String, Object> attributes) Creates a newRequestPartFieldsSnippet
that will document the fields in a subsection of the request part using the givendescriptors
. The subsection will be extracted using the givensubsectionExtractor
. If the extractor isnull
the fields of the entire request part will be documented. The givenattributes
will be included in the model during template rendering. Undocumented fields will trigger a failure.- Parameters:
partName
- the part namesubsectionExtractor
- the subsection extractor, ornull
to document the fields of the entire request partdescriptors
- the descriptorsattributes
- the additional attributes
-
RequestPartFieldsSnippet
protected RequestPartFieldsSnippet(String partName, @Nullable PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, @Nullable Map<String, Object> attributes, boolean ignoreUndocumentedFields) Creates a newRequestPartFieldsSnippet
that will document the fields in a subsection of the request part using the givendescriptors
. The subsection will be extracted using the givensubsectionExtractor
. If the extractor isnull
the fields of the entire request part will be documented. 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:
partName
- the part namesubsectionExtractor
- the subsection extractor, ornull
to document the fields of the entire request partdescriptors
- the descriptorsattributes
- the additional attributesignoreUndocumentedFields
- whether undocumented fields should be ignored
-
-
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 newRequestPartFieldsSnippet
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 newRequestPartFieldsSnippet
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 RequestPartFieldsSnippet 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 RequestPartFieldsSnippet 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
-