Skip to content

New webjar resolver mechanism does not work with springdoc.api-docs.enabled set to false #2287

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

Closed
arkadiuszl opened this issue Jun 27, 2023 · 1 comment

Comments

@arkadiuszl
Copy link

There was a change introduced in 2.1.0 that changes the way Swagger assets are resolved in webjars (commit). The SpringDocUIConfiguration has @ConditionalOnExpression("${springdoc.api-docs.enabled:true}") which prevents my application from working properly (it worked fine on 2.0.x) - when I hit the endpoint configured in springdoc.swagger-ui.path I am redirected to a URL that is not then resolved by Springdoc's SwaggerResourceResolver

To Reproduce
Version: 2.1.0
Dependency: org.springdoc:springdoc-openapi-starter-webmvc-ui
Spring Boot 3.0.8

Steps to reproduce the behavior:

  1. In application.yml
    • set springdoc.api-docs.enabled: false
    • set springdoc.swagger-ui.path: /my-url
  2. Open the URL in a web browser

Result: I'm receiving a 302 response with a Location which is then incorrectly resolved - web browser receives 404.

Expected behavior: I should be correctly redirected to Swagger's index.html

Additional context
For now, I'm using a workaround:

  @Bean SpringDocConfigFix springDocConfigFix(SwaggerUiConfigProperties props) {
    return new SpringDocConfigFix(Optional.of(props));
  }

  static class SpringDocConfigFix extends SpringDocUIConfiguration {

    public SpringDocConfigFix(
        Optional<SwaggerUiConfigProperties> optionalSwaggerUiConfigProperties) {
      super(optionalSwaggerUiConfigProperties);
    }
  }
@arkadiuszl
Copy link
Author

I can see it was fixed by #2193. Closing ;-)

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

No branches or pull requests

1 participant