Class TemplatedSnippet
java.lang.Object
org.springframework.restdocs.snippet.TemplatedSnippet
- All Implemented Interfaces:
Snippet
- Direct Known Subclasses:
AbstractBodySnippet,AbstractCookiesSnippet,AbstractFieldsSnippet,AbstractHeadersSnippet,AbstractParametersSnippet,CurlRequestSnippet,HttpieRequestSnippet,HttpRequestSnippet,HttpResponseSnippet,LinksSnippet,RequestPartsSnippet
- Author:
- Andy Wilkinson
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a newTemplatedSnippetthat will produce a snippet with the givensnippetNameusing a template with the giventemplateName.protectedTemplatedSnippet(String snippetName, Map<String, Object> attributes) Creates a newTemplatedSnippetthat will produce a snippet with the givensnippetName. -
Method Summary
Modifier and TypeMethodDescriptioncreateModel(Operation operation) Create the model that should be used during template rendering to document the givenoperation.voidDocuments the call to the RESTful API described by the givenoperation.Returns the additional attributes that will be included in the model during template rendering.protected final StringReturns the name of the snippet that will be created.
-
Constructor Details
-
TemplatedSnippet
Creates a newTemplatedSnippetthat will produce a snippet with the givensnippetName. ThesnippetNamewill also be used as the name of the template. The givenattributeswill be included in the model during rendering of the template.- Parameters:
snippetName- the name of the snippetattributes- the additional attributes- See Also:
-
TemplatedSnippet
Creates a newTemplatedSnippetthat will produce a snippet with the givensnippetNameusing a template with the giventemplateName. The givenattributeswill be included in the model during rendering of the template.- Parameters:
snippetName- the name of the snippettemplateName- the name of the templateattributes- the additional attributes
-
-
Method Details
-
document
Description copied from interface:SnippetDocuments the call to the RESTful API described by the givenoperation.- Specified by:
documentin interfaceSnippet- Parameters:
operation- the API operation- Throws:
IOException- if a failure occurs will documenting the operation
-
createModel
Create the model that should be used during template rendering to document the givenoperation. Any additional attributes that were supplied when thisTemplatedSnippetwere created will be automatically added to the model prior to rendering.- Parameters:
operation- the operation- Returns:
- the model
- Throws:
ModelCreationException- if model creation fails
-
getAttributes
Returns the additional attributes that will be included in the model during template rendering.- Returns:
- the additional attributes
-
getSnippetName
Returns the name of the snippet that will be created.- Returns:
- the snippet name
-