|
|
|
|
@ -9,13 +9,14 @@ and underlying strategies.
@@ -9,13 +9,14 @@ and underlying strategies.
|
|
|
|
|
|
|
|
|
|
Please, see also related content in: |
|
|
|
|
|
|
|
|
|
- Use xref:web/webflux/controller/ann-requestmapping.adoc#webflux-ann-requestmapping-version[API Versions] |
|
|
|
|
to map requests to annotated controller methods |
|
|
|
|
- Configure API versioning in xref:web/webflux/config.adoc#webflux-config-api-version[WebFlux Config] |
|
|
|
|
- Configure xref:web/webflux/config.adoc#webflux-config-api-version[API versioning] |
|
|
|
|
in the WebFlux Config |
|
|
|
|
- xref:web/webflux/controller/ann-requestmapping.adoc#webflux-ann-requestmapping-version[Map requests] |
|
|
|
|
to annotated controller methods with an API version |
|
|
|
|
|
|
|
|
|
TIP: API versioning is also supported on the client side in `RestClient`, `WebClient`, and |
|
|
|
|
Client support for API versioning is available also in `RestClient`, `WebClient`, and |
|
|
|
|
xref:integration/rest-clients.adoc#rest-http-interface[HTTP Service] clients, as well as |
|
|
|
|
for testing with `WebTestClient`. |
|
|
|
|
for testing in `WebTestClient`. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -24,14 +25,16 @@ for testing with `WebTestClient`.
@@ -24,14 +25,16 @@ for testing with `WebTestClient`.
|
|
|
|
|
== ApiVersionStrategy |
|
|
|
|
[.small]#xref:web/webmvc-versioning.adoc#mvc-versioning-strategy[See equivalent in the Servlet stack]# |
|
|
|
|
|
|
|
|
|
This strategy holds all application preferences about how to manage versioning. |
|
|
|
|
It delegates to xref:#webflux-versioning-resolver[ApiVersionResolver] to resolve versions |
|
|
|
|
from requests, and to xref:#webflux-versioning-parser[ApiVersionParser] to parse raw version |
|
|
|
|
values into `Comparable<?>`. It also helps to xref:#webflux-versioning-validation[validate] |
|
|
|
|
request versions. |
|
|
|
|
This is the central strategy for API versioning that holds all configured preferences |
|
|
|
|
related to versioning. It does the following: |
|
|
|
|
|
|
|
|
|
NOTE: `ApiVersionStrategy` helps to map requests to `@RequestMapping` controller methods, |
|
|
|
|
and is initialized by the WebFlux config. Typically, applications do not interact directly with it. |
|
|
|
|
- Resolves versions from the requests via xref:#webflux-versioning-resolver[ApiVersionResolver] |
|
|
|
|
- Parses raw version values into `Comparable<?>` with xref:#webflux-versioning-parser[ApiVersionParser] |
|
|
|
|
- xref:#webflux-versioning-validation[Validates] request versions |
|
|
|
|
|
|
|
|
|
`ApiVersionStrategy` helps to map requests to `@RequestMapping` controller methods, |
|
|
|
|
and is initialized by the WebFlux config. Typically, applications do not interact |
|
|
|
|
directly with it. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -53,7 +56,7 @@ You can also use a custom `ApiVersionResolver`.
@@ -53,7 +56,7 @@ You can also use a custom `ApiVersionResolver`.
|
|
|
|
|
|
|
|
|
|
This strategy helps to parse raw version values into `Comparable<?>`, which helps to |
|
|
|
|
compare, sort, and select versions. By default, the built-in `SemanticApiVersionParser` |
|
|
|
|
parses a version into `major`, `minor`, and `patch` integer values. Minor and patch |
|
|
|
|
parses a version into `major`, `minor`, and `patWebFluxch` integer values. Minor and patch |
|
|
|
|
values are set to 0 if not present. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -65,13 +68,13 @@ values are set to 0 if not present.
@@ -65,13 +68,13 @@ values are set to 0 if not present.
|
|
|
|
|
|
|
|
|
|
If a request version is not supported, `InvalidApiVersionException` is raised resulting |
|
|
|
|
in a 400 response. By default, the list of supported versions is initialized from declared |
|
|
|
|
versions in annotated controller mappings. You can add to that list, or set it explicitly |
|
|
|
|
to a fixed set of versions (i.e. ignoring declared ones) through the MVC config. |
|
|
|
|
versions in annotated controller mappings, but you can turn that off through a flag in the |
|
|
|
|
WebFlux config, and use only the versions configured explicitly in the config. |
|
|
|
|
|
|
|
|
|
By default, a version is required when API versioning is enabled, but you can turn that |
|
|
|
|
off in which case the highest available version is used. You can also specify a default |
|
|
|
|
version. `MissingApiVersionException` is raised resulting in a 400 response when a |
|
|
|
|
version is required but not present. |
|
|
|
|
By default, a version is required when API versioning is enabled, and |
|
|
|
|
`MissingApiVersionException` is raised resulting in a 400 response if not present. |
|
|
|
|
You can make it optional in which case the most recent version is used. |
|
|
|
|
You can also specify a default version to use. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|