Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authorize in Swagger UI no longer works, starting in v2.8.4 #2935

Closed
magnus-larsson opened this issue Mar 9, 2025 · 2 comments
Closed

Authorize in Swagger UI no longer works, starting in v2.8.4 #2935

magnus-larsson opened this issue Mar 9, 2025 · 2 comments
Labels
question Further information is requested

Comments

@magnus-larsson
Copy link

Describe the bug

  • Using the Authorize button in Swagger UI no longer works; the bug is introduced in v2.8.4

To Reproduce

I have created a minimal project to reproduce the error. It consists of:

  • An auth server
  • An API
  • A Spring Cloud Gateway

Steps to reproduce the behavior:

  1. Verify that login works in swagger-ui with springdoc-openapi 2.8.3:

    Get the source code:

    git clone https://github.com/magnus-larsson/ml-auth-server-error.git
    cd ml-auth-server-error
    

    Build and start the auth server, the API, and the gateway:

    ./gradlew build
    docker compose up -d --build
    

    Open the Swagger UI and login:

    1. Open in a web browser: https://localhost:8443/openapi/swagger-ui.html
    2. Click on the Authorize button
    3. Select all available scopes
    4. Sign in using username u and password p
    5. Select all scopes and submit consent
    6. Login done
  2. Update to springdoc-openapi 2.8.5 in product-composite-service/build.gradle and repeat the instruction above.

    1. After the sign in, an errorpage with the following text will now be displayed:

      Whitelabel Error Page
      
      This application has no explicit mapping for /error, so you are seeing this as a fallback.
      
      Sat Mar 08 16:01:11 UTC 2025
      There was an unexpected error (type=None, status=999).
      
@bnasslahsen
Copy link
Collaborator

@magnus-larsson,

I understand your concern for this breaking change. In addition, it's not well documented.
This is related to this change #2862, to can align Swagger-WebFlux
Swagger-UI Prefix Path with Swagger-WebMvc

To fix your project, the better option is to remove the webjars prefix, from:

The new redirect url will be: https://localhost:8443/openapi/swagger-ui/oauth2-redirect.html

@bnasslahsen bnasslahsen added the question Further information is requested label Mar 22, 2025
@magnus-larsson
Copy link
Author

@bnasslahsen Thanks for your help!

I have pushed a working solution in the branch v2.8.6-OK, where I removed webjars and upgraded to the latest version of springdoc-openapi, v2.8.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants