springdoc-openapi icon indicating copy to clipboard operation
springdoc-openapi copied to clipboard

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

Open junsung-cho opened this issue 1 month ago • 0 comments

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.

junsung-cho avatar Nov 21 '25 06:11 junsung-cho