Class ResponseBodySnippet
java.lang.Object
org.springframework.restdocs.snippet.TemplatedSnippet
org.springframework.restdocs.payload.AbstractBodySnippet
org.springframework.restdocs.payload.ResponseBodySnippet
- All Implemented Interfaces:
Snippet
A
Snippet
that documents the body of a response.- Author:
- Andy Wilkinson
-
Constructor Summary
ConstructorDescriptionCreates a newResponseBodySnippet
.ResponseBodySnippet
(Map<String, Object> attributes) Creates a newResponseBodySnippet
with the given additionalattributes
that will be included in the model during template rendering.ResponseBodySnippet
(PayloadSubsectionExtractor<?> subsectionExtractor) Creates a newResponseBodySnippet
that will document the subsection of the response body extracted by the givensubsectionExtractor
.ResponseBodySnippet
(PayloadSubsectionExtractor<?> subsectionExtractor, Map<String, Object> attributes) Creates a newResponseBodySnippet
that will document the subsection of the response body 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 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
-
ResponseBodySnippet
public ResponseBodySnippet()Creates a newResponseBodySnippet
. -
ResponseBodySnippet
Creates a newResponseBodySnippet
that will document the subsection of the response body extracted by the givensubsectionExtractor
.- Parameters:
subsectionExtractor
- the subsection extractor
-
ResponseBodySnippet
Creates a newResponseBodySnippet
with the given additionalattributes
that will be included in the model during template rendering.- Parameters:
attributes
- the additional attributes
-
ResponseBodySnippet
public ResponseBodySnippet(PayloadSubsectionExtractor<?> subsectionExtractor, Map<String, Object> attributes) Creates a newResponseBodySnippet
that will document the subsection of the response body extracted by the givensubsectionExtractor
. The given additionalattributes
that will be included in the model during template rendering.- Parameters:
subsectionExtractor
- the subsection extractorattributes
- 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
-