Skip to content

Add support for addPathPrefix with Webflux swagger-ui #1050

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
shota-hizawa-reazon opened this issue Feb 2, 2021 · 6 comments
Closed

Add support for addPathPrefix with Webflux swagger-ui #1050

shota-hizawa-reazon opened this issue Feb 2, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@shota-hizawa-reazon
Copy link

shota-hizawa-reazon commented Feb 2, 2021

Describe the Feature
When we use WebFluxConfigurer to set base-path, it's unable to access http://server:port/context-path/swagger-ui.html.
We can access to http://server:port/context-path/v3/api-doc though.
image
image

WebfluxConfigurer

@Configuration
@EnableWebFlux
class WebFluxConfiguration : WebFluxConfigurer {

    override fun configurePathMatching(configurer: PathMatchConfigurer) {
        configurer.addPathPrefix("/api/v1") { true }
    }
}

In this case, context-path should be replaced with /api/v1, so we should see swagger-ui at http://server:port/api/v1/swagger-ui.html.

image

It seems like that context-path is not loaded when generating the url of springdoc-config, because we can access to http://server:port/api/v1/v3/api-docs/swagger-config.
image

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?
    Running with Spring Boot v2.4.0, Spring v5.3.1

  • What modules and versions of springdoc-openapi are you using?
    Using springdoc-openapi-webflux-ui v1.5.2 with springdoc-openapi-kotlin v.1.5.2

  • Provide with a sample code (HelloController) or Test that reproduces the problem
    I put a sample code to set context-path by WebFluxConfigurer above. so please refer that.

Expected behavior
We should be able to access swagger-ui.html

@bnasslahsen
Copy link
Collaborator

@shota-hizawa-reazon,

This seems to be a dupblicate of #1034.
Have you tested with the latest stable release: v1.5.3 ?

@shota-hizawa-reazon
Copy link
Author

@bnasslahsen,

I've tested v1.5.3 now, but I got the same error as #1047.

Description:

Parameter 3 of method swaggerWelcome in org.springdoc.webflux.ui.SwaggerConfig required a bean of type 'org.springframework.boot.autoconfigure.web.reactive.WebFluxProperties' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.boot.autoconfigure.web.reactive.WebFluxProperties' in your configuration.

As you say, the problem itself seems to be a duplicate of #1037, so I close this.
Thank you for your quick reply!

@shota-hizawa-reazon
Copy link
Author

I tried springdoc-openapi-webflux-ui: v1.5.4, but I'm still unable to access to Swagger UI with base-path settings.

@Configuration
@EnableWebFlux
class WebFluxConfiguration : WebFluxConfigurer {

    override fun configurePathMatching(configurer: PathMatchConfigurer) {
        configurer.addPathPrefix("/api/v1") { true }
    }

In my WebFluxConfigurer, I set the base-path to /api/v1.
Then, I opened http://localhost:<PORT>/api/v1/swagger-ui.html, however, the page shows error and console also shows errors.
image

If I comment out the base-path settings shown above, and open http://localhost:<PORT>/swagger-ui.html, it works.

Anything I’m missing?

@bnasslahsen
Copy link
Collaborator

@shota-hizawa-reazon,

This seems a different problem, as you are setting the path prefix using addPathPrefix.
This one is not supported yet.

@bnasslahsen bnasslahsen changed the title unable to access swagger-ui.html using WebFluxConfigurer Add support for addPathPrefix on Webflux Feb 16, 2021
@bnasslahsen bnasslahsen changed the title Add support for addPathPrefix on Webflux Add support for addPathPrefix on Webflux, on the UI Feb 16, 2021
@bnasslahsen bnasslahsen changed the title Add support for addPathPrefix on Webflux, on the UI Add support for addPathPrefix on Webflux, for the swagger-ui Feb 16, 2021
@bnasslahsen bnasslahsen changed the title Add support for addPathPrefix on Webflux, for the swagger-ui Add support for addPathPrefix for Webflux swagger-ui Feb 16, 2021
@bnasslahsen bnasslahsen changed the title Add support for addPathPrefix for Webflux swagger-ui Add support for addPathPrefix with Webflux swagger-ui Feb 16, 2021
@bnasslahsen
Copy link
Collaborator

@shota-hizawa-reazon,

The support is now added.
You can test it using the latest snapshot.

@shota-hizawa-reazon
Copy link
Author

@bnasslahsen,

I've tested with the latest of 1.5.5-SNAPSHOT, and it works.
Thank you so much!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants