added validations for spec and ref (#2962)

Co-authored-by: Anusree Subash <anusree@usebruno.com>
This commit is contained in:
anusreesubash 2024-09-05 19:05:26 +05:30 committed by GitHub
parent ab8afed8f9
commit c85d7b0c77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -229,7 +229,7 @@ const transformOpenapiRequestItem = (request) => {
return brunoRequestItem; 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') { if (!spec || typeof spec !== 'object') {
return spec; return spec;
} }
@ -253,7 +253,7 @@ const resolveRefs = (spec, components = spec.components, visitedItems = new Set(
let ref = components; let ref = components;
for (const key of refKeys) { for (const key of refKeys) {
if (ref[key]) { if (ref && ref[key]) {
ref = ref[key]; ref = ref[key];
} else { } else {
// Handle invalid references gracefully? // Handle invalid references gracefully?