Class PathParametersSnippet
java.lang.Object
org.springframework.restdocs.snippet.TemplatedSnippet
org.springframework.restdocs.request.AbstractParametersSnippet
org.springframework.restdocs.request.PathParametersSnippet
- All Implemented Interfaces:
Snippet
A
Snippet that documents the path parameters supported by a RESTful resource.- Author:
- Andy Wilkinson
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPathParametersSnippet(List<ParameterDescriptor> descriptors) Creates a newPathParametersSnippetthat will document the request's path parameters using the givendescriptors.protectedPathParametersSnippet(List<ParameterDescriptor> descriptors, boolean ignoreUndocumentedParameters) Creates a newPathParametersSnippetthat will document the request's path parameters using the givendescriptors.protectedPathParametersSnippet(List<ParameterDescriptor> descriptors, Map<String, Object> attributes) Creates a newPathParametersSnippetthat will document the request's path parameters using the givendescriptors.protectedPathParametersSnippet(List<ParameterDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedParameters) Creates a newPathParametersSnippetthat will document the request's path parameters using the givendescriptors. -
Method Summary
Modifier and TypeMethodDescriptionfinal PathParametersSnippetand(List<ParameterDescriptor> additionalDescriptors) Returns a newPathParametersSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.final PathParametersSnippetand(ParameterDescriptor... additionalDescriptors) Returns a newPathParametersSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.createModel(Operation operation) Create the model that should be used during template rendering to document the givenoperation.extractActualParameters(Operation operation) Extracts the names of the parameters that were present in the givenoperation.protected voidverificationFailed(Set<String> undocumentedParameters, Set<String> missingParameters) Called when the documented parameters do not match the actual parameters.Methods inherited from class org.springframework.restdocs.request.AbstractParametersSnippet
createModelForDescriptor, getParameterDescriptors, isIgnoreUndocumentedParametersMethods inherited from class org.springframework.restdocs.snippet.TemplatedSnippet
document, getAttributes, getSnippetName
-
Constructor Details
-
PathParametersSnippet
Creates a newPathParametersSnippetthat will document the request's path parameters using the givendescriptors. Undocumented parameters will trigger a failure.- Parameters:
descriptors- the parameter descriptors
-
PathParametersSnippet
protected PathParametersSnippet(List<ParameterDescriptor> descriptors, boolean ignoreUndocumentedParameters) Creates a newPathParametersSnippetthat will document the request's path parameters using the givendescriptors. IfignoreUndocumentedParametersistrue, undocumented parameters will be ignored and will not trigger a failure.- Parameters:
descriptors- the parameter descriptorsignoreUndocumentedParameters- whether undocumented parameters should be ignored
-
PathParametersSnippet
protected PathParametersSnippet(List<ParameterDescriptor> descriptors, Map<String, Object> attributes) Creates a newPathParametersSnippetthat will document the request's path parameters using the givendescriptors. The givenattributeswill be included in the model during template rendering. Undocumented parameters will trigger a failure.- Parameters:
descriptors- the parameter descriptorsattributes- the additional attributes
-
PathParametersSnippet
protected PathParametersSnippet(List<ParameterDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedParameters) Creates a newPathParametersSnippetthat will document the request's path parameters using the givendescriptors. The givenattributeswill be included in the model during template rendering. IfignoreUndocumentedParametersistrue, undocumented parameters will be ignored and will not trigger a failure.- Parameters:
descriptors- the parameter descriptorsattributes- the additional attributesignoreUndocumentedParameters- whether undocumented parameters should be ignored
-
-
Method Details
-
createModel
Description copied from class:TemplatedSnippetCreate 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.- Overrides:
createModelin classAbstractParametersSnippet- Parameters:
operation- the operation- Returns:
- the model
-
extractActualParameters
Description copied from class:AbstractParametersSnippetExtracts the names of the parameters that were present in the givenoperation.- Specified by:
extractActualParametersin classAbstractParametersSnippet- Parameters:
operation- the operation- Returns:
- the parameters
-
verificationFailed
protected void verificationFailed(Set<String> undocumentedParameters, Set<String> missingParameters) Description copied from class:AbstractParametersSnippetCalled when the documented parameters do not match the actual parameters.- Specified by:
verificationFailedin classAbstractParametersSnippet- Parameters:
undocumentedParameters- the parameters that were found in the operation but were not documentedmissingParameters- the parameters that were documented but were not found in the operation
-
and
Returns a newPathParametersSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.- Parameters:
additionalDescriptors- the additional descriptors- Returns:
- the new snippet
-
and
Returns a newPathParametersSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.- Parameters:
additionalDescriptors- the additional descriptors- Returns:
- the new snippet
-