Skip to content

webjars are not served from the expected url in webflux-ui with swagger-ui prefix path set #454

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
maartenh opened this issue Feb 21, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@maartenh
Copy link

Describe the bug
When I have a custom path /documentation/swagger-ui.html set for the webflux-ui version, this redirects to /documentation/webjars/swagger-ui/index.html?configUrl=/documentation/v3/api-docs/swagger-config
However, the webjars are not available on this url, leading to a 404 response.
The webjars are available on the alternative path /webjars/swagger-ui/index.html?configUrl=/documentation/v3/api-docs/swagger-config, ie without the /documentation prefix. That however foils my plan to have everything under the /documentation prefix for easier management of access permissions.

I tried also setting springdoc.webjars.prefix: /documentation/webjars, but that just compounded the issue by redirecting to /documentation/documentation/webjars/swagger-ui/index.html without changing the actual location the webjars were served from.

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using? v2.2.4
  • What modules and versions of springdoc-openapi are you using? springdoc-openapi-webflux-ui v1.2.32
springdoc.api-docs.path: /documentation/v3/api-docs
springdoc.swagger-ui.path: /documentation/swagger-ui.html
  • Access the path /documentation/swagger-ui.html from a web browser.
  • Observe 404 error

Expected behavior
The swagger ui is shown when accessing /documentation/swagger-ui.html

@bnasslahsen
Copy link
Collaborator

Hi,

You can use the following configuration class.
We will make this functionnality out of the box, for webflux from the next release: v1.2.33

@Configuration
public class SwaggerConfig implements WebFluxConfigurer {

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/documentation/webjars/**")
				.addResourceLocations("classpath:/META-INF/resources/webjars/")
				.resourceChain(false);
	}

}

@joaodias14
Copy link
Contributor

Hi @bnasslahsen, with 6414fbe there is no longer the need to use the configuration you mentioned in your previous comment right?

@bnasslahsen
Copy link
Collaborator

Hi @joaodias14,

Yes i confirm. It will be available on the next release.

@joaodias14
Copy link
Contributor

Many thanks @bnasslahsen!

@bnasslahsen bnasslahsen added the enhancement New feature or request label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants