docusaurus-plugin-openapi-docs 0.0.0-728 → 0.0.0-730
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.
- package/lib/sidebars/index.js +15 -1
- package/package.json +2 -2
- package/src/sidebars/index.ts +21 -3
package/lib/sidebars/index.js
CHANGED
|
@@ -55,7 +55,9 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
|
|
|
55
55
|
apiTags.push(tag.name);
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
|
-
|
|
58
|
+
if (sidebarOptions.groupPathsBy !== "tagGroup") {
|
|
59
|
+
apiTags = (0, uniq_1.default)(apiTags.concat(operationTags, schemaTags));
|
|
60
|
+
}
|
|
59
61
|
const basePath = docPath
|
|
60
62
|
? outputDir.split(docPath)[1].replace(/^\/+/g, "")
|
|
61
63
|
: outputDir.slice(outputDir.indexOf("/", 1)).replace(/^\/+/g, "");
|
|
@@ -183,7 +185,9 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
|
|
|
183
185
|
function generateSidebarSlice(sidebarOptions, options, api, tags, docPath, tagGroups) {
|
|
184
186
|
let sidebarSlice = [];
|
|
185
187
|
if (sidebarOptions.groupPathsBy === "tagGroup") {
|
|
188
|
+
let schemasGroup = [];
|
|
186
189
|
tagGroups === null || tagGroups === void 0 ? void 0 : tagGroups.forEach((tagGroup) => {
|
|
190
|
+
var _a;
|
|
187
191
|
//filter tags only included in group
|
|
188
192
|
const filteredTags = [];
|
|
189
193
|
tags[0].forEach((tag) => {
|
|
@@ -198,8 +202,18 @@ function generateSidebarSlice(sidebarOptions, options, api, tags, docPath, tagGr
|
|
|
198
202
|
collapsed: true,
|
|
199
203
|
items: groupByTags(api, sidebarOptions, options, [filteredTags], docPath),
|
|
200
204
|
};
|
|
205
|
+
if (options.showSchemas) {
|
|
206
|
+
// For the first tagGroup, save the generated "Schemas" category for later.
|
|
207
|
+
if (schemasGroup.length === 0) {
|
|
208
|
+
schemasGroup = (_a = groupCategory.items) === null || _a === void 0 ? void 0 : _a.filter((item) => item.type === "category" && item.label === "Schemas");
|
|
209
|
+
}
|
|
210
|
+
// Remove the "Schemas" category from every `groupCategory`.
|
|
211
|
+
groupCategory.items = groupCategory.items.filter((item) => "label" in item ? item.label !== "Schemas" : true);
|
|
212
|
+
}
|
|
201
213
|
sidebarSlice.push(groupCategory);
|
|
202
214
|
});
|
|
215
|
+
// Add `schemasGroup` to the end of the sidebar.
|
|
216
|
+
sidebarSlice.push(...schemasGroup);
|
|
203
217
|
}
|
|
204
218
|
else if (sidebarOptions.groupPathsBy === "tag") {
|
|
205
219
|
sidebarSlice = groupByTags(api, sidebarOptions, options, tags, docPath);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-openapi-docs",
|
|
3
3
|
"description": "OpenAPI plugin for Docusaurus.",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-730",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=14"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "1d2eebcb4ad197684fb266157e22188b1b57c288"
|
|
64
64
|
}
|
package/src/sidebars/index.ts
CHANGED
|
@@ -93,7 +93,10 @@ function groupByTags(
|
|
|
93
93
|
apiTags.push(tag.name!);
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
|
-
|
|
96
|
+
|
|
97
|
+
if (sidebarOptions.groupPathsBy !== "tagGroup") {
|
|
98
|
+
apiTags = uniq(apiTags.concat(operationTags, schemaTags));
|
|
99
|
+
}
|
|
97
100
|
|
|
98
101
|
const basePath = docPath
|
|
99
102
|
? outputDir.split(docPath!)[1].replace(/^\/+/g, "")
|
|
@@ -264,6 +267,7 @@ export default function generateSidebarSlice(
|
|
|
264
267
|
let sidebarSlice: ProcessedSidebar = [];
|
|
265
268
|
|
|
266
269
|
if (sidebarOptions.groupPathsBy === "tagGroup") {
|
|
270
|
+
let schemasGroup: ProcessedSidebar = [];
|
|
267
271
|
tagGroups?.forEach((tagGroup) => {
|
|
268
272
|
//filter tags only included in group
|
|
269
273
|
const filteredTags: TagObject[] = [];
|
|
@@ -285,10 +289,24 @@ export default function generateSidebarSlice(
|
|
|
285
289
|
[filteredTags],
|
|
286
290
|
docPath
|
|
287
291
|
),
|
|
288
|
-
}
|
|
292
|
+
};
|
|
289
293
|
|
|
290
|
-
|
|
294
|
+
if (options.showSchemas) {
|
|
295
|
+
// For the first tagGroup, save the generated "Schemas" category for later.
|
|
296
|
+
if (schemasGroup.length === 0) {
|
|
297
|
+
schemasGroup = groupCategory.items?.filter(
|
|
298
|
+
(item) => item.type === "category" && item.label === "Schemas"
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
// Remove the "Schemas" category from every `groupCategory`.
|
|
302
|
+
groupCategory.items = groupCategory.items.filter((item) =>
|
|
303
|
+
"label" in item ? item.label !== "Schemas" : true
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
sidebarSlice.push(groupCategory as ProcessedSidebarItem);
|
|
291
307
|
});
|
|
308
|
+
// Add `schemasGroup` to the end of the sidebar.
|
|
309
|
+
sidebarSlice.push(...schemasGroup);
|
|
292
310
|
} else if (sidebarOptions.groupPathsBy === "tag") {
|
|
293
311
|
sidebarSlice = groupByTags(api, sidebarOptions, options, tags, docPath);
|
|
294
312
|
}
|