From c85d7b0c7727918f9fc670d80b9e88c7eede6bf0 Mon Sep 17 00:00:00 2001 From: anusreesubash <65728079+anusreesubash@users.noreply.github.com> Date: Thu, 5 Sep 2024 19:05:26 +0530 Subject: [PATCH] added validations for spec and ref (#2962) Co-authored-by: Anusree Subash --- packages/bruno-app/src/utils/importers/openapi-collection.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/bruno-app/src/utils/importers/openapi-collection.js b/packages/bruno-app/src/utils/importers/openapi-collection.js index 55719e74f..eb2944cbf 100644 --- a/packages/bruno-app/src/utils/importers/openapi-collection.js +++ b/packages/bruno-app/src/utils/importers/openapi-collection.js @@ -229,7 +229,7 @@ const transformOpenapiRequestItem = (request) => { return brunoRequestItem; }; -const resolveRefs = (spec, components = spec.components, visitedItems = new Set()) => { +const resolveRefs = (spec, components = spec?.components, visitedItems = new Set()) => { if (!spec || typeof spec !== 'object') { return spec; } @@ -253,7 +253,7 @@ const resolveRefs = (spec, components = spec.components, visitedItems = new Set( let ref = components; for (const key of refKeys) { - if (ref[key]) { + if (ref && ref[key]) { ref = ref[key]; } else { // Handle invalid references gracefully?