springdoc-openapi icon indicating copy to clipboard operation
springdoc-openapi copied to clipboard

How can I customize the endpoint prefix?

Open andochiwa opened this issue 3 years ago • 0 comments

Describe the bug As far as I know, springdoc configures the endpoint prefix via server.servlet.context-path.

In my application, my endpoint prefix is not configured by servlet, which means I don't use server.servlet.context-path. I configure a prefix internal, when I access api I use localhost:8081/internal/xxx to access it. So the path to swagger-ui should become localhost:8081/internal/swagger-ui.html or localhost:8081/internal/swagger/index.html. But actually, localhost:8081/internal/swagger-ui.html will redirect to localhost:8081/swagger/index.html, while localhost:8081/internal/swagger/index.html will get the apis information from localhost:8081/v3/api-docs/swagger-config, which causes that I can't get the apis information directly, I need to explore /internal/v3/api-docs manually on swagger-ui, and I don't know how to solve this problem.

Actually i had this problem with springfox, I solved it by configure pathmapping, but with springdoc I didn't find any relevant configuration

@bean
public Docket docket() {
    return new Docket(DocumentationType.SWAGGER_2)
                        .pathMapping(endpointPrefix)
                        ......
}

andochiwa avatar Sep 22 '22 17:09 andochiwa