Tegral
Tegral copied to clipboard
Simpler syntax for defining responses' schema
Currently:
get("/hello") {
respond(Greeting("You"))
} describe {
summary = "Greet someone"
200 response {
json { schema<Greeting>(Greeting("Hi!")) }
}
}
I think it would be possible to implement the invoke operator on the various valid types to allow the following syntax instead:
200 response {
json<Greeting>(Greeting("Hi!"))
(json or xml)<Greeting>(Greeting("Hi!"))
}
This is not possible until Kotlin's context()
feature lands, because otherwise this requires defining an inline extension function (because of reified generic types) in BodyDsl