implementation("io.github.turchenkoalex:kotlet-openapi:1.0.0")
Before configuration OpenAPI routing, you need to configure application routing as usual and provide it to documentedRoutings
property.
Example:
data class HelloResponse(val message: String)
val applicationRouter = Kotlet.routing {
get("/hello", { call ->
call.respondText("Hello, World!")
}) {
openapi {
summary("Hello world")
responses {
jsonResponse<HelloResponse>("Simple response")
}
}
}
}
val auxRouter = Kotlet.routing {
installOpenAPI {
path = "/swagger/openapi.json"
documentedRoutings = listOf(applicationRouter)
prettyPrint = true
openAPI {
info {
title = "Sample API"
version = "1.0"
}
}
}
}
val kotlet = Kotlet.servlet(
routings = listOf(applicationRouter, auxRouter)
)
This feature works better with the kotlet-swagger-ui
library. You can use it to visualize the OpenAPI documentation.