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 newRequestPartBodySnippetthat will document the body of the request part with the givenpartName.RequestPartBodySnippet(String partName, Map<String, Object> attributes) Creates a newRequestPartBodySnippetthat will document the body of the request part with the givenpartName.RequestPartBodySnippet(String partName, PayloadSubsectionExtractor<?> subsectionExtractor) Creates a newRequestPartBodySnippetthat will document the subsection of the body of the request part with the givenpartNameextracted by the givensubsectionExtractor.RequestPartBodySnippet(String partName, PayloadSubsectionExtractor<?> subsectionExtractor, Map<String, Object> attributes) Creates a newRequestPartBodySnippetthat will document the body of the request part with the givenpartName. -
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.MediaTypegetContentType(Operation operation) Returns the content type of the request or response extracted from the givenoperation.Methods inherited from class org.springframework.restdocs.payload.AbstractBodySnippet
createModelMethods inherited from class org.springframework.restdocs.snippet.TemplatedSnippet
document, getAttributes, getSnippetName
-
Constructor Details
-
RequestPartBodySnippet
Creates a newRequestPartBodySnippetthat will document the body of the request part with the givenpartName.- Parameters:
partName- the name of the request part
-
RequestPartBodySnippet
Creates a newRequestPartBodySnippetthat will document the subsection of the body of the request part with the givenpartNameextracted by the givensubsectionExtractor.- Parameters:
partName- the name of the request partsubsectionExtractor- the subsection extractor
-
RequestPartBodySnippet
Creates a newRequestPartBodySnippetthat will document the body of the request part with the givenpartName. The given additionalattributeswill be included in the model during template rendering.- Parameters:
partName- the name of the request partattributes- the additional attributes
-
RequestPartBodySnippet
public RequestPartBodySnippet(String partName, PayloadSubsectionExtractor<?> subsectionExtractor, Map<String, Object> attributes) Creates a newRequestPartBodySnippetthat will document the body of the request part with the givenpartName. The subsection of the body extracted by the givensubsectionExtractorwill be documented and the given additionalattributesthat will be included in the model during template rendering.- Parameters:
partName- the name of the request partsubsectionExtractor- the subsection extractorattributes- the additional attributes
-
-
Method Details
-
getContent
Description copied from class:AbstractBodySnippetReturns the content of the request or response extracted from the givenoperation.- Specified by:
getContentin classAbstractBodySnippet- Parameters:
operation- the operation- Returns:
- the content
- Throws:
IOException- if the content cannot be extracted
-
getContentType
Description copied from class:AbstractBodySnippetReturns the content type of the request or response extracted from the givenoperation.- Specified by:
getContentTypein classAbstractBodySnippet- Parameters:
operation- the operation- Returns:
- the content type
-