SMILEY4 / ktor-swagger-ui

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

Rate limiting scope included #110

Closed max-f closed 5 months ago

max-f commented 5 months ago

Hi, a rate limited endpoint like

routing {
        rateLimit(RateLimitName("limit")) {
            rateLimitedRoutes()
        }
}

fun Route.rateLimitedRoutes() {
    route("/rated") {
        get("hello", {
            description = "Returns a rated greeting"
            tags = setOf("Public")
        }) {
            call.respondText("ratedHello")
        }
    }
}

seems to result in a wrong path in the generated openapi spec / swagger-ui: image

Is there a way to 'overwrite' or otherwise circumvent that behavior?

SMILEY4 commented 5 months ago

Hi, you can ignore parts of the route in the plugin config using ignoredRouteSelectors. You can add the rate limiter routeSelector to this list and it will not be included in the spec.