From 3cf082fbd0975e3e87384f07d8fcb83bc0bebe0c Mon Sep 17 00:00:00 2001 From: Carmine DiMascio Date: Thu, 21 Mar 2019 22:08:58 -0400 Subject: [PATCH] fix errors --- index.ts | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/index.ts b/index.ts index 9725547b..89076bc0 100644 --- a/index.ts +++ b/index.ts @@ -38,26 +38,22 @@ export interface OpenApiMiddlewareOpts extends OpenAPIFrameworkArgs { const unsupportedMediaTypeError = { statusCode: 415, - error: { - errors: [ - { - status: 415, - message: 'unsupported media type', - }, - ], - }, + errors: [ + { + status: 415, + message: 'unsupported media type', + }, + ], }; const notFoundError = { - statusCode: 404, - error: { - errors: [ - { - status: 404, - message: 'not found', - }, - ], - }, + status: 404, + errors: [ + { + status: 404, + message: 'not found', + }, + ], }; export function OpenApiMiddleware(opts: OpenApiMiddlewareOpts) { @@ -185,7 +181,6 @@ OpenApiMiddleware.prototype._transformValidationResult = function( validationResult ) { if (validationResult && validationResult.errors.length > 0) { - const { errors, status } = validationResult; const transform = this.opts.errorTransform || (v => ({