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
FieldsModifier and TypeFieldDescriptionstatic final StringName of the operation attribute used to hold the default operation request preprocessor.static final StringName of the operation attribute used to hold the default operation response preprocessor.static final StringName of the operation attribute used to hold theListof default snippets.static final StringName of the operation attribute used to hold the request's URL template. -
Constructor Summary
ConstructorsConstructorDescriptionRestDocumentationGenerator(String identifier, RequestConverter<REQ> requestConverter, ResponseConverter<RESP> responseConverter, OperationRequestPreprocessor requestPreprocessor, OperationResponsePreprocessor responsePreprocessor, Snippet... snippets) Creates a newRestDocumentationGeneratorfor the operation identified by the givenidentifier.RestDocumentationGenerator(String identifier, RequestConverter<REQ> requestConverter, ResponseConverter<RESP> responseConverter, OperationRequestPreprocessor requestPreprocessor, Snippet... snippets) Creates a newRestDocumentationGeneratorfor the operation identified by the givenidentifier.RestDocumentationGenerator(String identifier, RequestConverter<REQ> requestConverter, ResponseConverter<RESP> responseConverter, OperationResponsePreprocessor responsePreprocessor, Snippet... snippets) Creates a newRestDocumentationGeneratorfor the operation identified by the givenidentifier.RestDocumentationGenerator(String identifier, RequestConverter<REQ> requestConverter, ResponseConverter<RESP> responseConverter, Snippet... snippets) Creates a newRestDocumentationGeneratorfor the operation identified by the givenidentifier. -
Method Summary
Modifier and TypeMethodDescriptionvoidHandles the givenrequestandresponse, producing documentation snippets for them using the givenconfiguration.withSnippets(Snippet... snippets) Creates a newRestDocumentationGeneratorwith 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 theListof 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 newRestDocumentationGeneratorfor the operation identified by the givenidentifier. The givenrequestConverterandresponseConverterare used to convert the operation's request and response into genericOperationRequestandOperationResponseinstances that can then be documented. The given documentationsnippetswill 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 newRestDocumentationGeneratorfor the operation identified by the givenidentifier. The givenrequestConverterandresponseConverterare used to convert the operation's request and response into genericOperationRequestandOperationResponseinstances that can then be documented. The givenrequestPreprocessoris applied to the request before it is documented. The given documentationsnippetswill 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 newRestDocumentationGeneratorfor the operation identified by the givenidentifier. The givenrequestConverterandresponseConverterare used to convert the operation's request and response into genericOperationRequestandOperationResponseinstances that can then be documented. The givenresponsePreprocessoris applied to the response before it is documented. The given documentationsnippetswill 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 newRestDocumentationGeneratorfor the operation identified by the givenidentifier. The givenrequestConverterandresponseConverterare used to convert the operation's request and response into genericOperationRequestandOperationResponseinstances that can then be documented. The givenrequestPreprocessorandresponsePreprocessorare applied to the request and response before they are documented. The given documentationsnippetswill 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 givenrequestandresponse, 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 newRestDocumentationGeneratorwith 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
-