spring-bootswaggercontextpath

Open API (Swagger) non working in Spring Boot when adding context path


I have a Spring Boot application exposing REST services that are easily called on addresses like

http://localhost:8080/<controller_mapping>/<service_mapping>.

I've been asked to modify my settings in order to add a context path and have my services to respond on

http://localhost:8080//gesev-mensa/<controller_mapping>/<service_mapping>.

Thus I edited my application.properties adding

server.servlet.context-path=/gesev-mensa

Everything works but I can't call Swagger on old address

http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/

I get the error Failed to load remote configuration

As suggested, I tried to add property

springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html

but problem persists. I guess Swagger should be reachable at

http://localhost:8080/gesev-mensa/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/

but that doesn't work. Any hint?

Thanks for support.


Solution

  • Try removing

    springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
    

    from your properties, And your swagger will be available in

    http://localhost:8080/gesev-mensa/swagger-ui/index.html

    As per your current configuration with,

    springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
    

    Swagger will be available in

    http://localhost:8080/gesev-mensa/gesev-mensa/swagger-ui/index.html