-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
post fails to deserialise List<UUID> in body, even though Swagger knows that the correct type is UUID. Kotlin says it's UUID, however during runtime, it's String, which results in ClassCastException when accessing the element. My project is using latest Jackson.
Minimal working example:
fun NormalOpenAPIRoute.testRoute() {
route("/test").post<Unit, String, List<UUID>> { _, listUuids ->
println(listUuids.joinToString(separator = " - ") { it.toString() }) // access on the element throws java.lang.ClassCastException
respond("OK")
}
}Request:
curl -X POST "http://localhost:8080/test" -H "accept: application/json" -H "Content-Type: application/json" -d "[\"3fa85f64-5717-4562-b3fc-2c963f66afa6\"]"
Exception:
java.lang.ClassCastException: class java.lang.String cannot be cast to class java.util.UUID (java.lang.String and java.util.UUID are in module java.base of loader 'bootstrap')
at com.wire.troy.routing.ConversationRoutesKt$testRoute$1$1.invoke(ConversationRoutes.kt:81)
at kotlin.text.StringsKt__AppendableKt.appendElement(Appendable.kt:85)
at kotlin.collections.CollectionsKt___CollectionsKt.joinTo(_Collections.kt:3344)
at kotlin.collections.CollectionsKt___CollectionsKt.joinToString(_Collections.kt:3361)
at kotlin.collections.CollectionsKt___CollectionsKt.joinToString$default(_Collections.kt:3360)
And the openapi.json
{
"/test": {
"post": {
"requestBody": {
"content": {
"application/json": {
"schema": {
"items": {
"format": "uuid",
"nullable": false,
"type": "string"
},
"nullable": false,
"type": "array"
}
}
}
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"nullable": false,
"type": "string"
}
}
},
"description": "OK"
}
}
}
}
}Metadata
Metadata
Assignees
Labels
No labels
