Reputation: 157
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:
openapi.json
file in my 'resources/static' folderspringdoc.swagger-ui.url=openapi.json
in my propertiesThis should be enough according to documentation:
But I've faced a problem trying to open swagger-ui.html, it says "Fetch error undefined openapi.json": Looking at browser dev tools and requests, I found following request:
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
Reputation: 157
As @Helen mentioned, it was important to put / before the path
Changing property to springdoc.swagger-ui.url=/openapi.json
resolved issue!
Upvotes: 1