From f31c997fed8235dcc4f211e33175e36f4d03d058 Mon Sep 17 00:00:00 2001 From: anusreesubash <65728079+anusreesubash@users.noreply.github.com> Date: Mon, 16 Sep 2024 00:22:59 +0530 Subject: [PATCH] Bugfix/openapispec empty tag (#2935) * test: added test for self closing tags in xml-json parser * fix: allows import of openapispec with empty string as tags --------- Co-authored-by: Anusree Subash --- .../src/utils/importers/openapi-collection.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/bruno-app/src/utils/importers/openapi-collection.js b/packages/bruno-app/src/utils/importers/openapi-collection.js index eb2944cbf6..3bfe8394f1 100644 --- a/packages/bruno-app/src/utils/importers/openapi-collection.js +++ b/packages/bruno-app/src/utils/importers/openapi-collection.js @@ -283,11 +283,16 @@ const groupRequestsByTags = (requests) => { each(requests, (request) => { let tags = request.operationObject.tags || []; if (tags.length > 0) { - let tag = tags[0]; // take first tag - if (!_groups[tag]) { - _groups[tag] = []; + let tag = tags[0].trim(); // take first tag and trim whitespace + + if (tag) { + if (!_groups[tag]) { + _groups[tag] = []; + } + _groups[tag].push(request); + } else { + ungrouped.push(request); } - _groups[tag].push(request); } else { ungrouped.push(request); }