SMILEY4 / ktor-swagger-ui

Kotlin Ktor plugin to generate OpenAPI and provide Swagger UI
Apache License 2.0
156 stars 25 forks source link

Parameter rootHostPath not pass to requests #64

Closed hram closed 11 months ago

hram commented 1 year ago

My server hostet on some domain and some path For example http:/// I setup rootHostPath parameter as "/"

Swager UI oppends up correctly on URL http:////swagger/index.html But when I try to send some request URL do not contains rootHostPath in request

For example if I have routing get /health Full correct path is http:////health

But if I "try it out" in Swager UI full path is http:///health without rootHostPath parameter

SMILEY4 commented 1 year ago

Hi, i currently don't have a setup to properly test this myself, but i think you should be able to control the request-url with the server-configuration like this:

install(SwaggerUI) {
    server {
        url = "https://example.com/my-api"  // or just /my-api
    }
    swagger {
        swaggerUrl = "/swagger-ui"
        rootHostPath = "/my-api"
    }
}
// example curl would then be "curl -X 'GET' 'https://example.com/my-api/hello' -H 'accept: */*'"