Class QueryParametersSnippet
java.lang.Object
org.springframework.restdocs.snippet.TemplatedSnippet
org.springframework.restdocs.request.AbstractParametersSnippet
org.springframework.restdocs.request.QueryParametersSnippet
- All Implemented Interfaces:
Snippet
A
Snippet that documents the query parameters supported by a RESTful resource.- Since:
- 3.0.0
- Author:
- Andy Wilkinson
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedQueryParametersSnippet(List<ParameterDescriptor> descriptors) Creates a newQueryParametersSnippetthat will document the request's query parameters using the givendescriptors.protectedQueryParametersSnippet(List<ParameterDescriptor> descriptors, boolean ignoreUndocumentedParameters) Creates a newQueryParametersSnippetthat will document the request's query parameters using the givendescriptors.protectedQueryParametersSnippet(List<ParameterDescriptor> descriptors, @Nullable Map<String, Object> attributes) Creates a newQueryParametersSnippetthat will document the request's query parameters using the givendescriptors.protectedQueryParametersSnippet(List<ParameterDescriptor> descriptors, @Nullable Map<String, Object> attributes, boolean ignoreUndocumentedParameters) Creates a newQueryParametersSnippetthat will document the request's query parameters using the givendescriptors. -
Method Summary
Modifier and TypeMethodDescriptionand(List<ParameterDescriptor> additionalDescriptors) Returns a newQueryParametersSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.and(ParameterDescriptor... additionalDescriptors) Returns a newQueryParametersSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.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 AbstractParametersSnippet
createModel, createModelForDescriptor, getParameterDescriptors, isIgnoreUndocumentedParametersMethods inherited from class TemplatedSnippet
document, getAttributes, getSnippetName
-
Constructor Details
-
QueryParametersSnippet
Creates a newQueryParametersSnippetthat will document the request's query parameters using the givendescriptors. Undocumented parameters will trigger a failure.- Parameters:
descriptors- the parameter descriptors
-
QueryParametersSnippet
protected QueryParametersSnippet(List<ParameterDescriptor> descriptors, boolean ignoreUndocumentedParameters) Creates a newQueryParametersSnippetthat will document the request's query 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
-
QueryParametersSnippet
protected QueryParametersSnippet(List<ParameterDescriptor> descriptors, @Nullable Map<String, Object> attributes) Creates a newQueryParametersSnippetthat will document the request's query 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
-
QueryParametersSnippet
protected QueryParametersSnippet(List<ParameterDescriptor> descriptors, @Nullable Map<String, Object> attributes, boolean ignoreUndocumentedParameters) Creates a newQueryParametersSnippetthat will document the request's query 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
-
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
-
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
-
and
Returns a newQueryParametersSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.- Parameters:
additionalDescriptors- the additional descriptors- Returns:
- the new snippet
-
and
Returns a newQueryParametersSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.- Parameters:
additionalDescriptors- the additional descriptors- Returns:
- the new snippet
-