docusaurus-theme-openapi-docs 1.0.1 → 1.0.4
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/MethodEndpoint/index.js +9 -6
- package/lib/theme/ApiDemoPanel/SecuritySchemes/index.js +27 -4
- package/lib/theme/ApiDemoPanel/buildPostmanRequest.js +5 -2
- package/lib/theme/ApiDemoPanel/index.js +7 -13
- package/lib/theme/ApiItem/index.js +4 -3
- package/lib/theme/ApiItem/styles.module.css +23 -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/MethodEndpoint/index.js +9 -6
- package/lib-next/theme/ApiDemoPanel/SecuritySchemes/index.js +31 -4
- package/lib-next/theme/ApiDemoPanel/buildPostmanRequest.js +5 -2
- package/lib-next/theme/ApiDemoPanel/index.js +8 -15
- package/lib-next/theme/ApiItem/index.js +4 -13
- package/lib-next/theme/ApiItem/styles.module.css +23 -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 +6 -7
- 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/MethodEndpoint/index.tsx +6 -4
- package/src/theme/ApiDemoPanel/SecuritySchemes/index.tsx +32 -4
- package/src/theme/ApiDemoPanel/buildPostmanRequest.ts +5 -3
- package/src/theme/ApiDemoPanel/index.tsx +17 -17
- package/src/theme/ApiItem/index.tsx +11 -17
- package/src/theme/ApiItem/styles.module.css +23 -2
- package/{lib-next/theme/Tabs → src/theme/ApiTabs}/index.js +3 -3
- package/src/theme/{Tabs → ApiTabs}/styles.module.css +0 -0
- package/src/types.ts +112 -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
|
}) {
|
|
@@ -24,18 +24,21 @@ function colorForMethod(method) {
|
|
|
24
24
|
case "get":
|
|
25
25
|
return "primary";
|
|
26
26
|
|
|
27
|
-
case "put":
|
|
28
|
-
return "warning";
|
|
29
|
-
|
|
30
|
-
case "patch":
|
|
31
|
-
return "warning";
|
|
32
|
-
|
|
33
27
|
case "post":
|
|
34
28
|
return "success";
|
|
35
29
|
|
|
36
30
|
case "delete":
|
|
37
31
|
return "danger";
|
|
38
32
|
|
|
33
|
+
case "put":
|
|
34
|
+
return "info";
|
|
35
|
+
|
|
36
|
+
case "patch":
|
|
37
|
+
return "warning";
|
|
38
|
+
|
|
39
|
+
case "head":
|
|
40
|
+
return "secondary";
|
|
41
|
+
|
|
39
42
|
default:
|
|
40
43
|
return undefined;
|
|
41
44
|
}
|
|
@@ -7,6 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
+
var _Link = _interopRequireDefault(require("@docusaurus/Link"));
|
|
11
|
+
|
|
10
12
|
var _hooks = require("../hooks");
|
|
11
13
|
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -17,18 +19,25 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
17
19
|
* This source code is licensed under the MIT license found in the
|
|
18
20
|
* LICENSE file in the root directory of this source tree.
|
|
19
21
|
* ========================================================================== */
|
|
20
|
-
function SecuritySchemes() {
|
|
22
|
+
function SecuritySchemes(props) {
|
|
21
23
|
const options = (0, _hooks.useTypedSelector)(state => state.auth.options);
|
|
22
24
|
const selected = (0, _hooks.useTypedSelector)(state => state.auth.selected);
|
|
25
|
+
const infoAuthPath = `/${props.infoPath}#authentication`;
|
|
23
26
|
if (selected === undefined) return null;
|
|
24
27
|
const selectedAuth = options[selected];
|
|
25
28
|
return <div style={{
|
|
26
29
|
marginBottom: "var(--ifm-table-cell-padding)"
|
|
27
30
|
}}>
|
|
28
31
|
{selectedAuth.map(auth => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
const isApiKey = auth.type === "apiKey";
|
|
33
|
+
const isBearer = auth.type === "http" && auth.key === "Bearer";
|
|
34
|
+
const isClientCredentials = auth.type === "oauth2" && auth.key === "ClientCredentials";
|
|
35
|
+
|
|
36
|
+
if (isApiKey || isBearer) {
|
|
37
|
+
return <_react.default.Fragment key={selected}>
|
|
38
|
+
<b>
|
|
39
|
+
Authorization: <_Link.default to={infoAuthPath}>{auth.key}</_Link.default>
|
|
40
|
+
</b>
|
|
32
41
|
<pre style={{
|
|
33
42
|
display: "flex",
|
|
34
43
|
flexDirection: "column",
|
|
@@ -42,6 +51,20 @@ function SecuritySchemes() {
|
|
|
42
51
|
</_react.default.Fragment>;
|
|
43
52
|
}
|
|
44
53
|
|
|
54
|
+
if (isClientCredentials) {
|
|
55
|
+
return <_react.default.Fragment key={selected}>
|
|
56
|
+
<b>Authorization: {auth.key}</b>
|
|
57
|
+
<pre style={{
|
|
58
|
+
display: "flex",
|
|
59
|
+
flexDirection: "column",
|
|
60
|
+
background: "var(--openapi-card-background-color)",
|
|
61
|
+
borderRadius: "var(--openapi-card-border-radius)"
|
|
62
|
+
}}>
|
|
63
|
+
<span>type: {auth.type}</span>
|
|
64
|
+
</pre>
|
|
65
|
+
</_react.default.Fragment>;
|
|
66
|
+
}
|
|
67
|
+
|
|
45
68
|
return null;
|
|
46
69
|
})}
|
|
47
70
|
</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,10 +45,9 @@ 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
|
-
item
|
|
49
|
+
item,
|
|
50
|
+
infoPath
|
|
52
51
|
}) {
|
|
53
52
|
var _item$responses, _item$requestBody$con, _item$requestBody, _item$servers, _item$parameters, _xCodeSamples;
|
|
54
53
|
|
|
@@ -58,8 +57,7 @@ function ApiDemoPanel({
|
|
|
58
57
|
const themeConfig = siteConfig.themeConfig;
|
|
59
58
|
const options = themeConfig.api;
|
|
60
59
|
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 => {
|
|
60
|
+
const acceptArray = Array.from(new Set(Object.values((_item$responses = item.responses) !== null && _item$responses !== void 0 ? _item$responses : {}).map(response => {
|
|
63
61
|
var _response$content;
|
|
64
62
|
|
|
65
63
|
return Object.keys((_response$content = response.content) !== null && _response$content !== void 0 ? _response$content : {});
|
|
@@ -74,8 +72,9 @@ function ApiDemoPanel({
|
|
|
74
72
|
cookie: []
|
|
75
73
|
};
|
|
76
74
|
(_item$parameters = item.parameters) === null || _item$parameters === void 0 ? void 0 : _item$parameters.forEach(param => {
|
|
77
|
-
|
|
78
|
-
params[
|
|
75
|
+
const paramType = param.in;
|
|
76
|
+
const paramsArray = params[paramType];
|
|
77
|
+
paramsArray.push(param);
|
|
79
78
|
});
|
|
80
79
|
const auth = (0, _slice.createAuth)({
|
|
81
80
|
security: item.security,
|
|
@@ -112,19 +111,14 @@ function ApiDemoPanel({
|
|
|
112
111
|
return <_reactRedux.Provider store={store2}>
|
|
113
112
|
<div className={_stylesModule.default.apiDemoPanelContainer}>
|
|
114
113
|
<_MethodEndpoint.default method={method} path={path} />
|
|
115
|
-
|
|
116
|
-
<_SecuritySchemes.default />
|
|
117
|
-
|
|
114
|
+
<_SecuritySchemes.default infoPath={infoPath} />
|
|
118
115
|
<div className={_stylesModule.default.optionsPanel}>
|
|
119
116
|
<_ParamOptions.default />
|
|
120
117
|
<_Body.default jsonRequestBodyExample={item.jsonRequestBodyExample} requestBodyMetadata={item.requestBody} />
|
|
121
118
|
<_Accept.default />
|
|
122
119
|
</div>
|
|
123
|
-
|
|
124
120
|
<_Server.default />
|
|
125
|
-
|
|
126
121
|
<_Curl.default postman={postman} codeSamples={(_xCodeSamples = item["x-code-samples"]) !== null && _xCodeSamples !== void 0 ? _xCodeSamples : []} />
|
|
127
|
-
|
|
128
122
|
<_Response.default />
|
|
129
123
|
</div>
|
|
130
124
|
</_reactRedux.Provider>;
|
|
@@ -85,6 +85,7 @@ function DocItemContent(props) {
|
|
|
85
85
|
frontMatter
|
|
86
86
|
} = DocContent;
|
|
87
87
|
const {
|
|
88
|
+
info_path: infoPath,
|
|
88
89
|
hide_title: hideTitle,
|
|
89
90
|
hide_table_of_contents: hideTableOfContents,
|
|
90
91
|
toc_min_heading_level: tocMinHeadingLevel,
|
|
@@ -131,16 +132,16 @@ function DocItemContent(props) {
|
|
|
131
132
|
<DocContent />
|
|
132
133
|
</div>
|
|
133
134
|
{api && <div className="col col--5">
|
|
134
|
-
<ApiDemoPanel item={api} />
|
|
135
|
+
<ApiDemoPanel item={api} infoPath={infoPath} />
|
|
135
136
|
</div>}
|
|
136
137
|
</div>
|
|
137
138
|
</_MDXContent.default>
|
|
138
139
|
</div>
|
|
139
|
-
<div className={(0, _clsx.default)("col", api ? "col--7" :
|
|
140
|
+
<div className={(0, _clsx.default)("col", api ? "col--7" : "col--12")}>
|
|
140
141
|
<_DocItemFooter.default {...props} />
|
|
141
142
|
</div>
|
|
142
143
|
</article>
|
|
143
|
-
<div className={(0, _clsx.default)("col", api ? "col--7" :
|
|
144
|
+
<div className={(0, _clsx.default)("col", api ? "col--7" : "col--12")}>
|
|
144
145
|
<_DocPaginator.default previous={metadata.previous} next={metadata.next} />
|
|
145
146
|
</div>
|
|
146
147
|
</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,
|
|
@@ -7,6 +11,23 @@
|
|
|
7
11
|
margin-top: 0;
|
|
8
12
|
}
|
|
9
13
|
|
|
14
|
+
:global(.version-button div) {
|
|
15
|
+
display: block;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
:global(.version-button div > button > span::after) {
|
|
19
|
+
border-color: currentcolor transparent;
|
|
20
|
+
border-style: solid;
|
|
21
|
+
border-width: 0.4em 0.4em 0;
|
|
22
|
+
content: "";
|
|
23
|
+
margin-left: 0.3em;
|
|
24
|
+
position: relative;
|
|
25
|
+
transform: translateY(-50%);
|
|
26
|
+
display: inline-block;
|
|
27
|
+
font-size: 0.8rem;
|
|
28
|
+
top: 1px;
|
|
29
|
+
}
|
|
30
|
+
|
|
10
31
|
/* default markdown margins look really silly in a table */
|
|
11
32
|
:global(.theme-api-markdown table *:last-child) {
|
|
12
33
|
margin-bottom: 0;
|
|
@@ -75,9 +96,9 @@
|
|
|
75
96
|
font-size: 14px;
|
|
76
97
|
}
|
|
77
98
|
|
|
78
|
-
:global(.theme-api-markdown h2) {
|
|
99
|
+
/* :global(.theme-api-markdown h2) {
|
|
79
100
|
font-size: 2rem;
|
|
80
|
-
}
|
|
101
|
+
} */
|
|
81
102
|
|
|
82
103
|
:global(.schemaItem) {
|
|
83
104
|
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";
|
|
@@ -14,18 +14,21 @@ function colorForMethod(method) {
|
|
|
14
14
|
case "get":
|
|
15
15
|
return "primary";
|
|
16
16
|
|
|
17
|
-
case "put":
|
|
18
|
-
return "warning";
|
|
19
|
-
|
|
20
|
-
case "patch":
|
|
21
|
-
return "warning";
|
|
22
|
-
|
|
23
17
|
case "post":
|
|
24
18
|
return "success";
|
|
25
19
|
|
|
26
20
|
case "delete":
|
|
27
21
|
return "danger";
|
|
28
22
|
|
|
23
|
+
case "put":
|
|
24
|
+
return "info";
|
|
25
|
+
|
|
26
|
+
case "patch":
|
|
27
|
+
return "warning";
|
|
28
|
+
|
|
29
|
+
case "head":
|
|
30
|
+
return "secondary";
|
|
31
|
+
|
|
29
32
|
default:
|
|
30
33
|
return undefined;
|
|
31
34
|
}
|
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
import React from "react";
|
|
8
|
+
import Link from "@docusaurus/Link";
|
|
8
9
|
import { useTypedSelector } from "../hooks";
|
|
9
10
|
|
|
10
|
-
function SecuritySchemes() {
|
|
11
|
+
function SecuritySchemes(props) {
|
|
11
12
|
const options = useTypedSelector((state) => state.auth.options);
|
|
12
13
|
const selected = useTypedSelector((state) => state.auth.selected);
|
|
14
|
+
const infoAuthPath = `/${props.infoPath}#authentication`;
|
|
13
15
|
if (selected === undefined) return null;
|
|
14
16
|
const selectedAuth = options[selected];
|
|
15
17
|
return (
|
|
@@ -19,10 +21,17 @@ function SecuritySchemes() {
|
|
|
19
21
|
}}
|
|
20
22
|
>
|
|
21
23
|
{selectedAuth.map((auth) => {
|
|
22
|
-
|
|
24
|
+
const isApiKey = auth.type === "apiKey";
|
|
25
|
+
const isBearer = auth.type === "http" && auth.key === "Bearer";
|
|
26
|
+
const isClientCredentials =
|
|
27
|
+
auth.type === "oauth2" && auth.key === "ClientCredentials";
|
|
28
|
+
|
|
29
|
+
if (isApiKey || isBearer) {
|
|
23
30
|
return (
|
|
24
|
-
<React.Fragment key={selected
|
|
25
|
-
<b>
|
|
31
|
+
<React.Fragment key={selected}>
|
|
32
|
+
<b>
|
|
33
|
+
Authorization: <Link to={infoAuthPath}>{auth.key}</Link>
|
|
34
|
+
</b>
|
|
26
35
|
<pre
|
|
27
36
|
style={{
|
|
28
37
|
display: "flex",
|
|
@@ -39,6 +48,24 @@ function SecuritySchemes() {
|
|
|
39
48
|
);
|
|
40
49
|
}
|
|
41
50
|
|
|
51
|
+
if (isClientCredentials) {
|
|
52
|
+
return (
|
|
53
|
+
<React.Fragment key={selected}>
|
|
54
|
+
<b>Authorization: {auth.key}</b>
|
|
55
|
+
<pre
|
|
56
|
+
style={{
|
|
57
|
+
display: "flex",
|
|
58
|
+
flexDirection: "column",
|
|
59
|
+
background: "var(--openapi-card-background-color)",
|
|
60
|
+
borderRadius: "var(--openapi-card-border-radius)",
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
<span>type: {auth.type}</span>
|
|
64
|
+
</pre>
|
|
65
|
+
</React.Fragment>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
42
69
|
return null;
|
|
43
70
|
})}
|
|
44
71
|
</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";
|
|
@@ -24,14 +21,14 @@ import Server from "./Server";
|
|
|
24
21
|
import { createStoreWithState } from "./store";
|
|
25
22
|
import styles from "./styles.module.css";
|
|
26
23
|
|
|
27
|
-
function ApiDemoPanel({ item }) {
|
|
24
|
+
function ApiDemoPanel({ item, infoPath }) {
|
|
28
25
|
const { siteConfig } = useDocusaurusContext();
|
|
29
26
|
const themeConfig = siteConfig.themeConfig;
|
|
30
27
|
const options = themeConfig.api;
|
|
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,
|
|
@@ -85,9 +83,7 @@ function ApiDemoPanel({ item }) {
|
|
|
85
83
|
<Provider store={store2}>
|
|
86
84
|
<div className={styles.apiDemoPanelContainer}>
|
|
87
85
|
<MethodEndpoint method={method} path={path} />
|
|
88
|
-
|
|
89
|
-
<SecuritySchemes />
|
|
90
|
-
|
|
86
|
+
<SecuritySchemes infoPath={infoPath} />
|
|
91
87
|
<div className={styles.optionsPanel}>
|
|
92
88
|
<ParamOptions />
|
|
93
89
|
<Body
|
|
@@ -96,11 +92,8 @@ function ApiDemoPanel({ item }) {
|
|
|
96
92
|
/>
|
|
97
93
|
<Accept />
|
|
98
94
|
</div>
|
|
99
|
-
|
|
100
95
|
<Server />
|
|
101
|
-
|
|
102
96
|
<Curl postman={postman} codeSamples={item["x-code-samples"] ?? []} />
|
|
103
|
-
|
|
104
97
|
<Response />
|
|
105
98
|
</div>
|
|
106
99
|
</Provider>
|
|
@@ -58,6 +58,7 @@ function DocItemContent(props) {
|
|
|
58
58
|
const { content: DocContent } = props;
|
|
59
59
|
const { metadata, frontMatter } = DocContent;
|
|
60
60
|
const {
|
|
61
|
+
info_path: infoPath,
|
|
61
62
|
hide_title: hideTitle,
|
|
62
63
|
hide_table_of_contents: hideTableOfContents,
|
|
63
64
|
toc_min_heading_level: tocMinHeadingLevel,
|
|
@@ -121,27 +122,17 @@ function DocItemContent(props) {
|
|
|
121
122
|
</div>
|
|
122
123
|
{api && (
|
|
123
124
|
<div className="col col--5">
|
|
124
|
-
<ApiDemoPanel item={api} />
|
|
125
|
+
<ApiDemoPanel item={api} infoPath={infoPath} />
|
|
125
126
|
</div>
|
|
126
127
|
)}
|
|
127
128
|
</div>
|
|
128
129
|
</MDXContent>
|
|
129
130
|
</div>
|
|
130
|
-
<div
|
|
131
|
-
className={clsx(
|
|
132
|
-
"col",
|
|
133
|
-
api ? "col--7" : !canRenderTOC ? "col--9" : "col--12"
|
|
134
|
-
)}
|
|
135
|
-
>
|
|
131
|
+
<div className={clsx("col", api ? "col--7" : "col--12")}>
|
|
136
132
|
<DocItemFooter {...props} />
|
|
137
133
|
</div>
|
|
138
134
|
</article>
|
|
139
|
-
<div
|
|
140
|
-
className={clsx(
|
|
141
|
-
"col",
|
|
142
|
-
api ? "col--7" : !canRenderTOC ? "col--9" : "col--12"
|
|
143
|
-
)}
|
|
144
|
-
>
|
|
135
|
+
<div className={clsx("col", api ? "col--7" : "col--12")}>
|
|
145
136
|
<DocPaginator previous={metadata.previous} next={metadata.next} />
|
|
146
137
|
</div>
|
|
147
138
|
</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,
|
|
@@ -7,6 +11,23 @@
|
|
|
7
11
|
margin-top: 0;
|
|
8
12
|
}
|
|
9
13
|
|
|
14
|
+
:global(.version-button div) {
|
|
15
|
+
display: block;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
:global(.version-button div > button > span::after) {
|
|
19
|
+
border-color: currentcolor transparent;
|
|
20
|
+
border-style: solid;
|
|
21
|
+
border-width: 0.4em 0.4em 0;
|
|
22
|
+
content: "";
|
|
23
|
+
margin-left: 0.3em;
|
|
24
|
+
position: relative;
|
|
25
|
+
transform: translateY(-50%);
|
|
26
|
+
display: inline-block;
|
|
27
|
+
font-size: 0.8rem;
|
|
28
|
+
top: 1px;
|
|
29
|
+
}
|
|
30
|
+
|
|
10
31
|
/* default markdown margins look really silly in a table */
|
|
11
32
|
:global(.theme-api-markdown table *:last-child) {
|
|
12
33
|
margin-bottom: 0;
|
|
@@ -75,9 +96,9 @@
|
|
|
75
96
|
font-size: 14px;
|
|
76
97
|
}
|
|
77
98
|
|
|
78
|
-
:global(.theme-api-markdown h2) {
|
|
99
|
+
/* :global(.theme-api-markdown h2) {
|
|
79
100
|
font-size: 2rem;
|
|
80
|
-
}
|
|
101
|
+
} */
|
|
81
102
|
|
|
82
103
|
:global(.schemaItem) {
|
|
83
104
|
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
|