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,11 +283,16 @@ 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 (!_groups[tag]) {
_groups[tag] = []; if (tag) {
if (!_groups[tag]) {
_groups[tag] = [];
}
_groups[tag].push(request);
} else {
ungrouped.push(request);
} }
_groups[tag].push(request);
} else { } else {
ungrouped.push(request); ungrouped.push(request);
} }