docusaurus-plugin-openapi-docs 1.1.3 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,7 +37,7 @@ function groupByTags(
37
37
  items: ApiPageMetadata[],
38
38
  sidebarOptions: SidebarOptions,
39
39
  options: APIOptions,
40
- tags: TagObject[],
40
+ tags: TagObject[][],
41
41
  docPath: string
42
42
  ): ProcessedSidebar {
43
43
  const { outputDir, label } = options;
@@ -60,12 +60,20 @@ function groupByTags(
60
60
  });
61
61
 
62
62
  // TODO: make sure we only take the first tag
63
- const apiTags = uniq(
63
+ const operationTags = uniq(
64
64
  apiItems
65
65
  .flatMap((item) => item.api.tags)
66
66
  .filter((item): item is string => !!item)
67
67
  );
68
68
 
69
+ // Only include operation tags that are globally defined
70
+ const apiTags: string[] = [];
71
+ tags.flat().forEach((tag) => {
72
+ if (operationTags.includes(tag.name!)) {
73
+ apiTags.push(tag.name!);
74
+ }
75
+ });
76
+
69
77
  const basePath = docPath
70
78
  ? outputDir.split(docPath!)[1].replace(/^\/+/g, "")
71
79
  : outputDir.slice(outputDir.indexOf("/", 1)).replace(/^\/+/g, "");
@@ -107,7 +115,7 @@ function groupByTags(
107
115
  );
108
116
  const tagObject = tags.flat().find(
109
117
  (t) =>
110
- (tag === t.name || tag === t["x-displayName"]) ?? {
118
+ tag === t.name ?? {
111
119
  name: tag,
112
120
  description: `${tag} Index`,
113
121
  }
@@ -148,7 +156,7 @@ function groupByTags(
148
156
 
149
157
  return {
150
158
  type: "category" as const,
151
- label: tag,
159
+ label: tagObject?.["x-displayName"] ?? tag,
152
160
  link: linkConfig,
153
161
  collapsible: sidebarCollapsible,
154
162
  collapsed: sidebarCollapsed,
@@ -191,7 +199,7 @@ export default function generateSidebarSlice(
191
199
  sidebarOptions: SidebarOptions,
192
200
  options: APIOptions,
193
201
  api: ApiMetadata[],
194
- tags: TagObject[],
202
+ tags: TagObject[][],
195
203
  docPath: string
196
204
  ) {
197
205
  let sidebarSlice: ProcessedSidebar = [];