1

I'm trying to set up swagger-ui based on on existing json config, using 'org.springdoc:springdoc-openapi-ui:1.5.9' dependency (spring boot + gradle)

what I have is:

  • custom openapi.json file in my 'resources/static' folder
  • springdoc.swagger-ui.url=openapi.json in my properties

This should be enough according to documentation:

enter image description here

But I've faced a problem trying to open swagger-ui.html, it says "Fetch error undefined openapi.json": enter image description here Looking at browser dev tools and requests, I found following request:

enter image description here

So it uses /swagger-ui/ in path and cannot reach resource. My openapi.json available with simple http://localhost:8080/openapi.json, but w/o prefix.

I've tried to create "swagger-ui" dir under "static", but it did not help, file is still reachable in previous location.

I also tries to setspringdoc.api-docs.path, but it did not help as well, it changes only generated api location.

2
  • 1
    Try springdoc.swagger-ui.url=/openapi.json (note the slash / before the file name). Does this help? Commented Jul 20, 2021 at 16:20
  • Yes! It was the root cause (facepalm) Thank you! Commented Jul 20, 2021 at 20:43

1 Answer 1

1

As @Helen mentioned, it was important to put / before the path
Changing property to springdoc.swagger-ui.url=/openapi.json resolved issue!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.