From 57324ee0b6cb58ff038f0d6f092b2c203d8382ad Mon Sep 17 00:00:00 2001 From: Carmine DiMascio Date: Fri, 1 Jan 2021 23:13:03 -0500 Subject: [PATCH] fix: preprocessor fails if it cannot dereference a path. skip it. --- src/middlewares/parsers/schema.preprocessor.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/middlewares/parsers/schema.preprocessor.ts b/src/middlewares/parsers/schema.preprocessor.ts index 0ce96c5b..e0f4a11b 100644 --- a/src/middlewares/parsers/schema.preprocessor.ts +++ b/src/middlewares/parsers/schema.preprocessor.ts @@ -171,6 +171,12 @@ export class SchemaPreprocessor { const recurse = (parent, node, opts: TraversalStates) => { const schema = this.resolveSchema(node.schema); + if (!schema) { + // if we can't resolve the schema, skip it + // TODO fix me - must resolve $refs like, etc + // #/paths/~1subscription/get/requestBody/content/application~1json/schema/properties/subscription + return; + } // Save the original schema so we can check if it was a $ref (opts).req.originalSchema = node.schema; (opts).res.originalSchema = node.schema;