java.util.NoSuchElementException: no root-schema for given type-descriptor
at io.github.smiley4.ktorswaggerui.builder.schema.SchemaContextImpl.getSchema(SchemaContextImpl.kt:167)
at io.github.smiley4.ktorswaggerui.builder.openapi.ContentBuilder.buildSimpleBody(ContentBuilder.kt:34)
at io.github.smiley4.ktorswaggerui.builder.openapi.ContentBuilder.build(ContentBuilder.kt:28)
at io.github.smiley4.ktorswaggerui.builder.openapi.ResponseBuilder.build(ResponseBuilder.kt:20)
...
It seems like the type's schema is not registered automatically by defaultUnauthorizedResponse.
Workaround
Manually define the unauthorized response on each route. Helper function can be used:
fun OpenApiResponses.unauthorizedResponse() {
HttpStatusCode.Unauthorized to {
// define response
}
}
The following works:
But this doesn't work (in setup):
Logs
It seems like the type's schema is not registered automatically by
defaultUnauthorizedResponse
.Workaround
Manually define the unauthorized response on each route. Helper function can be used:
Then used like so: