Search code examples
spring-bootswagger-uiopenapispringdocspringdoc-openapi-ui

Springdoc configUrl behind api gateway


I have springdoc swagger ui up and running with a spring cloud gateway route /myapi. So when I hit the url

https://myhost.com/myapi

it redirects me to a url

https://myhost.com/myapi/webjars/swagger-ui/index.html?configUrl=/swagger-config.json

I have below code in my application.yml file

springdoc:
  swagger-ui:
    path: /
    configUrl: /swagger-config.json

and I have set the below property as well

server.forward-headers-strategy: framework

My question is what else do I need to do in order to get the redirected url to also include the API gateway route in the config URL? Basically I want the redirected url to be

https://myhost.com/myapi/webjars/swagger-ui/index.html?configUrl=/myapi/swagger-config.json

and NOT

https://myhost.com/myapi/webjars/swagger-ui/index.html?configUrl=/swagger-config.json

Solution

  • I got a response from one of the contributors of the project on github (https://github.com/springdoc/springdoc-openapi/issues/1144). It all works fine if we use the default springdoc.swagger-ui.configUrl instead of specifying it explicitly.