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.

Springfox swagger-ui.html not loading using version 3.0.0-SNAPSHOT

See original GitHub issue

In our project we are using 3.0.0-SNAPSHOT of swagger springfox.

Recently when we open swagger-ui.html, it is giving 404 Whilte Label Error.

I enabled logs at web level

`

logging.level.web=TRACE
logging.level.org.springframework.web=TRACE

`

It is loading “/swagger-resources”, but not loading “/swagger-ui.html”

The addition of the resource handler is as per the document.

When loading “/swagger-ui.html”, it’s giving “Resource not found”

`

web.server.adapter.HttpWebHandlerAdapter.traceDebug - [74c4396b] HTTP GET "/swagger-resources/", headers={masked}
web.reactive.result.method.annotation.RequestMappingHandlerMapping.lambda$getHandler$1 - [74c4396b] Mapped to public org.springframework.http.ResponseEntity<java.util.List<springfox.documentation.swagger.web.SwaggerResource>> springfox.documentation.swagger.web.ApiResourceController.swaggerResources()
web.reactive.result.method.annotation.ResponseEntityResultHandler.selectMediaType - Using 'application/json;q=0.8' given [text/html, application/xhtml+xml, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.9, */*;q=0.8] and supported [application/json]
web.reactive.result.method.annotation.ResponseEntityResultHandler.writeBody - [74c4396b] 0..1 [java.util.List<springfox.documentation.swagger.web.SwaggerResource>]
http.codec.json.Jackson2JsonEncoder.trace - [74c4396b] Encoding [[springfox.documentation.swagger.web.SwaggerResource@4903f26e, springfox.documentation.swagger.web.SwaggerResource@57b46085, springfox.documentation.swagger.web.SwaggerResource@4beb0f82, springfox.documentation.swagger.web.SwaggerResource@3a6db652, springfox.documentation.swagger.web.SwaggerResource@6caba3f3, springfox.documentation.swagger.web.SwaggerResource@18ef56ab, springfox.documentation.swagger.web.SwaggerResource@b6bcd2b, springfox.documentation.swagger.web.SwaggerResource@5ce32532, springfox.documentation.swagger.web.SwaggerResource@6d66b166, springfox.documentation.swagger.web.SwaggerResource@fdef86f, springfox.documentation.swagger.web.SwaggerResource@5a096e2a, springfox.documentation.swagger.web.SwaggerResource@1f060aec, springfox.documentation.swagger.web.SwaggerResource@473365eb, springfox.documentation.swagger.web.SwaggerResource@3fd6e0e2]]
web.server.adapter.HttpWebHandlerAdapter.traceDebug - [74c4396b] Completed 200 OK, headers={masked}
http.server.reactive.ReactorHttpHandlerAdapter.trace - [74c4396b] Handling completed

web.server.adapter.HttpWebHandlerAdapter.traceDebug - [74c4396b] HTTP GET "/swagger-ui.html", headers={masked}
web.reactive.handler.SimpleUrlHandlerMapping.lookupHandler - [74c4396b] Matching patterns [/swagger-ui.html**, /**]
web.reactive.handler.SimpleUrlHandlerMapping.lambda$getHandler$1 - [74c4396b] Mapped to ResourceWebHandler ["classpath:/META-INF/resources/"]
web.reactive.resource.ResourceWebHandler.lambda$handle$0 - [74c4396b] Resource not found
web.reactive.function.server.RouterFunctions.route - [74c4396b] Matched org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler$$Lambda$1372/0x00000008008bb040@10209892
web.HttpLogging.debug - [74c4396b] Resolved [ResponseStatusException: 404 NOT_FOUND] for HTTP GET /swagger-ui.html
core.codec.CharSequenceEncoder.trace - [74c4396b] Writing "<html><body><h1>Whitelabel Error Page</h1><p>This application has no configured error view, so you are seeing this as a fallback.</p><div id='created'>Thu Jul 02 22:15:45 IST 2020</div><div>There was an unexpected error (type=Not Found, status=404).</div></body></html>"
web.server.adapter.HttpWebHandlerAdapter.traceDebug - [74c4396b] Completed 404 NOT_FOUND, headers={masked}
http.server.reactive.ReactorHttpHandlerAdapter.trace - [74c4396b] Handling completed

`

I checked if path inside META-INF is changed or not as per documentation at https://springfox.github.io/springfox/docs/snapshot/#snapshot-3, it is same as V 2.10.5

Then, when I changed version from V 3 Snapshot to current stable 2.10.5, it worked.

Can you let me know what I am missing? And since I am a noobie, can you tell me is snapshot version is like beta version which should not be used in production?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:25 (3 by maintainers)

github_iconTop GitHub Comments

46reactions
egchcommented, Oct 30, 2020

In spring boot it works by simply adding this, no other dependencies needed: <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> </dependency> The url is /swagger-ui/ , mind the final slash.

25reactions
fishjamcommented, Jul 23, 2020

I use 3.0.0 and find the new swagger ui is http://xxxx:port/swagger-ui/ ( please remember the last splash). actually, you can add spring-boot-starter-actuator and confirm the swagger ui mapping by check http://xxx:port/actuator/mappings . And my suggestion is restore the url to swagger-ui.html.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Springfox swagger-ui 3.0.0 does not bring up ... - Stack Overflow
I am using springfox swagger-ui with Springboot ...
Read more >
springfox/springfox - Gitter
JsonView support is now available in 3.0.0-SNAPSHOT version. ... I am getting a "Failed to load API definition" while accessing /swagger-ui.html.
Read more >
failed to start bean 'documentationpluginsbootstrapper ...
Spring boot Swagger implementation using Spring Fox Failed to start bean ... Swagger is not working after migrating Springfox from v. 2.9.2 to...
Read more >
Springfox Reference Documentation - GitHub Pages
In this scenario, Springfox will not correctly generate and expose the Swagger UI endpoint ( /swagger-ui.html ) if @EnableWebMvc is present in ......
Read more >
[Solved]-Springfox swagger-ui.html unable to infer base URL
I am using Spring boot 2.3.0.BUILD-SNAPSHOT and io.springfox 3.0.0-SNAPSHOT. SpringFoxConfig class stays the same. package com.telixia.educare.academy; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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