docusaurus-plugin-openapi-docs 1.5.1 → 1.6.0
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/index.js +5 -0
- package/lib/markdown/createArrayBracket.d.ts +2 -0
- package/lib/markdown/createArrayBracket.js +37 -0
- package/lib/markdown/createAuthentication.js +45 -13
- package/lib/markdown/createRequestSchema.js +133 -91
- package/lib/markdown/createResponseSchema.js +140 -95
- package/lib/markdown/createStatusCodes.js +7 -7
- package/lib/markdown/index.js +1 -1
- package/lib/openapi/createRequestExample.js +27 -8
- package/lib/openapi/createResponseExample.js +27 -8
- package/lib/openapi/openapi.js +7 -1
- package/lib/openapi/utils/loadAndResolveSpec.js +13 -0
- package/lib/options.js +1 -0
- package/lib/sidebars/index.js +3 -1
- package/lib/types.d.ts +1 -0
- package/package.json +8 -8
- package/src/index.ts +6 -0
- package/src/markdown/createArrayBracket.ts +35 -0
- package/src/markdown/createAuthentication.ts +53 -17
- package/src/markdown/createRequestSchema.ts +208 -107
- package/src/markdown/createResponseSchema.ts +228 -119
- package/src/markdown/createStatusCodes.ts +42 -47
- package/src/markdown/index.ts +1 -1
- package/src/openapi/createRequestExample.ts +36 -13
- package/src/openapi/createResponseExample.ts +36 -13
- package/src/openapi/openapi.ts +7 -1
- package/src/openapi/utils/loadAndResolveSpec.ts +15 -0
- package/src/options.ts +1 -0
- package/src/sidebars/index.ts +6 -1
- package/src/types.ts +1 -0
package/lib/sidebars/index.js
CHANGED
|
@@ -21,7 +21,9 @@ function isInfoItem(item) {
|
|
|
21
21
|
return item.type === "info";
|
|
22
22
|
}
|
|
23
23
|
function groupByTags(items, sidebarOptions, options, tags, docPath) {
|
|
24
|
-
|
|
24
|
+
let { outputDir, label } = options;
|
|
25
|
+
// Remove trailing slash before proceeding
|
|
26
|
+
outputDir = outputDir.replace(/\/$/, "");
|
|
25
27
|
const { sidebarCollapsed, sidebarCollapsible, customProps, categoryLinkSource, } = sidebarOptions;
|
|
26
28
|
const apiItems = items.filter(isApiItem);
|
|
27
29
|
const infoItems = items.filter(isInfoItem);
|
package/lib/types.d.ts
CHANGED
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": "1.
|
|
4
|
+
"version": "1.6.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"watch": "tsc --watch"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@docusaurus/module-type-aliases": "
|
|
32
|
-
"@docusaurus/types": "
|
|
31
|
+
"@docusaurus/module-type-aliases": ">=2.0.1 <2.3.0",
|
|
32
|
+
"@docusaurus/types": ">=2.0.1 <2.3.0",
|
|
33
33
|
"@types/fs-extra": "^9.0.13",
|
|
34
34
|
"@types/js-yaml": "^4.0.5",
|
|
35
35
|
"@types/json-pointer": "^1.0.31",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@apidevtools/json-schema-ref-parser": "^9.0.9",
|
|
43
|
-
"@docusaurus/mdx-loader": "
|
|
44
|
-
"@docusaurus/plugin-content-docs": "
|
|
45
|
-
"@docusaurus/utils": "
|
|
46
|
-
"@docusaurus/utils-validation": "
|
|
43
|
+
"@docusaurus/mdx-loader": ">=2.0.1 <2.3.0",
|
|
44
|
+
"@docusaurus/plugin-content-docs": ">=2.0.1 <2.3.0",
|
|
45
|
+
"@docusaurus/utils": ">=2.0.1 <2.3.0",
|
|
46
|
+
"@docusaurus/utils-validation": ">=2.0.1 <2.3.0",
|
|
47
47
|
"@paloaltonetworks/openapi-to-postmanv2": "3.1.0-hotfix.1",
|
|
48
48
|
"@paloaltonetworks/postman-collection": "^4.1.0",
|
|
49
49
|
"@redocly/openapi-core": "^1.0.0-beta.103",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "937e6543af8c1575877a0ebe7c5732e5cffaa37d"
|
|
72
72
|
}
|
package/src/index.ts
CHANGED
|
@@ -94,6 +94,9 @@ export default function pluginOpenAPIDocs(
|
|
|
94
94
|
let { specPath, outputDir, template, downloadUrl, sidebarOptions } =
|
|
95
95
|
options;
|
|
96
96
|
|
|
97
|
+
// Remove trailing slash before proceeding
|
|
98
|
+
outputDir = outputDir.replace(/\/$/, "");
|
|
99
|
+
|
|
97
100
|
// Override docPath if pluginId provided
|
|
98
101
|
if (pluginId) {
|
|
99
102
|
docData = getDocsPluginConfig(presetsPlugins, pluginId);
|
|
@@ -187,6 +190,9 @@ custom_edit_url: null
|
|
|
187
190
|
{{#frontMatter.proxy}}
|
|
188
191
|
proxy: {{{frontMatter.proxy}}}
|
|
189
192
|
{{/frontMatter.proxy}}
|
|
193
|
+
{{#frontMatter.hide_send_button}}
|
|
194
|
+
hide_send_button: true
|
|
195
|
+
{{/frontMatter.hide_send_button}}
|
|
190
196
|
---
|
|
191
197
|
|
|
192
198
|
{{{markdown}}}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import { create } from "./utils";
|
|
9
|
+
|
|
10
|
+
export function createOpeningArrayBracket() {
|
|
11
|
+
return create("li", {
|
|
12
|
+
children: create("div", {
|
|
13
|
+
style: {
|
|
14
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
15
|
+
opacity: "0.6",
|
|
16
|
+
marginLeft: "-.5rem",
|
|
17
|
+
paddingBottom: ".5rem",
|
|
18
|
+
},
|
|
19
|
+
children: ["Array ["],
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function createClosingArrayBracket() {
|
|
25
|
+
return create("li", {
|
|
26
|
+
children: create("div", {
|
|
27
|
+
style: {
|
|
28
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
29
|
+
opacity: "0.6",
|
|
30
|
+
marginLeft: "-.5rem",
|
|
31
|
+
},
|
|
32
|
+
children: ["]"],
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -13,7 +13,8 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
13
13
|
if (!securitySchemes || !Object.keys(securitySchemes).length) return "";
|
|
14
14
|
|
|
15
15
|
const createAuthenticationTable = (securityScheme: any) => {
|
|
16
|
-
const { bearerFormat, flows, name, scheme, type } =
|
|
16
|
+
const { bearerFormat, flows, name, scheme, type, openIdConnectUrl } =
|
|
17
|
+
securityScheme;
|
|
17
18
|
|
|
18
19
|
const createSecuritySchemeTypeRow = () =>
|
|
19
20
|
create("tr", {
|
|
@@ -30,7 +31,7 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
30
31
|
|
|
31
32
|
return create("tr", {
|
|
32
33
|
children: [
|
|
33
|
-
create("th", { children:
|
|
34
|
+
create("th", { children: `OAuth Flow (${flowType}):` }),
|
|
34
35
|
create("td", {
|
|
35
36
|
children: [
|
|
36
37
|
guard(tokenUrl, () =>
|
|
@@ -91,12 +92,14 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
91
92
|
create("td", { children: scheme }),
|
|
92
93
|
],
|
|
93
94
|
}),
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
guard(bearerFormat, () =>
|
|
96
|
+
create("tr", {
|
|
97
|
+
children: [
|
|
98
|
+
create("th", { children: "Bearer format:" }),
|
|
99
|
+
create("td", { children: bearerFormat }),
|
|
100
|
+
],
|
|
101
|
+
})
|
|
102
|
+
),
|
|
100
103
|
],
|
|
101
104
|
}),
|
|
102
105
|
}),
|
|
@@ -115,23 +118,51 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
115
118
|
}),
|
|
116
119
|
],
|
|
117
120
|
});
|
|
121
|
+
case "openIdConnect":
|
|
122
|
+
return create("div", {
|
|
123
|
+
children: [
|
|
124
|
+
create("table", {
|
|
125
|
+
children: create("tbody", {
|
|
126
|
+
children: [
|
|
127
|
+
createSecuritySchemeTypeRow(),
|
|
128
|
+
guard(openIdConnectUrl, () =>
|
|
129
|
+
create("tr", {
|
|
130
|
+
children: [
|
|
131
|
+
create("th", { children: "OpenID Connect URL:" }),
|
|
132
|
+
create("td", { children: openIdConnectUrl }),
|
|
133
|
+
],
|
|
134
|
+
})
|
|
135
|
+
),
|
|
136
|
+
],
|
|
137
|
+
}),
|
|
138
|
+
}),
|
|
139
|
+
],
|
|
140
|
+
});
|
|
118
141
|
default:
|
|
119
142
|
return "";
|
|
120
143
|
}
|
|
121
144
|
};
|
|
122
145
|
|
|
123
|
-
const formatTabLabel = (
|
|
124
|
-
const formattedLabel =
|
|
146
|
+
const formatTabLabel = (key: string, type: string, scheme: string) => {
|
|
147
|
+
const formattedLabel = key
|
|
125
148
|
.replace(/(_|-)/g, " ")
|
|
126
149
|
.trim()
|
|
127
150
|
.replace(/\w\S*/g, (str) => str.charAt(0).toUpperCase() + str.substr(1))
|
|
128
151
|
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
|
129
152
|
.replace(/([A-Z])([A-Z][a-z])/g, "$1 $2");
|
|
153
|
+
const isOAuth = type === "oauth2";
|
|
154
|
+
const isApiKey = type === "apiKey";
|
|
155
|
+
const isHttpBasic = type === "http" && scheme === "basic";
|
|
156
|
+
const isHttpBearer = type === "http" && scheme === "bearer";
|
|
157
|
+
const isOpenId = type === "openIdConnect";
|
|
130
158
|
|
|
131
|
-
|
|
132
|
-
|
|
159
|
+
if (isOAuth) return `OAuth 2.0: ${key}`;
|
|
160
|
+
if (isApiKey) return `API Key: ${key}`;
|
|
161
|
+
if (isHttpBasic) return "HTTP: Basic Auth";
|
|
162
|
+
if (isHttpBearer) return "HTTP: Bearer Auth";
|
|
163
|
+
if (isOpenId) return `OpenID Connect: ${key}`;
|
|
133
164
|
|
|
134
|
-
return
|
|
165
|
+
return formattedLabel;
|
|
135
166
|
};
|
|
136
167
|
|
|
137
168
|
return create("div", {
|
|
@@ -141,12 +172,17 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
141
172
|
id: "authentication",
|
|
142
173
|
style: { marginBottom: "1rem" },
|
|
143
174
|
}),
|
|
144
|
-
create("
|
|
175
|
+
create("SchemaTabs", {
|
|
176
|
+
className: "openapi-tabs__security-schemes",
|
|
145
177
|
children: Object.entries(securitySchemes).map(
|
|
146
|
-
([
|
|
178
|
+
([schemeKey, schemeObj]) =>
|
|
147
179
|
create("TabItem", {
|
|
148
|
-
label: formatTabLabel(
|
|
149
|
-
|
|
180
|
+
label: formatTabLabel(
|
|
181
|
+
schemeKey,
|
|
182
|
+
schemeObj.type,
|
|
183
|
+
schemeObj.scheme
|
|
184
|
+
),
|
|
185
|
+
value: `${schemeKey}`,
|
|
150
186
|
children: [
|
|
151
187
|
createDescription(schemeObj.description),
|
|
152
188
|
createAuthenticationTable(schemeObj),
|