This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Framework 6.2.6!

API Versioning

Spring WebFlux supports API versioning. This section provides an overview of the support and underlying strategies.

Please, see also related content in:

API versioning is also supported on the client side in RestClient, WebClient, and HTTP Service clients, as well as for testing with WebTestClient.

ApiVersionStrategy

This strategy holds all application preferences about how to manage versioning. It delegates to ApiVersionResolver to resolve versions from requests, and to ApiVersionParser to parse raw version values into Comparable<?>. It also helps to validate 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.

ApiVersionResolver

This strategy resolves the API version from a request. The WebFlux config provides built-in options to resolve from a header, a request parameter, or from the URL path. You can also use a custom ApiVersionResolver.

ApiVersionParser

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 values are set to 0 if not present.

Validation

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.

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.

Request Mapping

ApiVersionStrategy supports the mapping of requests to annotated controller methods. See API Versions for more details.