diff --git a/packages/elements/src/components/API/utils.ts b/packages/elements/src/components/API/utils.ts index 66d8d9e0b..769a4d554 100644 --- a/packages/elements/src/components/API/utils.ts +++ b/packages/elements/src/components/API/utils.ts @@ -31,9 +31,9 @@ export function computeTagGroups(serviceNode: ServiceNo groupsByTagId[tagId].items.push(node); } else { const serviceTagIndex = lowerCaseServiceTags.findIndex(tn => tn === tagId); - const serviceTagName = serviceNode.tags[serviceTagIndex]; + const serviceTag = serviceNode.tagsRaw?.[serviceTagIndex]; groupsByTagId[tagId] = { - title: serviceTagName || tagName, + title: serviceTag?.description || serviceTag?.name || tagName, items: [node], }; } diff --git a/packages/elements/src/utils/oas/__tests__/oas.spec.ts b/packages/elements/src/utils/oas/__tests__/oas.spec.ts index 865728632..f2dde02bd 100644 --- a/packages/elements/src/utils/oas/__tests__/oas.spec.ts +++ b/packages/elements/src/utils/oas/__tests__/oas.spec.ts @@ -94,6 +94,16 @@ describe('computeOasNodes', () => { infoExtensions: {}, }, tags: ['operation-tag', 'model-tag'], + tagsRaw: [ + { + id: '68c460dd9e97a', + name: 'operation-tag', + }, + { + id: 'feec8b579ae6b', + name: 'model-tag', + }, + ], children: [ { type: 'http_operation', @@ -171,6 +181,16 @@ describe('computeOasNodes', () => { version: '1.0.0', }, tags: ['operation-tag', 'model-tag'], + tagsRaw: [ + { + id: '68c460dd9e97a', + name: 'operation-tag', + }, + { + id: 'feec8b579ae6b', + name: 'model-tag', + }, + ], children: [ { type: 'http_operation', diff --git a/packages/elements/src/utils/oas/index.ts b/packages/elements/src/utils/oas/index.ts index 14e425c64..7215ad239 100644 --- a/packages/elements/src/utils/oas/index.ts +++ b/packages/elements/src/utils/oas/index.ts @@ -73,6 +73,7 @@ function computeServiceNode( name: serviceDocument.name, data: serviceDocument, tags: serviceDocument.tags?.map(tag => tag.name) || [], + tagsRaw: serviceDocument.tags, children: computeChildNodes(document, document, map, transformOperation), }; diff --git a/packages/elements/src/utils/oas/types.ts b/packages/elements/src/utils/oas/types.ts index 8d22cc546..3a8a1802e 100644 --- a/packages/elements/src/utils/oas/types.ts +++ b/packages/elements/src/utils/oas/types.ts @@ -25,6 +25,7 @@ type Node = { name: string; data: D; tags: string[]; + tagsRaw?: { name?: string; description?: string }[]; }; export type ServiceNode = Node & { children: ServiceChildNode[] };