Skip to content

Api Versioning. Use the default version from ApiVersionConfigurer #3159

@ruslansin

Description

@ruslansin

Is your feature request related to a problem? Please describe.

I’m using Swagger (OpenAPI) in a Spring Boot 4 application with API versioning. The OpenAPI specification is not generated correctly when the version is not explicitly specified in the @GetMapping or similar annotations.

Describe the solution you'd like

I expect it to automatically apply the default version defined in my ApiVersionConfigurer:

@Configuration
public class ApplicationWebConfiguration implements WebMvcConfigurer {
    @Override
    public void configureApiVersioning(ApiVersionConfigurer configurer) {
        configurer.setDefaultVersion("1");
    }
}

Specifically, if no version is explicitly declared in the @GetMapping or similar, the system should:

  1. Detect the absence of a version in the request mapping.
  2. Fall back to the defaultVersion property configured in ApiVersionConfigurer.
  3. Include that default version in the OpenAPI schema.
    Example of desired outcome:
    If ApiVersionConfigurer sets defaultVersion = "1", then:
    @RequestMapping(value = "/api/v{version}", produces = APPLICATION_JSON_VALUE)
    @GetMapping("/data") → should generate OpenAPI path: /api/v1/data
    The OpenAPI doc should reflect v1 as the version for this endpoint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions