question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`swagger-ui.html` is not found - HTTP404

See original GitHub issue

TLDR: this is the duplicate of the issue #361, but:

  • the solution there (start the app differently from IntelliJ) did not solve my issue
  • I was able to create an MCVE

Describe the bug I do run spring-boot 2.2.2-RELEASE with springdoc-openapi-webflux-ui 1.2.29.

The following requests give me the following statuses:

[vilmosnagy@vnagy-dell hkir-trip-planner]$ curl -sD - http://localhost:8080/v3/api-docs/swagger-config  && echo 
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 119

{"configUrl":"/v3/api-docs/swagger-config","oauth2RedirectUrl":"/swagger-ui/oauth2-redirect.html","url":"/v3/api-docs"}
[vilmosnagy@vnagy-dell hkir-trip-planner]$ curl -sD - http://localhost:8080/v3/api-docs   && echo 
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 719

{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost:8080","description":"Generated server url"}],"paths":{"/v1/test":{"post":{"tags":["example-controller"],"operationId":"getPlanForParameter","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExampleRequest"}}}},"responses":{"200":{"description":"default response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExampleResponse"}}}}}}}},"components":{"schemas":{"ExampleRequest":{"type":"object","properties":{"id":{"type":"string"}}},"ExampleResponse":{"type":"object","properties":{"id":{"type":"string"},"count":{"type":"integer","format":"int32"}}}}}}
[vilmosnagy@vnagy-dell hkir-trip-planner]$ curl -sD - http://localhost:8080/swagger-ui.html  && echo 
HTTP/1.1 307 Temporary Redirect
Location: /webjars/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config
content-length: 0


[vilmosnagy@vnagy-dell hkir-trip-planner]$ curl -sD - http://localhost:8080/webjars/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config  && echo 
HTTP/1.1 404 Not Found
Content-Type: application/json
Content-Length: 155

{"timestamp":1580836491212,"path":"/webjars/swagger-ui/index.html","status":404,"error":"Not Found","message":"No matching handler","requestId":"ed2cc66d"}
[vilmosnagy@vnagy-dell hkir-trip-planner]$ 

(TLDR: it’s the same as in the mentioned issue, the swagger-ui.html redirects me somewhere, and that page does not load)

To Reproduce Steps to reproduce the behavior:

Expected behavior

  • I shall see the swagger IO at that location

Screenshots Nothing extraordinary, the standard Spirng-Boot error page. image

Additional context My problem is the same as in #361, but I was able to create an MVCE.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
bnasslahsencommented, Feb 4, 2020

Hi @vilmosnagy,

As stated in the Spring Boot reference documentation, when you use @EnableWebFlux, you tell Spring Boot that you wish to take full control over the WebFlux configuration and disable all auto-configuration for this (including static resources):

You have two solutions:

  • Remove @EnableWebFlux
  • If you really want take control of Bean creation and you want absolutely to use @EnableWebFlux, then you need to add an implementation of WebFluxConfigurer. Here is a sample code:
@Configuration
public class WebConfig  implements WebFluxConfigurer {
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/webjars/**")
				.addResourceLocations(CLASSPATH_RESOURCE_LOCATION+"/webjars/")
				.resourceChain(true)
				.addResolver(new WebJarsResourceResolver());
	}
}
0reactions
bnasslahsencommented, Dec 30, 2020

@kanai0618,

You have here a fully working sample of spring cloud gateway. You can see the Piotrminkowski Blog for detailed instructions

And if you are still struggling, please make sure you Provide a Minimal, Reproducible Example - with HelloController that reproduces the problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger with Spring Boot 2.0 leads to 404 error page
And it worked. The Swagger UI can be reached at /swagger-ui.html# ... I also had the same issue (404 Not Found with springfox...
Read more >
Getting HTTP 404 error on /swagger-ui.html but other ... - GitHub
When I try to access http://localhost:8080/swagger-ui.html URL I am getting following error in console. No mapping found for HTTP request with ...
Read more >
Receiving 404 error on Swagger UI with Spring-Springboot
Just use /swagger-ui/ instead of swagger-ui.html if you are using version > 3 ... Springfox swagger 2 not working with Spring Boot 1.5:...
Read more >
Getting error 404 in deployed swagger project - Google Groups
Hello, I'm new to developing REST Web Services and Swagger. I'm using JAX-RS/Jersey and Eclipse and I already managed to configure and deploy...
Read more >
Setting Example and Description with Swagger - Baeldung
For example, let's say the product isn't found, and our API returns an HTTP 404 status in this scenario. If we don't add...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found