Custom openapi documentation can't be applied for springdoc-openapi-ui web view

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:

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.

Upvotes: 1

Views: 1426

Answers (1)

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

Upvotes: 1

Related Questions