docusaurus-plugin-openapi-docs 0.0.0-420 → 0.0.0-421
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/openapi/openapi.js +11 -11
- package/lib/openapi/types.d.ts +1 -1
- package/lib/sidebars/index.js +5 -4
- package/package.json +2 -2
- package/src/openapi/openapi.ts +2 -6
- package/src/openapi/types.ts +1 -1
- package/src/sidebars/index.ts +5 -4
package/lib/openapi/openapi.js
CHANGED
|
@@ -59,7 +59,7 @@ async function createPostmanCollection(openapiData) {
|
|
|
59
59
|
return await jsonToCollection(data);
|
|
60
60
|
}
|
|
61
61
|
function createItems(openapiData, sidebarOptions) {
|
|
62
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p
|
|
62
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
63
63
|
// TODO: Find a better way to handle this
|
|
64
64
|
let items = [];
|
|
65
65
|
const infoId = (0, kebabCase_1.default)(openapiData.info.title);
|
|
@@ -100,8 +100,8 @@ function createItems(openapiData, sidebarOptions) {
|
|
|
100
100
|
securitySchemes: (_b = openapiData.components) === null || _b === void 0 ? void 0 : _b.securitySchemes,
|
|
101
101
|
info: {
|
|
102
102
|
...openapiData.info,
|
|
103
|
-
tags:
|
|
104
|
-
title: (
|
|
103
|
+
tags: openapiData.tags,
|
|
104
|
+
title: (_c = openapiData.info.title) !== null && _c !== void 0 ? _c : "Introduction",
|
|
105
105
|
logo: openapiData.info["x-logo"],
|
|
106
106
|
darkLogo: openapiData.info["x-dark-logo"],
|
|
107
107
|
},
|
|
@@ -111,18 +111,18 @@ function createItems(openapiData, sidebarOptions) {
|
|
|
111
111
|
for (let [path, pathObject] of Object.entries(openapiData.paths)) {
|
|
112
112
|
const { $ref, description, parameters, servers, summary, ...rest } = pathObject;
|
|
113
113
|
for (let [method, operationObject] of Object.entries({ ...rest })) {
|
|
114
|
-
const title = (
|
|
114
|
+
const title = (_e = (_d = operationObject.summary) !== null && _d !== void 0 ? _d : operationObject.operationId) !== null && _e !== void 0 ? _e : "Missing summary";
|
|
115
115
|
if (operationObject.description === undefined) {
|
|
116
116
|
operationObject.description =
|
|
117
|
-
(
|
|
117
|
+
(_g = (_f = operationObject.summary) !== null && _f !== void 0 ? _f : operationObject.operationId) !== null && _g !== void 0 ? _g : "";
|
|
118
118
|
}
|
|
119
119
|
const baseId = operationObject.operationId
|
|
120
120
|
? (0, kebabCase_1.default)(operationObject.operationId)
|
|
121
121
|
: (0, kebabCase_1.default)(operationObject.summary);
|
|
122
|
-
const servers = (
|
|
123
|
-
const security = (
|
|
122
|
+
const servers = (_j = (_h = operationObject.servers) !== null && _h !== void 0 ? _h : pathObject.servers) !== null && _j !== void 0 ? _j : openapiData.servers;
|
|
123
|
+
const security = (_k = operationObject.security) !== null && _k !== void 0 ? _k : openapiData.security;
|
|
124
124
|
// Add security schemes so we know how to handle security.
|
|
125
|
-
const securitySchemes = (
|
|
125
|
+
const securitySchemes = (_l = openapiData.components) === null || _l === void 0 ? void 0 : _l.securitySchemes;
|
|
126
126
|
// Make sure schemes are lowercase. See: https://github.com/cloud-annotations/docusaurus-plugin-openapi/issues/79
|
|
127
127
|
if (securitySchemes) {
|
|
128
128
|
for (let securityScheme of Object.values(securitySchemes)) {
|
|
@@ -132,12 +132,12 @@ function createItems(openapiData, sidebarOptions) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
let jsonRequestBodyExample;
|
|
135
|
-
const body = (
|
|
135
|
+
const body = (_o = (_m = operationObject.requestBody) === null || _m === void 0 ? void 0 : _m.content) === null || _o === void 0 ? void 0 : _o["application/json"];
|
|
136
136
|
if (body === null || body === void 0 ? void 0 : body.schema) {
|
|
137
137
|
jsonRequestBodyExample = (0, createExample_1.sampleFromSchema)(body.schema);
|
|
138
138
|
}
|
|
139
139
|
// Handle vendor JSON media types
|
|
140
|
-
const bodyContent = (
|
|
140
|
+
const bodyContent = (_p = operationObject.requestBody) === null || _p === void 0 ? void 0 : _p.content;
|
|
141
141
|
if (bodyContent) {
|
|
142
142
|
const firstBodyContentKey = Object.keys(bodyContent)[0];
|
|
143
143
|
if (firstBodyContentKey.endsWith("+json")) {
|
|
@@ -159,7 +159,7 @@ function createItems(openapiData, sidebarOptions) {
|
|
|
159
159
|
frontMatter: {},
|
|
160
160
|
api: {
|
|
161
161
|
...defaults,
|
|
162
|
-
tags:
|
|
162
|
+
tags: operationObject.tags,
|
|
163
163
|
method,
|
|
164
164
|
path,
|
|
165
165
|
servers,
|
package/lib/openapi/types.d.ts
CHANGED
package/lib/sidebars/index.js
CHANGED
|
@@ -36,9 +36,9 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
|
|
|
36
36
|
const operationTags = (0, uniq_1.default)(apiItems
|
|
37
37
|
.flatMap((item) => item.api.tags)
|
|
38
38
|
.filter((item) => !!item));
|
|
39
|
+
// Only include operation tags that are globally defined
|
|
39
40
|
const apiTags = [];
|
|
40
|
-
|
|
41
|
-
tags.map((tag) => {
|
|
41
|
+
tags.forEach((tag) => {
|
|
42
42
|
if (operationTags.includes(tag.name)) {
|
|
43
43
|
apiTags.push(tag.name);
|
|
44
44
|
}
|
|
@@ -73,11 +73,12 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
|
|
|
73
73
|
}
|
|
74
74
|
const tagged = apiTags
|
|
75
75
|
.map((tag) => {
|
|
76
|
+
var _a;
|
|
76
77
|
// Map info object to tag
|
|
77
78
|
const taggedInfoObject = intros.find((i) => i.tags ? i.tags.includes(tag) : undefined);
|
|
78
79
|
const tagObject = tags.flat().find((t) => {
|
|
79
80
|
var _a;
|
|
80
|
-
return (_a =
|
|
81
|
+
return (_a = tag === t.name) !== null && _a !== void 0 ? _a : {
|
|
81
82
|
name: tag,
|
|
82
83
|
description: `${tag} Index`,
|
|
83
84
|
};
|
|
@@ -112,7 +113,7 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
|
|
|
112
113
|
}
|
|
113
114
|
return {
|
|
114
115
|
type: "category",
|
|
115
|
-
label: tag,
|
|
116
|
+
label: (_a = tagObject === null || tagObject === void 0 ? void 0 : tagObject["x-displayName"]) !== null && _a !== void 0 ? _a : tag,
|
|
116
117
|
link: linkConfig,
|
|
117
118
|
collapsible: sidebarCollapsible,
|
|
118
119
|
collapsed: sidebarCollapsed,
|
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-421",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"engines": {
|
|
68
68
|
"node": ">=14"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "5ca3bcb461f9dad4a78d51fb7c3c59657528e24e"
|
|
71
71
|
}
|
package/src/openapi/openapi.ts
CHANGED
|
@@ -124,9 +124,7 @@ function createItems(
|
|
|
124
124
|
securitySchemes: openapiData.components?.securitySchemes,
|
|
125
125
|
info: {
|
|
126
126
|
...openapiData.info,
|
|
127
|
-
tags: openapiData.tags
|
|
128
|
-
getTagDisplayName(tagName.name!, openapiData.tags ?? [])
|
|
129
|
-
),
|
|
127
|
+
tags: openapiData.tags,
|
|
130
128
|
title: openapiData.info.title ?? "Introduction",
|
|
131
129
|
logo: openapiData.info["x-logo"]! as any,
|
|
132
130
|
darkLogo: openapiData.info["x-dark-logo"]! as any,
|
|
@@ -200,9 +198,7 @@ function createItems(
|
|
|
200
198
|
frontMatter: {},
|
|
201
199
|
api: {
|
|
202
200
|
...defaults,
|
|
203
|
-
tags: operationObject.tags
|
|
204
|
-
getTagDisplayName(tagName, openapiData.tags ?? [])
|
|
205
|
-
),
|
|
201
|
+
tags: operationObject.tags,
|
|
206
202
|
method,
|
|
207
203
|
path,
|
|
208
204
|
servers,
|
package/src/openapi/types.ts
CHANGED
package/src/sidebars/index.ts
CHANGED
|
@@ -65,9 +65,10 @@ function groupByTags(
|
|
|
65
65
|
.flatMap((item) => item.api.tags)
|
|
66
66
|
.filter((item): item is string => !!item)
|
|
67
67
|
);
|
|
68
|
+
|
|
69
|
+
// Only include operation tags that are globally defined
|
|
68
70
|
const apiTags: string[] = [];
|
|
69
|
-
|
|
70
|
-
tags.map((tag) => {
|
|
71
|
+
tags.forEach((tag) => {
|
|
71
72
|
if (operationTags.includes(tag.name!)) {
|
|
72
73
|
apiTags.push(tag.name!);
|
|
73
74
|
}
|
|
@@ -114,7 +115,7 @@ function groupByTags(
|
|
|
114
115
|
);
|
|
115
116
|
const tagObject = tags.flat().find(
|
|
116
117
|
(t) =>
|
|
117
|
-
|
|
118
|
+
tag === t.name ?? {
|
|
118
119
|
name: tag,
|
|
119
120
|
description: `${tag} Index`,
|
|
120
121
|
}
|
|
@@ -155,7 +156,7 @@ function groupByTags(
|
|
|
155
156
|
|
|
156
157
|
return {
|
|
157
158
|
type: "category" as const,
|
|
158
|
-
label: tag,
|
|
159
|
+
label: tagObject?.["x-displayName"] ?? tag,
|
|
159
160
|
link: linkConfig,
|
|
160
161
|
collapsible: sidebarCollapsible,
|
|
161
162
|
collapsed: sidebarCollapsed,
|