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
ModifierConstructorDescriptionprotected
Creates a newTemplatedSnippet
that will produce a snippet with the givensnippetName
using a template with the giventemplateName
.protected
TemplatedSnippet
(String snippetName, Map<String, Object> attributes) Creates a newTemplatedSnippet
that 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
.void
Documents 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 String
Returns the name of the snippet that will be created.
-
Constructor Details
-
TemplatedSnippet
Creates a newTemplatedSnippet
that will produce a snippet with the givensnippetName
. ThesnippetName
will also be used as the name of the template. The givenattributes
will 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 newTemplatedSnippet
that will produce a snippet with the givensnippetName
using a template with the giventemplateName
. The givenattributes
will 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:Snippet
Documents the call to the RESTful API described by the givenoperation
.- Specified by:
document
in 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 thisTemplatedSnippet
were 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
-