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 <anusree@usebruno.com>
This commit is contained in:
anusreesubash 2024-09-16 00:22:59 +05:30 committed by GitHub
parent 3dfb27d447
commit f31c997fed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -283,7 +283,9 @@ const groupRequestsByTags = (requests) => {
each(requests, (request) => { each(requests, (request) => {
let tags = request.operationObject.tags || []; let tags = request.operationObject.tags || [];
if (tags.length > 0) { if (tags.length > 0) {
let tag = tags[0]; // take first tag let tag = tags[0].trim(); // take first tag and trim whitespace
if (tag) {
if (!_groups[tag]) { if (!_groups[tag]) {
_groups[tag] = []; _groups[tag] = [];
} }
@ -291,6 +293,9 @@ const groupRequestsByTags = (requests) => {
} else { } else {
ungrouped.push(request); ungrouped.push(request);
} }
} else {
ungrouped.push(request);
}
}); });
let groups = Object.keys(_groups).map((groupName) => { let groups = Object.keys(_groups).map((groupName) => {