Class RestDocumentationGenerator<REQ,RESP>
java.lang.Object
org.springframework.restdocs.generate.RestDocumentationGenerator<REQ,RESP>
- Type Parameters:
REQ
- the request type that can be handledRESP
- the response type that can be handled
A
RestDocumentationGenerator
is used to generate documentation snippets from
the request and response of an operation performed on a service.- Since:
- 1.1.0
- Author:
- Andy Wilkinson, Filip Hrisafov
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Name of the operation attribute used to hold the default operation request preprocessor.static final String
Name of the operation attribute used to hold the default operation response preprocessor.static final String
Name of the operation attribute used to hold theList
of default snippets.static final String
Name of the operation attribute used to hold the request's URL template. -
Constructor Summary
ConstructorDescriptionRestDocumentationGenerator
(String identifier, RequestConverter<REQ> requestConverter, ResponseConverter<RESP> responseConverter, OperationRequestPreprocessor requestPreprocessor, OperationResponsePreprocessor responsePreprocessor, Snippet... snippets) Creates a newRestDocumentationGenerator
for the operation identified by the givenidentifier
.RestDocumentationGenerator
(String identifier, RequestConverter<REQ> requestConverter, ResponseConverter<RESP> responseConverter, OperationRequestPreprocessor requestPreprocessor, Snippet... snippets) Creates a newRestDocumentationGenerator
for the operation identified by the givenidentifier
.RestDocumentationGenerator
(String identifier, RequestConverter<REQ> requestConverter, ResponseConverter<RESP> responseConverter, OperationResponsePreprocessor responsePreprocessor, Snippet... snippets) Creates a newRestDocumentationGenerator
for the operation identified by the givenidentifier
.RestDocumentationGenerator
(String identifier, RequestConverter<REQ> requestConverter, ResponseConverter<RESP> responseConverter, Snippet... snippets) Creates a newRestDocumentationGenerator
for the operation identified by the givenidentifier
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Handles the givenrequest
andresponse
, producing documentation snippets for them using the givenconfiguration
.withSnippets
(Snippet... snippets) Creates a newRestDocumentationGenerator
with the same configuration as this one other than its snippets.
-
Field Details
-
ATTRIBUTE_NAME_URL_TEMPLATE
Name of the operation attribute used to hold the request's URL template.- See Also:
-
ATTRIBUTE_NAME_DEFAULT_SNIPPETS
Name of the operation attribute used to hold theList
of default snippets.- See Also:
-
ATTRIBUTE_NAME_DEFAULT_OPERATION_REQUEST_PREPROCESSOR
Name of the operation attribute used to hold the default operation request preprocessor.- See Also:
-
ATTRIBUTE_NAME_DEFAULT_OPERATION_RESPONSE_PREPROCESSOR
Name of the operation attribute used to hold the default operation response preprocessor.- See Also:
-
-
Constructor Details
-
RestDocumentationGenerator
public RestDocumentationGenerator(String identifier, RequestConverter<REQ> requestConverter, ResponseConverter<RESP> responseConverter, Snippet... snippets) Creates a newRestDocumentationGenerator
for the operation identified by the givenidentifier
. The givenrequestConverter
andresponseConverter
are used to convert the operation's request and response into genericOperationRequest
andOperationResponse
instances that can then be documented. The given documentationsnippets
will be produced.- Parameters:
identifier
- the identifier for the operationrequestConverter
- the request converterresponseConverter
- the response convertersnippets
- the snippets
-
RestDocumentationGenerator
public RestDocumentationGenerator(String identifier, RequestConverter<REQ> requestConverter, ResponseConverter<RESP> responseConverter, OperationRequestPreprocessor requestPreprocessor, Snippet... snippets) Creates a newRestDocumentationGenerator
for the operation identified by the givenidentifier
. The givenrequestConverter
andresponseConverter
are used to convert the operation's request and response into genericOperationRequest
andOperationResponse
instances that can then be documented. The givenrequestPreprocessor
is applied to the request before it is documented. The given documentationsnippets
will be produced.- Parameters:
identifier
- the identifier for the operationrequestConverter
- the request converterresponseConverter
- the response converterrequestPreprocessor
- the request preprocessorsnippets
- the snippets
-
RestDocumentationGenerator
public RestDocumentationGenerator(String identifier, RequestConverter<REQ> requestConverter, ResponseConverter<RESP> responseConverter, OperationResponsePreprocessor responsePreprocessor, Snippet... snippets) Creates a newRestDocumentationGenerator
for the operation identified by the givenidentifier
. The givenrequestConverter
andresponseConverter
are used to convert the operation's request and response into genericOperationRequest
andOperationResponse
instances that can then be documented. The givenresponsePreprocessor
is applied to the response before it is documented. The given documentationsnippets
will be produced.- Parameters:
identifier
- the identifier for the operationrequestConverter
- the request converterresponseConverter
- the response converterresponsePreprocessor
- the response preprocessorsnippets
- the snippets
-
RestDocumentationGenerator
public RestDocumentationGenerator(String identifier, RequestConverter<REQ> requestConverter, ResponseConverter<RESP> responseConverter, OperationRequestPreprocessor requestPreprocessor, OperationResponsePreprocessor responsePreprocessor, Snippet... snippets) Creates a newRestDocumentationGenerator
for the operation identified by the givenidentifier
. The givenrequestConverter
andresponseConverter
are used to convert the operation's request and response into genericOperationRequest
andOperationResponse
instances that can then be documented. The givenrequestPreprocessor
andresponsePreprocessor
are applied to the request and response before they are documented. The given documentationsnippets
will be produced.- Parameters:
identifier
- the identifier for the operationrequestConverter
- the request converterresponseConverter
- the response converterrequestPreprocessor
- the request preprocessorresponsePreprocessor
- the response preprocessorsnippets
- the snippets
-
-
Method Details
-
handle
Handles the givenrequest
andresponse
, producing documentation snippets for them using the givenconfiguration
.- Parameters:
request
- the requestresponse
- the requestconfiguration
- the configuration- Throws:
RestDocumentationGenerationException
- if a failure occurs during handling
-
withSnippets
Creates a newRestDocumentationGenerator
with the same configuration as this one other than its snippets. The new generator will use the givensnippets
.- Parameters:
snippets
- the snippets- Returns:
- the new generator
-