Closed mcxinyu closed 3 months ago
I have no good way to get io.ktor.server.config.ApplicationConfig
in the io.github.smiley4.ktorswaggerui.builder.openapi.PathsBuilder
class, so I added it in the io.github.smiley4.ktorswaggerui.routing.ControllerUtils
utils class A field for storing it, maybe you can have a good idea?
Hi, thanks for the pr. Could you quickly explain why this change is necessary, i.e. which problem this is trying to solve. I think I'm overlooking something here :)
RootPath is A servlet context path.
It is the same concept as SwaggerUIDsl.kt#L33, but ktor will add this path to the front.
It is similar to the path of a reverse proxy, but it is implemented internally within ktor.
e.g.
in route.kt
get("/test") {}
in application.conf
ktor {
deployment {
rootPath = "xxxApi"
}
}
So the path of this api should be '/xxxApi/test'`.
The problem I solved here is that the user configures rootPath
, but the generated openapi.json did not include the path, causing 404 errors in the access interface.
Ah, i see. Looks good then 👍 Thank you!
Add ktor.deployment.rootPath to paths in openapi.json.