Skip to content

Commit da7af83

Browse files
committed
feat(elements): show tags description if exist
1 parent be11c9a commit da7af83

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

packages/elements/src/components/API/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ export function computeTagGroups<T extends GroupableNode>(serviceNode: ServiceNo
3030
groupsByTagId[tagId].items.push(node);
3131
} else {
3232
const serviceTagIndex = lowerCaseServiceTags.findIndex(tn => tn === tagId);
33-
const serviceTagName = serviceNode.tags[serviceTagIndex];
33+
const serviceTag = serviceNode.tagsRaw?.[serviceTagIndex];
3434
groupsByTagId[tagId] = {
35-
title: serviceTagName || tagName,
35+
title: serviceTag?.description || serviceTag?.name || tagName,
3636
items: [node],
3737
};
3838
}

packages/elements/src/utils/oas/__tests__/oas.spec.ts

+20
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ describe('computeOasNodes', () => {
9494
infoExtensions: {},
9595
},
9696
tags: ['operation-tag', 'model-tag'],
97+
tagsRaw: [
98+
{
99+
id: '68c460dd9e97a',
100+
name: 'operation-tag',
101+
},
102+
{
103+
id: 'feec8b579ae6b',
104+
name: 'model-tag',
105+
},
106+
],
97107
children: [
98108
{
99109
type: 'http_operation',
@@ -171,6 +181,16 @@ describe('computeOasNodes', () => {
171181
version: '1.0.0',
172182
},
173183
tags: ['operation-tag', 'model-tag'],
184+
tagsRaw: [
185+
{
186+
id: '68c460dd9e97a',
187+
name: 'operation-tag',
188+
},
189+
{
190+
id: 'feec8b579ae6b',
191+
name: 'model-tag',
192+
},
193+
],
174194
children: [
175195
{
176196
type: 'http_operation',

packages/elements/src/utils/oas/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ function computeServiceNode(
7373
name: serviceDocument.name,
7474
data: serviceDocument,
7575
tags: serviceDocument.tags?.map(tag => tag.name) || [],
76+
tagsRaw: serviceDocument.tags,
7677
children: computeChildNodes(document, document, map, transformOperation),
7778
};
7879

packages/elements/src/utils/oas/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type Node<T, D> = {
2525
name: string;
2626
data: D;
2727
tags: string[];
28+
tagsRaw?: { name?: string; description?: string }[];
2829
};
2930

3031
export type ServiceNode = Node<NodeType.HttpService, IHttpService> & { children: ServiceChildNode[] };

0 commit comments

Comments
 (0)