Skip to content

Setting API Version Required when using WebFlux breaks the Swagger UI #3258

@magnus-larsson

Description

@magnus-larsson

Describe the bug

Using Springdoc 3.0.2 with Spring Boot 4.0.3.
When configuring a WebFluxConfigurer for API Versioning and setting VersionRequired to true, Swagger UI fails.
Specifically, the OpenAPI definition endpoint (/v3/api-docs) returns 404 - Not Found.

I have created a reproducer (attached zip file) based on the path-segment branch in the Git repo https://github.com/springdoc/springdoc-openapi-versioning-demo.

I have changed webmvc dependencies to webflux in the pom.xml, and changed the WebMvcConfigurer to a WebFluxConfigurer. To show the error, I have changed:

.setDefaultVersion("1.0")
.setVersionRequired(false)

to:

.setVersionRequired(true)

To Reproduce

Steps to reproduce the behavior:

  1. Download an unzip springdoc-webflux-version-requried-error.zip

  2. Build, run, and test

    In one terminal:

    cd springdoc-webflux-version-requried-error
    ./mvnw spring-boot:run
    

    In another terminal:

    # Expect 200 - OK responses from these reqiuests
    curl localhost:8080/api/v1.0/users
    curl localhost:8080/api/2.0/users
    curl http://localhost:8080/swagger-ui/index.html
    
    # These requests will fail with 404 - Not Found
    curl http://localhost:8080/v3/api-docs/swagger-config
    curl http://localhost:8080/v3/api-docs
    
  3. Open Swagger UI (http://localhost:8080/swagger-ui/index.html), it will show the error message: "Failed to load remote configuration."

  4. Change back to not requiring an API version, and Swagger UI starts to work again, including the two failed requests above.

Expected behavior

  • A working Swagger UI when using WebFlux and requiring API Versions to be specified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions