From c3aaa62e9e4ef27a37e1c1a655b6f74ba146fd6a Mon Sep 17 00:00:00 2001 From: Carmine DiMascio Date: Sun, 19 Apr 2020 11:08:25 -0400 Subject: [PATCH] improve error handling for missing/mistyped route mappings --- package-lock.json | 2 +- package.json | 2 +- src/index.ts | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 062aa538..ff6829ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "express-openapi-validator", - "version": "3.12.1", + "version": "3.12.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 77834a3f..2c3b1806 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "express-openapi-validator", - "version": "3.12.1", + "version": "3.12.2", "description": "Automatically validate API requests and responses with OpenAPI 3 and Express.", "main": "dist/index.js", "scripts": { diff --git a/src/index.ts b/src/index.ts index 874f1d2d..f7e010b0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -249,6 +249,9 @@ export class OpenApiValidator { } } const fn = tmpModules[modulePath][oId]; + if (!tmpModules[modulePath][oId]) { + throw Error(`Could not resolve 'x-eov-operation-handler' function in module '${modulePath}' for with id '${oId}'. Make sure a function exists for id '${oId}'.`) + } app[method.toLowerCase()](expressRoute, fn); } }