Merge pull request #32920 from NotWoods/koa-joi-router_output

Set koa-joi-router output object types
This commit is contained in:
Mine Starks
2019-02-12 12:29:53 -08:00
committed by GitHub
2 changed files with 13 additions and 3 deletions
+3 -1
View File
@@ -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;
+10 -2
View File
@@ -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'