jooby
jooby copied to clipboard
[kotlin, openapi] Kooby extension method in another compilation unit
The following code will generate valid openapi json file:
// an extension method that creates some routes
fun Kooby.helloRoute() {
get("/hello") { "world" }
}
fun main(args: Array<String>) {
runApp(args) {
// calling the extension method
helloRoute()
}
}
as long as Kooby.helloRoute() method is written in the same compilation unit as main() in App.kt.
If I move Kooby.helloRoute() to another file, the generated openapi json will contain an empty paths section, although browsing to http://localhost:8080/hello still gets world.