-
-
Notifications
You must be signed in to change notification settings - Fork 562
Description
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:
- Use Spring Boot 4.0.0.
- Use the Springdoc OpenAPI modules compatible with Spring Boot 4
- Enable API versioning using
@RequestMapping(version = "v1")and configure versioning withApiVersionConfigurer. - Access
/swagger-ui.htmlor/swagger-ui/index.html. - 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.