Class ApiVersionConfigurer
- Since:
- 7.0
- Author:
- Rossen Stoyanchev
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionaddSupportedVersions(String... versions) Add to the list of supported versions to check against before raisingInvalidApiVersionExceptionfor unknown versions.detectSupportedVersions(boolean detect) Whether to use versions from mappings for supported version validation.protected @Nullable ApiVersionStrategysetDefaultVersion(@Nullable String defaultVersion) Configure a default version to assign to requests that don't specify one.setVersionParser(@Nullable ApiVersionParser<?> versionParser) Configure a parser to parse API versions with.setVersionRequired(boolean required) Whether requests are required to have an API version.usePathSegment(int index) Add a resolver that extracts the API version from a path segment.useRequestHeader(String headerName) Add a resolver that extracts the API version from a request header.useRequestParam(String paramName) Add a resolver that extracts the API version from a request parameter.useVersionResolver(ApiVersionResolver... resolvers) Add custom resolvers to resolve the API version.
- 
Constructor Details- 
ApiVersionConfigurerpublic ApiVersionConfigurer()
 
- 
- 
Method Details- 
useRequestHeaderAdd a resolver that extracts the API version from a request header.- Parameters:
- headerName- the header name to check
 
- 
useRequestParamAdd a resolver that extracts the API version from a request parameter.- Parameters:
- paramName- the parameter name to check
 
- 
usePathSegmentAdd a resolver that extracts the API version from a path segment.- Parameters:
- index- the index of the path segment to check; e.g. for URL's like "/{version}/..." use index 0, for "/api/{version}/..." index 1.
 
- 
useVersionResolverAdd custom resolvers to resolve the API version.- Parameters:
- resolvers- the resolvers to use
 
- 
setVersionParserConfigure a parser to parse API versions with.By default, SemanticApiVersionParseris used.- Parameters:
- versionParser- the parser to user
 
- 
setVersionRequiredWhether requests are required to have an API version. When set totrue,MissingApiVersionExceptionis raised, resulting in a 400 response if the request doesn't have an API version. When set to false, a request without a version is considered to accept any version.By default, this is set to truewhen API versioning is enabled by adding at least oneApiVersionResolver). When adefaultVersionis also set, this is automatically set tofalse.- Parameters:
- required- whether an API version is required.
 
- 
setDefaultVersionConfigure a default version to assign to requests that don't specify one.- Parameters:
- defaultVersion- the default version to use
 
- 
addSupportedVersionsAdd to the list of supported versions to check against before raisingInvalidApiVersionExceptionfor unknown versions.By default, actual version values that appear in request mappings are used for validation. Therefore, use of this method is optional. However, if you prefer to use explicitly configured, supported versions only, then set detectSupportedVersionstofalse.Note that the initial API version, if not explicitly declared in any request mappings, may need to be declared here instead as a supported version. - Parameters:
- versions- supported version values to add
 
- 
detectSupportedVersionsWhether to use versions from mappings for supported version validation.By default, this is truein which case mapped versions are considered supported versions. Set this tofalseif you want to use only explicitly configuredsupported versions.- Parameters:
- detect- whether to use detected versions for validation
 
- 
getApiVersionStrategy
 
-