koa-swagger-decorator
koa-swagger-decorator copied to clipboard
Add support for "default" response
Currently is not possible to define a default response block because the "response" decorator accepts an argument with type IResponses:
export interface IResponses {
[name: number]: any;
}
So is not possible to assign a string as key.
The desiderata woud be to allow the following:
@responses({
200: { description: "success",
"default": {description: "default error"}
})
The resulting json must have the following structure:
responses:
200:
description: Success
schema:
$ref: '#/definitions/User'
# Definition of all error statuses
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
A possible workaround could be:
const DEFAULT_ERROR_KEY: number = "default" as unknown as number
@responses({
200: { description: "success",
[DEFAULT_ERROR_KEY]: {description: "default error"}
})