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
ConstructorsModifierConstructorDescriptionprotectedRequestPartFieldsSnippet(String partName, List<FieldDescriptor> descriptors) Creates a newRequestPartFieldsSnippetthat will document the fields in the request part using the givendescriptors.protectedRequestPartFieldsSnippet(String partName, List<FieldDescriptor> descriptors, boolean ignoreUndocumentedFields) Creates a newRequestPartFieldsSnippetthat will document the fields in the request part using the givendescriptors.protectedRequestPartFieldsSnippet(String partName, List<FieldDescriptor> descriptors, Map<String, Object> attributes) Creates a newRequestFieldsSnippetthat will document the fields in the request using the givendescriptors.protectedRequestPartFieldsSnippet(String partName, List<FieldDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedFields) Creates a newRequestFieldsSnippetthat will document the fields in the request using the givendescriptors.protectedRequestPartFieldsSnippet(String partName, PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors) Creates a newRequestPartFieldsSnippetthat will document the fields in a subsection of the request part using the givendescriptors.protectedRequestPartFieldsSnippet(String partName, PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, boolean ignoreUndocumentedFields) Creates a newRequestPartFieldsSnippetthat will document the fields in a subsection the request part using the givendescriptors.protectedRequestPartFieldsSnippet(String partName, PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, Map<String, Object> attributes) Creates a newRequestPartFieldsSnippetthat will document the fields in a subsection of the request part using the givendescriptors.protectedRequestPartFieldsSnippet(String partName, PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedFields) Creates a newRequestPartFieldsSnippetthat will document the fields in a subsection of the request part using the givendescriptors. -
Method Summary
Modifier and TypeMethodDescriptionfinal RequestPartFieldsSnippetand(List<FieldDescriptor> additionalDescriptors) Returns a newRequestPartFieldsSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.final RequestPartFieldsSnippetand(FieldDescriptor... additionalDescriptors) Returns a newRequestPartFieldsSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.final RequestPartFieldsSnippetandWithPrefix(String pathPrefix, List<FieldDescriptor> additionalDescriptors) Returns a newRequestFieldsSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.final RequestPartFieldsSnippetandWithPrefix(String pathPrefix, FieldDescriptor... additionalDescriptors) Returns a newRequestFieldsSnippetconfigured 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.MediaTypegetContentType(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, isIgnoredUndocumentedFieldsMethods inherited from class org.springframework.restdocs.snippet.TemplatedSnippet
document, getAttributes, getSnippetName
-
Constructor Details
-
RequestPartFieldsSnippet
Creates a newRequestPartFieldsSnippetthat 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 newRequestPartFieldsSnippetthat will document the fields in the request part using the givendescriptors. IfignoreUndocumentedFieldsistrue, 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, Map<String, Object> attributes) Creates a newRequestFieldsSnippetthat will document the fields in the request using the givendescriptors. The givenattributeswill 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, Map<String, Object> attributes, boolean ignoreUndocumentedFields) Creates a newRequestFieldsSnippetthat will document the fields in the request using the givendescriptors. The givenattributeswill be included in the model during template rendering. IfignoreUndocumentedFieldsistrue, 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, PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors) Creates a newRequestPartFieldsSnippetthat will document the fields in a subsection of the request part using the givendescriptors. The subsection will be extracted using the givensubsectionExtractor. Undocumented fields will trigger a failure.- Parameters:
partName- the part namesubsectionExtractor- the subsection extractordescriptors- the descriptors
-
RequestPartFieldsSnippet
protected RequestPartFieldsSnippet(String partName, PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, boolean ignoreUndocumentedFields) Creates a newRequestPartFieldsSnippetthat will document the fields in a subsection the request part using the givendescriptors. The subsection will be extracted using the givensubsectionExtractor. IfignoreUndocumentedFieldsistrue, undocumented fields will be ignored and will not trigger a failure.- Parameters:
partName- the part namesubsectionExtractor- the subsection extractordescriptors- the descriptorsignoreUndocumentedFields- whether undocumented fields should be ignored
-
RequestPartFieldsSnippet
protected RequestPartFieldsSnippet(String partName, PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, Map<String, Object> attributes) Creates a newRequestPartFieldsSnippetthat will document the fields in a subsection of the request part using the givendescriptors. The subsection will be extracted using the givensubsectionExtractor. The givenattributeswill be included in the model during template rendering. Undocumented fields will trigger a failure.- Parameters:
partName- the part namesubsectionExtractor- the subsection extractordescriptors- the descriptorsattributes- the additional attributes
-
RequestPartFieldsSnippet
protected RequestPartFieldsSnippet(String partName, PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedFields) Creates a newRequestPartFieldsSnippetthat will document the fields in a subsection of the request part using the givendescriptors. The subsection will be extracted using the givensubsectionExtractor. The givenattributeswill be included in the model during template rendering. IfignoreUndocumentedFieldsistrue, undocumented fields will be ignored and will not trigger a failure.- Parameters:
partName- the part namesubsectionExtractor- the subsection extractordescriptors- the descriptorsattributes- the additional attributesignoreUndocumentedFields- whether undocumented fields should be ignored
-
-
Method Details
-
getContentType
Description copied from class:AbstractFieldsSnippetReturns the content type of the request or response extracted from the givenoperation.- Specified by:
getContentTypein classAbstractFieldsSnippet- Parameters:
operation- the operation- Returns:
- the content type
-
getContent
Description copied from class:AbstractFieldsSnippetReturns the content of the request or response extracted form the givenoperation.- Specified by:
getContentin classAbstractFieldsSnippet- Parameters:
operation- the operation- Returns:
- the content
- Throws:
IOException- if the content cannot be extracted
-
and
Returns a newRequestPartFieldsSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.- Parameters:
additionalDescriptors- the additional descriptors- Returns:
- the new snippet
-
and
Returns a newRequestPartFieldsSnippetconfigured 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 newRequestFieldsSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors. The givenpathPrefixis 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 newRequestFieldsSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors. The givenpathPrefixis 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
-