Skip to content

Swagger UI displays blank page when using Spring Boot 4.0.0 API versioning (@RequestMapping(version = "v1")) #3154

@junsung-cho

Description

@junsung-cho

Describe the bug

When using Spring Boot 4.0.0 with Spring’s built-in API versioning (via @RequestMapping(version = "v1") and configureApiVersioning), the generated Swagger UI displays a blank page. The OpenAPI document is not rendered, and no API endpoints appear.
The issue occurs only when API versioning is enabled. When the version is part of the URL path (e.g., /v1/hello), Swagger UI works normally.

To Reproduce

Steps to reproduce the behavior:

  1. Use Spring Boot 4.0.0.
  2. Use the Springdoc OpenAPI modules compatible with Spring Boot 4
  3. Enable API versioning using @RequestMapping(version = "v1") and configure versioning with ApiVersionConfigurer.
  4. Access /swagger-ui.html or /swagger-ui/index.html.
  5. Swagger UI loads but shows a blank page.

Actual result
Swagger UI renders an empty page with no endpoints.

Expected result
Swagger UI should generate and render the OpenAPI document containing the versioned endpoint (e.g., /v1/hello) and display the API in the UI.

Sample Code

@RestController
@RequestMapping("hello", version = "v1")
class HelloController {
    @GetMapping
    fun hello(): HelloResponse {
        return HelloResponse("Hello, World!")
    }
}

@Configuration
class WebConfig : WebMvcConfigurer {
    override fun configureApiVersioning(configurer: ApiVersionConfigurer) {
        configurer.usePathSegment(0)
    }
}

This versioning method causes Swagger UI to be blank.

If the controller is written without Spring Boot API versioning, Swagger works normally:

@RestController
@RequestMapping("/v1/hello")
class HelloController {
    @GetMapping
    fun hello(): HelloResponse {
        return HelloResponse("Hello, World!")
    }
}

Screenshots

(If needed, a screenshot of the blank Swagger UI page can be attached here.)

Additional context

It appears that Spring Boot 4’s native API versioning modifies the request mappings in a way that Springdoc OpenAPI does not currently detect or process, resulting in an empty OpenAPI specification being generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions