problemResponse
fun Responses.Builder.problemResponse(type: ProblemType, description: String? = null, schema: JsonSchema = ProblemSchemas.problem, configure: Response.Builder.() -> Unit = {})(source)
Documents type as a possible outcome of this operation.
The status comes from ProblemType.status and, unless description says otherwise, the description from ProblemType.title. Declaring two types that share a status yields one response describing both, with an example per type keyed by its type URI — OpenAPI allows only one response object per code.
Parameters
schema
the document shape; pass ProblemSchemas.problemWithErrors for a response carrying per-field errors.
Samples
routing {
get("/orders/{id}") {
call.respondText("an order")
}.describe {
summary = "Fetch one order"
responses {
problemResponse(OutOfCredit)
}
}
}Content copied to clipboard
fun Responses.Builder.problemResponse(status: HttpStatusCode, description: String? = null, schema: JsonSchema = ProblemSchemas.problem, configure: Response.Builder.() -> Unit = {})(source)
Documents status as producing a problem document, without naming a problem type.
For a status a server emits with a blank document — the codes standardStatusCodes() registers, for instance.