Hi. I am trying to generate the OpenAPI documentat...
# ktor
f
Hi. I am trying to generate the OpenAPI documentation using the built-in tool in IntelliJ Ultimate. The issue I'm facing is that the endpoint and request object are not added at all into the generated OpenAPI output file when I specify the actual request types, such as for example
post<TestMessageRequest>
, like in the following example:
Copy code
@Serializable
data class TestMessageRequest(val message: String, val status: Int)

fun Route.testMessageRoute() {
    post<TestMessageRequest>("/message") { request ->
        println(request)
        call.respond(HttpStatusCode.OK)
    }
}
The endpoint only gets included in the OpenAPI file if I remove
<TestMessageRequest>
. On the other hand, type objects are included in the file when the endpoints are instead
get
calls returning them. It seems the issue affects only
post
calls.
I've just found out that if I use instead
call.receive
, then the documentation gets correctly generated. But the above syntax seems cleaner as it avoids having to write an extra line to receive the object. So, is this a bug, or the intended behavior?
Copy code
fun Route.testMessageRoute() {
    post("/message") {
        val request = call.receive<TestMessageRequest>()
        println(request)
        call.respond(HttpStatusCode.OK)
    }
}
a
That's likely a bug. Can you please file an issue?