docusaurus-theme-openapi-docs 1.0.1 → 1.0.2
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/postman-code-generators.d.ts +9 -0
- package/lib/react-magic-dropzone.d.ts +9 -0
- package/lib/theme/ApiDemoPanel/Curl/index.js +0 -1
- package/lib/theme/ApiDemoPanel/FormFileUpload/index.js +0 -1
- package/lib/theme/ApiDemoPanel/SecuritySchemes/index.js +21 -3
- package/lib/theme/ApiDemoPanel/buildPostmanRequest.js +5 -2
- package/lib/theme/ApiDemoPanel/index.js +4 -6
- package/lib/theme/ApiItem/index.js +2 -2
- package/lib/theme/ApiItem/styles.module.css +6 -2
- package/lib/theme/{Tabs → ApiTabs}/index.js +3 -3
- package/lib/theme/{Tabs → ApiTabs}/styles.module.css +0 -0
- package/lib-next/postman-code-generators.d.ts +9 -0
- package/lib-next/react-magic-dropzone.d.ts +9 -0
- package/lib-next/theme/ApiDemoPanel/Curl/index.js +2 -4
- package/lib-next/theme/ApiDemoPanel/FormFileUpload/index.js +1 -2
- package/lib-next/theme/ApiDemoPanel/SecuritySchemes/index.js +26 -3
- package/lib-next/theme/ApiDemoPanel/buildPostmanRequest.js +5 -2
- package/lib-next/theme/ApiDemoPanel/index.js +6 -8
- package/lib-next/theme/ApiItem/index.js +2 -12
- package/lib-next/theme/ApiItem/styles.module.css +6 -2
- package/{src/theme/Tabs → lib-next/theme/ApiTabs}/index.js +3 -3
- package/lib-next/theme/{Tabs → ApiTabs}/styles.module.css +0 -0
- package/package.json +3 -4
- package/src/postman-code-generators.d.ts +9 -0
- package/src/react-magic-dropzone.d.ts +9 -0
- package/src/theme/ApiDemoPanel/Curl/index.tsx +0 -2
- package/src/theme/ApiDemoPanel/FormFileUpload/index.tsx +0 -1
- package/src/theme/ApiDemoPanel/SecuritySchemes/index.tsx +26 -3
- package/src/theme/ApiDemoPanel/buildPostmanRequest.ts +5 -3
- package/src/theme/ApiDemoPanel/index.tsx +10 -11
- package/src/theme/ApiItem/index.tsx +2 -12
- package/src/theme/ApiItem/styles.module.css +6 -2
- package/{lib-next/theme/Tabs → src/theme/ApiTabs}/index.js +3 -3
- package/src/theme/{Tabs → ApiTabs}/styles.module.css +0 -0
- package/lib/theme/ApiDemoPanel/Authorization/index.js +0 -174
- package/lib/theme/ApiDemoPanel/Execute/index.js +0 -85
- package/lib/theme/ApiDemoPanel/Execute/makeRequest.js +0 -202
- package/lib-next/theme/ApiDemoPanel/Authorization/index.js +0 -203
- package/lib-next/theme/ApiDemoPanel/Execute/index.js +0 -74
- package/lib-next/theme/ApiDemoPanel/Execute/makeRequest.js +0 -183
- package/src/theme/ApiDemoPanel/Authorization/index.tsx +0 -211
- package/src/theme/ApiDemoPanel/Execute/index.tsx +0 -88
- package/src/theme/ApiDemoPanel/Execute/makeRequest.ts +0 -184
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
// TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
|
|
9
|
+
declare module "@paloaltonetworks/postman-code-generators";
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
// TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
|
|
9
|
+
declare module "react-magic-dropzone";
|
|
@@ -35,7 +35,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
35
35
|
* This source code is licensed under the MIT license found in the
|
|
36
36
|
* LICENSE file in the root directory of this source tree.
|
|
37
37
|
* ========================================================================== */
|
|
38
|
-
// @ts-ignore
|
|
39
38
|
const languageSet = [{
|
|
40
39
|
tabName: "cURL",
|
|
41
40
|
highlight: "bash",
|
|
@@ -25,7 +25,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
25
25
|
* This source code is licensed under the MIT license found in the
|
|
26
26
|
* LICENSE file in the root directory of this source tree.
|
|
27
27
|
* ========================================================================== */
|
|
28
|
-
// @ts-ignore
|
|
29
28
|
function RenderPreview({
|
|
30
29
|
file
|
|
31
30
|
}) {
|
|
@@ -26,9 +26,13 @@ function SecuritySchemes() {
|
|
|
26
26
|
marginBottom: "var(--ifm-table-cell-padding)"
|
|
27
27
|
}}>
|
|
28
28
|
{selectedAuth.map(auth => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
const isApiKey = auth.type === "apiKey";
|
|
30
|
+
const isBearer = auth.type === "http" && auth.key === "Bearer";
|
|
31
|
+
const isClientCredentials = auth.type === "oauth2" && auth.key === "ClientCredentials";
|
|
32
|
+
|
|
33
|
+
if (isApiKey || isBearer) {
|
|
34
|
+
return <_react.default.Fragment key={selected}>
|
|
35
|
+
<b>Authorization: {auth.key}</b>
|
|
32
36
|
<pre style={{
|
|
33
37
|
display: "flex",
|
|
34
38
|
flexDirection: "column",
|
|
@@ -42,6 +46,20 @@ function SecuritySchemes() {
|
|
|
42
46
|
</_react.default.Fragment>;
|
|
43
47
|
}
|
|
44
48
|
|
|
49
|
+
if (isClientCredentials) {
|
|
50
|
+
return <_react.default.Fragment key={selected}>
|
|
51
|
+
<b>Authorization: {auth.key}</b>
|
|
52
|
+
<pre style={{
|
|
53
|
+
display: "flex",
|
|
54
|
+
flexDirection: "column",
|
|
55
|
+
background: "var(--openapi-card-background-color)",
|
|
56
|
+
borderRadius: "var(--openapi-card-border-radius)"
|
|
57
|
+
}}>
|
|
58
|
+
<span>type: {auth.type}</span>
|
|
59
|
+
</pre>
|
|
60
|
+
</_react.default.Fragment>;
|
|
61
|
+
}
|
|
62
|
+
|
|
45
63
|
return null;
|
|
46
64
|
})}
|
|
47
65
|
</div>;
|
|
@@ -17,7 +17,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
17
17
|
* This source code is licensed under the MIT license found in the
|
|
18
18
|
* LICENSE file in the root directory of this source tree.
|
|
19
19
|
* ========================================================================== */
|
|
20
|
-
// @ts-ignore
|
|
21
20
|
function setQueryParams(postman, queryParams) {
|
|
22
21
|
postman.url.query.clear();
|
|
23
22
|
const qp = queryParams.map(param => {
|
|
@@ -270,6 +269,10 @@ function buildPostmanRequest(postman, {
|
|
|
270
269
|
} = auth.data[a.key];
|
|
271
270
|
|
|
272
271
|
if (token === undefined) {
|
|
272
|
+
otherHeaders.push({
|
|
273
|
+
key: "Authorization",
|
|
274
|
+
value: "Bearer <TOKEN>"
|
|
275
|
+
});
|
|
273
276
|
continue;
|
|
274
277
|
}
|
|
275
278
|
|
|
@@ -307,7 +310,7 @@ function buildPostmanRequest(postman, {
|
|
|
307
310
|
if (apikey === undefined) {
|
|
308
311
|
otherHeaders.push({
|
|
309
312
|
key: a.name,
|
|
310
|
-
value: "API_KEY_VALUE"
|
|
313
|
+
value: "<API_KEY_VALUE>"
|
|
311
314
|
});
|
|
312
315
|
continue;
|
|
313
316
|
}
|
|
@@ -45,8 +45,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
45
45
|
* This source code is licensed under the MIT license found in the
|
|
46
46
|
* LICENSE file in the root directory of this source tree.
|
|
47
47
|
* ========================================================================== */
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
// @ts-ignore
|
|
50
48
|
function ApiDemoPanel({
|
|
51
49
|
item
|
|
52
50
|
}) {
|
|
@@ -58,8 +56,7 @@ function ApiDemoPanel({
|
|
|
58
56
|
const themeConfig = siteConfig.themeConfig;
|
|
59
57
|
const options = themeConfig.api;
|
|
60
58
|
const postman = new _postmanCollection.default.Request(item.postman);
|
|
61
|
-
const acceptArray = Array.from(new Set(Object.values((_item$responses = item.responses) !== null && _item$responses !== void 0 ? _item$responses : {})
|
|
62
|
-
.map(response => {
|
|
59
|
+
const acceptArray = Array.from(new Set(Object.values((_item$responses = item.responses) !== null && _item$responses !== void 0 ? _item$responses : {}).map(response => {
|
|
63
60
|
var _response$content;
|
|
64
61
|
|
|
65
62
|
return Object.keys((_response$content = response.content) !== null && _response$content !== void 0 ? _response$content : {});
|
|
@@ -74,8 +71,9 @@ function ApiDemoPanel({
|
|
|
74
71
|
cookie: []
|
|
75
72
|
};
|
|
76
73
|
(_item$parameters = item.parameters) === null || _item$parameters === void 0 ? void 0 : _item$parameters.forEach(param => {
|
|
77
|
-
|
|
78
|
-
params[
|
|
74
|
+
const paramType = param.in;
|
|
75
|
+
const paramsArray = params[paramType];
|
|
76
|
+
paramsArray.push(param);
|
|
79
77
|
});
|
|
80
78
|
const auth = (0, _slice.createAuth)({
|
|
81
79
|
security: item.security,
|
|
@@ -136,11 +136,11 @@ function DocItemContent(props) {
|
|
|
136
136
|
</div>
|
|
137
137
|
</_MDXContent.default>
|
|
138
138
|
</div>
|
|
139
|
-
<div className={(0, _clsx.default)("col", api ? "col--7" :
|
|
139
|
+
<div className={(0, _clsx.default)("col", api ? "col--7" : "col--12")}>
|
|
140
140
|
<_DocItemFooter.default {...props} />
|
|
141
141
|
</div>
|
|
142
142
|
</article>
|
|
143
|
-
<div className={(0, _clsx.default)("col", api ? "col--7" :
|
|
143
|
+
<div className={(0, _clsx.default)("col", api ? "col--7" : "col--12")}>
|
|
144
144
|
<_DocPaginator.default previous={metadata.previous} next={metadata.next} />
|
|
145
145
|
</div>
|
|
146
146
|
</div>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--openapi-required: var(--ifm-color-danger);
|
|
3
|
+
--openapi-code-blue: var(--ifm-color-info);
|
|
4
|
+
--openapi-code-red: var(--ifm-color-danger);
|
|
5
|
+
--openapi-code-orange: var(--ifm-color-warning);
|
|
6
|
+
--openapi-code-green: var(--ifm-color-success);
|
|
3
7
|
}
|
|
4
8
|
|
|
5
9
|
.apiItemContainer article > *:first-child,
|
|
@@ -75,9 +79,9 @@
|
|
|
75
79
|
font-size: 14px;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
:global(.theme-api-markdown h2) {
|
|
82
|
+
/* :global(.theme-api-markdown h2) {
|
|
79
83
|
font-size: 2rem;
|
|
80
|
-
}
|
|
84
|
+
} */
|
|
81
85
|
|
|
82
86
|
:global(.schemaItem) {
|
|
83
87
|
list-style: none;
|
|
@@ -29,7 +29,7 @@ function isTabItem(comp) {
|
|
|
29
29
|
return typeof comp.props.value !== "undefined";
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
function ApiTabsComponent(props) {
|
|
33
33
|
const {
|
|
34
34
|
lazy,
|
|
35
35
|
block,
|
|
@@ -246,10 +246,10 @@ function ResponseCodeTabs(props) {
|
|
|
246
246
|
);
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
export default function
|
|
249
|
+
export default function ApiTabs(props) {
|
|
250
250
|
const isBrowser = useIsBrowser();
|
|
251
251
|
return (
|
|
252
|
-
<
|
|
252
|
+
<ApiTabsComponent // Remount tabs after hydration
|
|
253
253
|
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
254
254
|
key={String(isBrowser)}
|
|
255
255
|
{...props}
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
// TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
|
|
9
|
+
declare module "@paloaltonetworks/postman-code-generators";
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
// TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
|
|
9
|
+
declare module "react-magic-dropzone";
|
|
@@ -5,10 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
import React, { useRef, useState, useEffect } from "react";
|
|
8
|
-
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
9
|
-
|
|
10
|
-
import codegen from "@paloaltonetworks/postman-code-generators"; // @ts-ignore
|
|
11
|
-
|
|
8
|
+
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
9
|
+
import codegen from "@paloaltonetworks/postman-code-generators";
|
|
12
10
|
import clsx from "clsx";
|
|
13
11
|
import Highlight, { defaultProps } from "prism-react-renderer";
|
|
14
12
|
import { useTypedSelector } from "../hooks";
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
|
-
import React, { useState } from "react";
|
|
8
|
-
|
|
7
|
+
import React, { useState } from "react";
|
|
9
8
|
import MagicDropzone from "react-magic-dropzone";
|
|
10
9
|
import FloatingButton from "../FloatingButton";
|
|
11
10
|
import styles from "./styles.module.css";
|
|
@@ -19,10 +19,15 @@ function SecuritySchemes() {
|
|
|
19
19
|
}}
|
|
20
20
|
>
|
|
21
21
|
{selectedAuth.map((auth) => {
|
|
22
|
-
|
|
22
|
+
const isApiKey = auth.type === "apiKey";
|
|
23
|
+
const isBearer = auth.type === "http" && auth.key === "Bearer";
|
|
24
|
+
const isClientCredentials =
|
|
25
|
+
auth.type === "oauth2" && auth.key === "ClientCredentials";
|
|
26
|
+
|
|
27
|
+
if (isApiKey || isBearer) {
|
|
23
28
|
return (
|
|
24
|
-
<React.Fragment key={selected
|
|
25
|
-
<b>Authorization: {auth.
|
|
29
|
+
<React.Fragment key={selected}>
|
|
30
|
+
<b>Authorization: {auth.key}</b>
|
|
26
31
|
<pre
|
|
27
32
|
style={{
|
|
28
33
|
display: "flex",
|
|
@@ -39,6 +44,24 @@ function SecuritySchemes() {
|
|
|
39
44
|
);
|
|
40
45
|
}
|
|
41
46
|
|
|
47
|
+
if (isClientCredentials) {
|
|
48
|
+
return (
|
|
49
|
+
<React.Fragment key={selected}>
|
|
50
|
+
<b>Authorization: {auth.key}</b>
|
|
51
|
+
<pre
|
|
52
|
+
style={{
|
|
53
|
+
display: "flex",
|
|
54
|
+
flexDirection: "column",
|
|
55
|
+
background: "var(--openapi-card-background-color)",
|
|
56
|
+
borderRadius: "var(--openapi-card-border-radius)",
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
<span>type: {auth.type}</span>
|
|
60
|
+
</pre>
|
|
61
|
+
</React.Fragment>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
42
65
|
return null;
|
|
43
66
|
})}
|
|
44
67
|
</div>
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
import sdk from "@paloaltonetworks/postman-collection";
|
|
8
|
-
// @ts-ignore
|
|
9
8
|
import cloneDeep from "lodash/cloneDeep";
|
|
10
9
|
|
|
11
10
|
function setQueryParams(postman, queryParams) {
|
|
@@ -252,6 +251,10 @@ function buildPostmanRequest(
|
|
|
252
251
|
const { token } = auth.data[a.key];
|
|
253
252
|
|
|
254
253
|
if (token === undefined) {
|
|
254
|
+
otherHeaders.push({
|
|
255
|
+
key: "Authorization",
|
|
256
|
+
value: "Bearer <TOKEN>",
|
|
257
|
+
});
|
|
255
258
|
continue;
|
|
256
259
|
}
|
|
257
260
|
|
|
@@ -282,7 +285,7 @@ function buildPostmanRequest(
|
|
|
282
285
|
if (apikey === undefined) {
|
|
283
286
|
otherHeaders.push({
|
|
284
287
|
key: a.name,
|
|
285
|
-
value: "API_KEY_VALUE",
|
|
288
|
+
value: "<API_KEY_VALUE>",
|
|
286
289
|
});
|
|
287
290
|
continue;
|
|
288
291
|
}
|
|
@@ -5,11 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
import React from "react";
|
|
8
|
-
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import sdk from "@paloaltonetworks/postman-collection"; // @ts-ignore
|
|
12
|
-
|
|
8
|
+
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
9
|
+
import sdk from "@paloaltonetworks/postman-collection";
|
|
13
10
|
import { Provider } from "react-redux";
|
|
14
11
|
import Accept from "./Accept";
|
|
15
12
|
import { createAuth } from "./Authorization/slice";
|
|
@@ -31,7 +28,7 @@ function ApiDemoPanel({ item }) {
|
|
|
31
28
|
const postman = new sdk.Request(item.postman);
|
|
32
29
|
const acceptArray = Array.from(
|
|
33
30
|
new Set(
|
|
34
|
-
Object.values(item.responses ?? {})
|
|
31
|
+
Object.values(item.responses ?? {})
|
|
35
32
|
.map((response) => Object.keys(response.content ?? {}))
|
|
36
33
|
.flat()
|
|
37
34
|
)
|
|
@@ -46,8 +43,9 @@ function ApiDemoPanel({ item }) {
|
|
|
46
43
|
cookie: [],
|
|
47
44
|
};
|
|
48
45
|
item.parameters?.forEach((param) => {
|
|
49
|
-
|
|
50
|
-
params[
|
|
46
|
+
const paramType = param.in;
|
|
47
|
+
const paramsArray = params[paramType];
|
|
48
|
+
paramsArray.push(param);
|
|
51
49
|
});
|
|
52
50
|
const auth = createAuth({
|
|
53
51
|
security: item.security,
|
|
@@ -127,21 +127,11 @@ function DocItemContent(props) {
|
|
|
127
127
|
</div>
|
|
128
128
|
</MDXContent>
|
|
129
129
|
</div>
|
|
130
|
-
<div
|
|
131
|
-
className={clsx(
|
|
132
|
-
"col",
|
|
133
|
-
api ? "col--7" : !canRenderTOC ? "col--9" : "col--12"
|
|
134
|
-
)}
|
|
135
|
-
>
|
|
130
|
+
<div className={clsx("col", api ? "col--7" : "col--12")}>
|
|
136
131
|
<DocItemFooter {...props} />
|
|
137
132
|
</div>
|
|
138
133
|
</article>
|
|
139
|
-
<div
|
|
140
|
-
className={clsx(
|
|
141
|
-
"col",
|
|
142
|
-
api ? "col--7" : !canRenderTOC ? "col--9" : "col--12"
|
|
143
|
-
)}
|
|
144
|
-
>
|
|
134
|
+
<div className={clsx("col", api ? "col--7" : "col--12")}>
|
|
145
135
|
<DocPaginator previous={metadata.previous} next={metadata.next} />
|
|
146
136
|
</div>
|
|
147
137
|
</div>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--openapi-required: var(--ifm-color-danger);
|
|
3
|
+
--openapi-code-blue: var(--ifm-color-info);
|
|
4
|
+
--openapi-code-red: var(--ifm-color-danger);
|
|
5
|
+
--openapi-code-orange: var(--ifm-color-warning);
|
|
6
|
+
--openapi-code-green: var(--ifm-color-success);
|
|
3
7
|
}
|
|
4
8
|
|
|
5
9
|
.apiItemContainer article > *:first-child,
|
|
@@ -75,9 +79,9 @@
|
|
|
75
79
|
font-size: 14px;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
:global(.theme-api-markdown h2) {
|
|
82
|
+
/* :global(.theme-api-markdown h2) {
|
|
79
83
|
font-size: 2rem;
|
|
80
|
-
}
|
|
84
|
+
} */
|
|
81
85
|
|
|
82
86
|
:global(.schemaItem) {
|
|
83
87
|
list-style: none;
|
|
@@ -29,7 +29,7 @@ function isTabItem(comp) {
|
|
|
29
29
|
return typeof comp.props.value !== "undefined";
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
function ApiTabsComponent(props) {
|
|
33
33
|
const {
|
|
34
34
|
lazy,
|
|
35
35
|
block,
|
|
@@ -246,10 +246,10 @@ function ResponseCodeTabs(props) {
|
|
|
246
246
|
);
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
export default function
|
|
249
|
+
export default function ApiTabs(props) {
|
|
250
250
|
const isBrowser = useIsBrowser();
|
|
251
251
|
return (
|
|
252
|
-
<
|
|
252
|
+
<ApiTabsComponent // Remount tabs after hydration
|
|
253
253
|
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
254
254
|
key={String(isBrowser)}
|
|
255
255
|
{...props}
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-theme-openapi-docs",
|
|
3
3
|
"description": "OpenAPI theme for Docusaurus.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"@types/fs-extra": "^9.0.13",
|
|
39
39
|
"@types/lodash": "^4.14.176",
|
|
40
40
|
"@types/mdx-js__react": "^1.5.4",
|
|
41
|
-
"@types/postman-collection": "^3.5.7",
|
|
42
41
|
"@types/rtlcss": "^3.1.1",
|
|
43
42
|
"concurrently": "^5.2.0"
|
|
44
43
|
},
|
|
@@ -52,7 +51,7 @@
|
|
|
52
51
|
"buffer": "^6.0.3",
|
|
53
52
|
"clsx": "^1.1.1",
|
|
54
53
|
"crypto-js": "^4.1.1",
|
|
55
|
-
"docusaurus-plugin-openapi-docs": "^1.0.
|
|
54
|
+
"docusaurus-plugin-openapi-docs": "^1.0.2",
|
|
56
55
|
"immer": "^9.0.7",
|
|
57
56
|
"lodash": "^4.17.20",
|
|
58
57
|
"monaco-editor": "^0.31.1",
|
|
@@ -71,5 +70,5 @@
|
|
|
71
70
|
"engines": {
|
|
72
71
|
"node": ">=14"
|
|
73
72
|
},
|
|
74
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "526f2d10bc187bc7095ac70d5b1453b9b92c114f"
|
|
75
74
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
// TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
|
|
9
|
+
declare module "@paloaltonetworks/postman-code-generators";
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
// TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
|
|
9
|
+
declare module "react-magic-dropzone";
|
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
import React, { useRef, useState, useEffect } from "react";
|
|
9
9
|
|
|
10
10
|
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
11
|
-
// @ts-ignore
|
|
12
11
|
import codegen from "@paloaltonetworks/postman-code-generators";
|
|
13
|
-
// @ts-ignore
|
|
14
12
|
import sdk from "@paloaltonetworks/postman-collection";
|
|
15
13
|
import clsx from "clsx";
|
|
16
14
|
import Highlight, { defaultProps } from "prism-react-renderer";
|
|
@@ -20,10 +20,15 @@ function SecuritySchemes() {
|
|
|
20
20
|
return (
|
|
21
21
|
<div style={{ marginBottom: "var(--ifm-table-cell-padding)" }}>
|
|
22
22
|
{selectedAuth.map((auth) => {
|
|
23
|
-
|
|
23
|
+
const isApiKey = auth.type === "apiKey";
|
|
24
|
+
const isBearer = auth.type === "http" && auth.key === "Bearer";
|
|
25
|
+
const isClientCredentials =
|
|
26
|
+
auth.type === "oauth2" && auth.key === "ClientCredentials";
|
|
27
|
+
|
|
28
|
+
if (isApiKey || isBearer) {
|
|
24
29
|
return (
|
|
25
|
-
<React.Fragment key={selected
|
|
26
|
-
<b>Authorization: {auth.
|
|
30
|
+
<React.Fragment key={selected}>
|
|
31
|
+
<b>Authorization: {auth.key}</b>
|
|
27
32
|
<pre
|
|
28
33
|
style={{
|
|
29
34
|
display: "flex",
|
|
@@ -40,6 +45,24 @@ function SecuritySchemes() {
|
|
|
40
45
|
);
|
|
41
46
|
}
|
|
42
47
|
|
|
48
|
+
if (isClientCredentials) {
|
|
49
|
+
return (
|
|
50
|
+
<React.Fragment key={selected}>
|
|
51
|
+
<b>Authorization: {auth.key}</b>
|
|
52
|
+
<pre
|
|
53
|
+
style={{
|
|
54
|
+
display: "flex",
|
|
55
|
+
flexDirection: "column",
|
|
56
|
+
background: "var(--openapi-card-background-color)",
|
|
57
|
+
borderRadius: "var(--openapi-card-border-radius)",
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
<span>type: {auth.type}</span>
|
|
61
|
+
</pre>
|
|
62
|
+
</React.Fragment>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
43
66
|
return null;
|
|
44
67
|
})}
|
|
45
68
|
</div>
|
|
@@ -9,9 +9,7 @@ import sdk from "@paloaltonetworks/postman-collection";
|
|
|
9
9
|
import {
|
|
10
10
|
ParameterObject,
|
|
11
11
|
ServerObject,
|
|
12
|
-
// @ts-ignore
|
|
13
12
|
} from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
14
|
-
// @ts-ignore
|
|
15
13
|
import cloneDeep from "lodash/cloneDeep";
|
|
16
14
|
|
|
17
15
|
import { AuthState, Scheme } from "./Authorization/slice";
|
|
@@ -250,6 +248,10 @@ function buildPostmanRequest(
|
|
|
250
248
|
if (a.type === "http" && a.scheme === "bearer") {
|
|
251
249
|
const { token } = auth.data[a.key];
|
|
252
250
|
if (token === undefined) {
|
|
251
|
+
otherHeaders.push({
|
|
252
|
+
key: "Authorization",
|
|
253
|
+
value: "Bearer <TOKEN>",
|
|
254
|
+
});
|
|
253
255
|
continue;
|
|
254
256
|
}
|
|
255
257
|
otherHeaders.push({
|
|
@@ -278,7 +280,7 @@ function buildPostmanRequest(
|
|
|
278
280
|
if (apikey === undefined) {
|
|
279
281
|
otherHeaders.push({
|
|
280
282
|
key: a.name,
|
|
281
|
-
value: "API_KEY_VALUE",
|
|
283
|
+
value: "<API_KEY_VALUE>",
|
|
282
284
|
});
|
|
283
285
|
continue;
|
|
284
286
|
}
|
|
@@ -8,12 +8,9 @@
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
10
|
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
// @ts-ignore
|
|
13
11
|
import sdk from "@paloaltonetworks/postman-collection";
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
import { Metadata } from "@theme/ApiItem";
|
|
16
12
|
import { ParameterObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
13
|
+
import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
17
14
|
import { Provider } from "react-redux";
|
|
18
15
|
|
|
19
16
|
import { ThemeConfig } from "../../types";
|
|
@@ -30,7 +27,7 @@ import Server from "./Server";
|
|
|
30
27
|
import { createStoreWithState } from "./store";
|
|
31
28
|
import styles from "./styles.module.css";
|
|
32
29
|
|
|
33
|
-
function ApiDemoPanel({ item }: { item: NonNullable<
|
|
30
|
+
function ApiDemoPanel({ item }: { item: NonNullable<ApiItem> }) {
|
|
34
31
|
const { siteConfig } = useDocusaurusContext();
|
|
35
32
|
const themeConfig = siteConfig.themeConfig as ThemeConfig;
|
|
36
33
|
const options = themeConfig.api;
|
|
@@ -39,8 +36,7 @@ function ApiDemoPanel({ item }: { item: NonNullable<Metadata["api"]> }) {
|
|
|
39
36
|
const acceptArray = Array.from(
|
|
40
37
|
new Set(
|
|
41
38
|
Object.values(item.responses ?? {})
|
|
42
|
-
|
|
43
|
-
.map((response) => Object.keys(response.content ?? {}))
|
|
39
|
+
.map((response: any) => Object.keys(response.content ?? {}))
|
|
44
40
|
.flat()
|
|
45
41
|
)
|
|
46
42
|
);
|
|
@@ -58,10 +54,13 @@ function ApiDemoPanel({ item }: { item: NonNullable<Metadata["api"]> }) {
|
|
|
58
54
|
cookie: [] as ParameterObject[],
|
|
59
55
|
};
|
|
60
56
|
|
|
61
|
-
item.parameters?.forEach(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
item.parameters?.forEach(
|
|
58
|
+
(param: { in: "path" | "query" | "header" | "cookie" }) => {
|
|
59
|
+
const paramType = param.in;
|
|
60
|
+
const paramsArray: ParameterObject[] = params[paramType];
|
|
61
|
+
paramsArray.push(param as ParameterObject);
|
|
62
|
+
}
|
|
63
|
+
);
|
|
65
64
|
|
|
66
65
|
const auth = createAuth({
|
|
67
66
|
security: item.security,
|
|
@@ -127,21 +127,11 @@ function DocItemContent(props: Props): JSX.Element {
|
|
|
127
127
|
</div>
|
|
128
128
|
</MDXContent>
|
|
129
129
|
</div>
|
|
130
|
-
<div
|
|
131
|
-
className={clsx(
|
|
132
|
-
"col",
|
|
133
|
-
api ? "col--7" : !canRenderTOC ? "col--9" : "col--12"
|
|
134
|
-
)}
|
|
135
|
-
>
|
|
130
|
+
<div className={clsx("col", api ? "col--7" : "col--12")}>
|
|
136
131
|
<DocItemFooter {...props} />
|
|
137
132
|
</div>
|
|
138
133
|
</article>
|
|
139
|
-
<div
|
|
140
|
-
className={clsx(
|
|
141
|
-
"col",
|
|
142
|
-
api ? "col--7" : !canRenderTOC ? "col--9" : "col--12"
|
|
143
|
-
)}
|
|
144
|
-
>
|
|
134
|
+
<div className={clsx("col", api ? "col--7" : "col--12")}>
|
|
145
135
|
<DocPaginator previous={metadata.previous} next={metadata.next} />
|
|
146
136
|
</div>
|
|
147
137
|
</div>
|