SMILEY4 / ktor-swagger-ui

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

Problem with rootPath and paths with multiple methods in 2.10.0 #103

Closed mrodem closed 1 month ago

mrodem commented 2 months ago

In 2.10.0 the ktor rootPath was added to paths: https://github.com/SMILEY4/ktor-swagger-ui/releases/tag/2.10.0.

When a rootPath has been configured, and a path has multiple methods (f.ex. both GET and POST) then only one of the methods are included in openapi.json. This is probably because the rootPath is not taken into account in when determining if a path already exists: https://github.com/SMILEY4/ktor-swagger-ui/blob/425236eb9cf1a3b990b99e1f0be09a35af4589b0/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/PathsBuilder.kt#L12-L22

So addAsNewPath is invoked even though a path exists, and overwrites the existing path.

SMILEY4 commented 2 months ago

Hi, thanks for reporting this problem. Can you check if this issue persists in version 3.0 and if an upgrade is possible for you? Otherwise i may need to fix this with a 2.10.x.

mrodem commented 2 months ago

This does not seem to be a problem in 3.0. However, I had some other problems there, so I decided to stay with 2.X until I have time to take a deeper look. A 2.10.x would be welcome though.

SMILEY4 commented 2 months ago

Hi, i released a quick fix as version 2.10.1 and it should be working now. For the future (and version 3.0) i removed the rootPath from the route-url again since i think its already covered by the server url - i'm not 100% sure though, so if you encounter any other issues just let me know :)