Class RequestPartBodySnippet
java.lang.Object
org.springframework.restdocs.snippet.TemplatedSnippet
org.springframework.restdocs.payload.AbstractBodySnippet
org.springframework.restdocs.payload.RequestPartBodySnippet
- All Implemented Interfaces:
Snippet
A
Snippet
that documents the body of a request part.- Author:
- Andy Wilkinson
-
Constructor Summary
ConstructorsConstructorDescriptionRequestPartBodySnippet
(String partName) Creates a newRequestPartBodySnippet
that will document the body of the request part with the givenpartName
.RequestPartBodySnippet
(String partName, @Nullable Map<String, Object> attributes) Creates a newRequestPartBodySnippet
that will document the body of the request part with the givenpartName
.RequestPartBodySnippet
(String partName, @Nullable PayloadSubsectionExtractor<?> subsectionExtractor) Creates a newRequestPartBodySnippet
that will document the subsection of the body of the request part with the givenpartName
extracted by the givensubsectionExtractor
.RequestPartBodySnippet
(String partName, @Nullable PayloadSubsectionExtractor<?> subsectionExtractor, @Nullable Map<String, Object> attributes) Creates a newRequestPartBodySnippet
that will document the subsection of the body of the request part with the givenpartName
extracted by the givensubsectionExtractor
. -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]
getContent
(Operation operation) Returns the content of the request or response extracted from 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.AbstractBodySnippet
createModel
Methods inherited from class org.springframework.restdocs.snippet.TemplatedSnippet
document, getAttributes, getSnippetName
-
Constructor Details
-
RequestPartBodySnippet
Creates a newRequestPartBodySnippet
that will document the body of the request part with the givenpartName
.- Parameters:
partName
- the name of the request part
-
RequestPartBodySnippet
public RequestPartBodySnippet(String partName, @Nullable PayloadSubsectionExtractor<?> subsectionExtractor) Creates a newRequestPartBodySnippet
that will document the subsection of the body of the request part with the givenpartName
extracted by the givensubsectionExtractor
. If the extractor isnull
the entire body of the request part will be documented.- Parameters:
partName
- the name of the request partsubsectionExtractor
- the subsection extractor ornull
to document the request part's entire body
-
RequestPartBodySnippet
Creates a newRequestPartBodySnippet
that will document the body of the request part with the givenpartName
. If the extractor isnull
the entire body of the request part will be documented. The given additionalattributes
will be included in the model during template rendering.- Parameters:
partName
- the name of the request partattributes
- the additional attributes
-
RequestPartBodySnippet
public RequestPartBodySnippet(String partName, @Nullable PayloadSubsectionExtractor<?> subsectionExtractor, @Nullable Map<String, Object> attributes) Creates a newRequestPartBodySnippet
that will document the subsection of the body of the request part with the givenpartName
extracted by the givensubsectionExtractor
. If the extractor isnull
the entire body of the request part will be documented. The given additionalattributes
will be included in the model during template rendering.- Parameters:
partName
- the name of the request partsubsectionExtractor
- the subsection extractor ornull
to document the request part's entire bodyattributes
- the additional attributes
-
-
Method Details
-
getContent
Description copied from class:AbstractBodySnippet
Returns the content of the request or response extracted from the givenoperation
.- Specified by:
getContent
in classAbstractBodySnippet
- Parameters:
operation
- the operation- Returns:
- the content
- Throws:
IOException
- if the content cannot be extracted
-
getContentType
Description copied from class:AbstractBodySnippet
Returns the content type of the request or response extracted from the givenoperation
.- Specified by:
getContentType
in classAbstractBodySnippet
- Parameters:
operation
- the operation- Returns:
- the content type
-