Skip to content

Commit

Permalink
feat(elements): show tags description if exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Airkro committed Jul 8, 2024
1 parent 663a0d1 commit c9ced5f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/elements/src/components/API/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export function computeTagGroups<T extends GroupableNode>(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],
};
}
Expand Down
20 changes: 20 additions & 0 deletions packages/elements/src/utils/oas/__tests__/oas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions packages/elements/src/utils/oas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function computeServiceNode(
name: serviceDocument.name,
data: serviceDocument,
tags: serviceDocument.tags?.map(tag => tag.name) || [],
tagsRaw: serviceDocument.tags,
children: computeChildNodes(document, document, map, transformOperation),
};

Expand Down
1 change: 1 addition & 0 deletions packages/elements/src/utils/oas/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Node<T, D> = {
name: string;
data: D;
tags: string[];
tagsRaw?: { name?: string; description?: string }[];
};

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

0 comments on commit c9ced5f

Please sign in to comment.