diff --git a/types/koa-joi-router/index.d.ts b/types/koa-joi-router/index.d.ts index 54cf148240..8ee1563370 100644 --- a/types/koa-joi-router/index.d.ts +++ b/types/koa-joi-router/index.d.ts @@ -31,6 +31,8 @@ declare namespace createRouter { type Method = (path: string|RegExp, handlerOrConfig: Handler | object, ...handlers: Handler[]) => Router; + type OutputValidation = { body: Joi.SchemaLike } | { headers: Joi.SchemaLike }; + interface Spec { method: string|string[]; path: string|RegExp; @@ -47,7 +49,7 @@ declare namespace createRouter { formOptions?: CoBody.Options; jsonOptions?: CoBody.Options; multipartOptions?: CoBody.Options; - output?: {[status: string]: Joi.SchemaLike}; + output?: {[status: string]: OutputValidation}; continueOnError?: boolean; }; meta?: any; diff --git a/types/koa-joi-router/koa-joi-router-tests.ts b/types/koa-joi-router/koa-joi-router-tests.ts index 160c3834c1..050ad4d5a1 100644 --- a/types/koa-joi-router/koa-joi-router-tests.ts +++ b/types/koa-joi-router/koa-joi-router-tests.ts @@ -41,8 +41,16 @@ const spec4: router.Spec = { validate: { type: 'json', output: { - 201: Joi.object(), - '400,404': Joi.object(), + 201: { + body: Joi.object(), + }, + '400,404': { + headers: Joi.object(), + body: Joi.object(), + }, + '500-599': { + headers: Joi.object(), + }, }, jsonOptions: { limit: '10kb'