docusaurus-theme-openapi-docs 1.0.3 → 1.0.6
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/theme/ApiDemoPanel/Body/index.js +11 -9
- package/lib/theme/ApiDemoPanel/Body/json2xml.js +43 -0
- package/lib/theme/ApiDemoPanel/CodeTabs/index.js +188 -0
- package/lib/theme/ApiDemoPanel/CodeTabs/styles.module.css +11 -0
- package/lib/theme/ApiDemoPanel/Curl/index.js +41 -110
- package/lib/theme/ApiDemoPanel/LiveEditor/index.js +61 -0
- package/lib/theme/ApiDemoPanel/LiveEditor/styles.module.css +34 -0
- package/lib/theme/ApiItem/icons/bash-original.svg +1 -0
- package/lib/theme/ApiItem/icons/go-original-wordmark.svg +1 -0
- package/lib/theme/ApiItem/icons/javascript-original.svg +1 -0
- package/lib/theme/ApiItem/icons/linux-original.svg +1 -0
- package/lib/theme/ApiItem/icons/python-original.svg +1 -0
- package/lib/theme/ApiItem/styles.module.css +89 -0
- package/lib-next/theme/ApiDemoPanel/Body/index.js +11 -15
- package/lib-next/theme/ApiDemoPanel/Body/json2xml.js +43 -0
- package/lib-next/theme/ApiDemoPanel/CodeTabs/index.js +214 -0
- package/lib-next/theme/ApiDemoPanel/CodeTabs/styles.module.css +11 -0
- package/lib-next/theme/ApiDemoPanel/Curl/index.js +46 -135
- package/lib-next/theme/ApiDemoPanel/LiveEditor/index.js +49 -0
- package/lib-next/theme/ApiDemoPanel/LiveEditor/styles.module.css +34 -0
- package/lib-next/theme/ApiItem/icons/bash-original.svg +1 -0
- package/lib-next/theme/ApiItem/icons/go-original-wordmark.svg +1 -0
- package/lib-next/theme/ApiItem/icons/javascript-original.svg +1 -0
- package/lib-next/theme/ApiItem/icons/linux-original.svg +1 -0
- package/lib-next/theme/ApiItem/icons/python-original.svg +1 -0
- package/lib-next/theme/ApiItem/styles.module.css +89 -0
- package/package.json +4 -6
- package/src/theme/ApiDemoPanel/Body/index.tsx +9 -13
- package/src/theme/ApiDemoPanel/Body/json2xml.js +43 -0
- package/src/theme/ApiDemoPanel/CodeTabs/index.tsx +237 -0
- package/src/theme/ApiDemoPanel/CodeTabs/styles.module.css +11 -0
- package/src/theme/ApiDemoPanel/Curl/index.tsx +45 -124
- package/src/theme/ApiDemoPanel/LiveEditor/index.tsx +59 -0
- package/src/theme/ApiDemoPanel/LiveEditor/styles.module.css +34 -0
- package/src/theme/ApiItem/icons/bash-original.svg +1 -0
- package/src/theme/ApiItem/icons/go-original-wordmark.svg +1 -0
- package/src/theme/ApiItem/icons/javascript-original.svg +1 -0
- package/src/theme/ApiItem/icons/linux-original.svg +1 -0
- package/src/theme/ApiItem/icons/python-original.svg +1 -0
- package/src/theme/ApiItem/styles.module.css +89 -0
- package/lib/theme/ApiDemoPanel/VSCode/index.js +0 -252
- package/lib/theme/ApiDemoPanel/VSCode/styles.module.css +0 -19
- package/lib-next/theme/ApiDemoPanel/VSCode/index.js +0 -265
- package/lib-next/theme/ApiDemoPanel/VSCode/styles.module.css +0 -19
- package/src/theme/ApiDemoPanel/VSCode/index.tsx +0 -205
- package/src/theme/ApiDemoPanel/VSCode/styles.module.css +0 -19
|
@@ -13,13 +13,15 @@ var _FormSelect = _interopRequireDefault(require("../FormSelect"));
|
|
|
13
13
|
|
|
14
14
|
var _hooks = require("../hooks");
|
|
15
15
|
|
|
16
|
+
var _LiveEditor = _interopRequireDefault(require("../LiveEditor"));
|
|
17
|
+
|
|
16
18
|
var _FormFileUpload = _interopRequireDefault(require("./../FormFileUpload"));
|
|
17
19
|
|
|
18
20
|
var _FormItem = _interopRequireDefault(require("./../FormItem"));
|
|
19
21
|
|
|
20
22
|
var _FormTextInput = _interopRequireDefault(require("./../FormTextInput"));
|
|
21
23
|
|
|
22
|
-
var
|
|
24
|
+
var _json2xml = _interopRequireDefault(require("./json2xml"));
|
|
23
25
|
|
|
24
26
|
var _slice = require("./slice");
|
|
25
27
|
|
|
@@ -31,6 +33,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
31
33
|
* This source code is licensed under the MIT license found in the
|
|
32
34
|
* LICENSE file in the root directory of this source tree.
|
|
33
35
|
* ========================================================================== */
|
|
36
|
+
// @ts-ignore
|
|
34
37
|
function BodyWrap({
|
|
35
38
|
requestBodyMetadata,
|
|
36
39
|
jsonRequestBodyExample
|
|
@@ -166,18 +169,17 @@ function Body({
|
|
|
166
169
|
}
|
|
167
170
|
|
|
168
171
|
if (contentType === "application/xml") {
|
|
172
|
+
if (jsonRequestBodyExample) {
|
|
173
|
+
exampleBodyString = (0, _json2xml.default)(jsonRequestBodyExample);
|
|
174
|
+
}
|
|
175
|
+
|
|
169
176
|
language = "xml";
|
|
170
177
|
}
|
|
171
178
|
|
|
172
179
|
return <_FormItem.default label="Body">
|
|
173
|
-
<
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
dispatch((0, _slice.setStringRawBody)(value));
|
|
180
|
-
}} />
|
|
180
|
+
<_LiveEditor.default action={dispatch} language={language}>
|
|
181
|
+
{exampleBodyString}
|
|
182
|
+
</_LiveEditor.default>
|
|
181
183
|
</_FormItem.default>;
|
|
182
184
|
}
|
|
183
185
|
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
export default function json2xml(o, tab) {
|
|
9
|
+
var toXml = function (v, name, ind) {
|
|
10
|
+
var xml = "";
|
|
11
|
+
if (v instanceof Array) {
|
|
12
|
+
for (var i = 0, n = v.length; i < n; i++)
|
|
13
|
+
xml += ind + toXml(v[i], name, ind + "\t") + "\n";
|
|
14
|
+
} else if (typeof v == "object") {
|
|
15
|
+
var hasChild = false;
|
|
16
|
+
xml += ind + "<" + name;
|
|
17
|
+
for (var m in v) {
|
|
18
|
+
if (m.charAt(0) === "@")
|
|
19
|
+
xml += " " + m.substr(1) + '="' + v[m].toString() + '"';
|
|
20
|
+
else hasChild = true;
|
|
21
|
+
}
|
|
22
|
+
xml += hasChild ? ">" : "/>";
|
|
23
|
+
if (hasChild) {
|
|
24
|
+
for (var m2 in v) {
|
|
25
|
+
if (m2 === "#text") xml += v[m2];
|
|
26
|
+
else if (m2 === "#cdata") xml += "<![CDATA[" + v[m2] + "]]>";
|
|
27
|
+
else if (m2.charAt(0) !== "@") xml += toXml(v[m2], m2, ind + "\t");
|
|
28
|
+
}
|
|
29
|
+
xml +=
|
|
30
|
+
(xml.charAt(xml.length - 1) === "\n" ? ind : "") +
|
|
31
|
+
"</" +
|
|
32
|
+
name +
|
|
33
|
+
">";
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
xml += ind + "<" + name + ">" + v.toString() + "</" + name + ">";
|
|
37
|
+
}
|
|
38
|
+
return xml;
|
|
39
|
+
},
|
|
40
|
+
xml = "";
|
|
41
|
+
for (var m3 in o) xml += toXml(o[m3], m3, "");
|
|
42
|
+
return tab ? xml.replace(/\t/g, tab) : xml.replace(/\t|\n/g, "");
|
|
43
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = CodeTabs;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _themeCommon = require("@docusaurus/theme-common");
|
|
11
|
+
|
|
12
|
+
var _useIsBrowser = _interopRequireDefault(require("@docusaurus/useIsBrowser"));
|
|
13
|
+
|
|
14
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
15
|
+
|
|
16
|
+
var _Curl = require("../Curl");
|
|
17
|
+
|
|
18
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.css"));
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
+
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
|
|
26
|
+
/* ============================================================================
|
|
27
|
+
* Copyright (c) Palo Alto Networks
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the MIT license found in the
|
|
30
|
+
* LICENSE file in the root directory of this source tree.
|
|
31
|
+
* ========================================================================== */
|
|
32
|
+
// A very rough duck type, but good enough to guard against mistakes while
|
|
33
|
+
// allowing customization
|
|
34
|
+
function isTabItem(comp) {
|
|
35
|
+
return "value" in comp.props;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function TabsComponent(props) {
|
|
39
|
+
var _ref, _children$find;
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
lazy,
|
|
43
|
+
block,
|
|
44
|
+
defaultValue: defaultValueProp,
|
|
45
|
+
values: valuesProp,
|
|
46
|
+
groupId,
|
|
47
|
+
className,
|
|
48
|
+
action
|
|
49
|
+
} = props;
|
|
50
|
+
|
|
51
|
+
const children = _react.default.Children.map(props.children, child => {
|
|
52
|
+
if ((0, _react.isValidElement)(child) && isTabItem(child)) {
|
|
53
|
+
return child;
|
|
54
|
+
} // child.type.name will give non-sensical values in prod because of
|
|
55
|
+
// minification, but we assume it won't throw in prod.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
throw new Error(`Docusaurus error: Bad <Tabs> child <${// @ts-expect-error: guarding against unexpected cases
|
|
59
|
+
typeof child.type === "string" ? child.type : child.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const values = valuesProp !== null && valuesProp !== void 0 ? valuesProp : // Only pick keys that we recognize. MDX would inject some keys by default
|
|
63
|
+
children.map(({
|
|
64
|
+
props: {
|
|
65
|
+
value,
|
|
66
|
+
label,
|
|
67
|
+
attributes
|
|
68
|
+
}
|
|
69
|
+
}) => ({
|
|
70
|
+
value,
|
|
71
|
+
label,
|
|
72
|
+
attributes
|
|
73
|
+
}));
|
|
74
|
+
const dup = (0, _themeCommon.duplicates)(values, (a, b) => a.value === b.value);
|
|
75
|
+
|
|
76
|
+
if (dup.length > 0) {
|
|
77
|
+
throw new Error(`Docusaurus error: Duplicate values "${dup.map(a => a.value).join(", ")}" found in <Tabs>. Every value needs to be unique.`);
|
|
78
|
+
} // When defaultValueProp is null, don't show a default tab
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
const defaultValue = defaultValueProp === null ? defaultValueProp : (_ref = defaultValueProp !== null && defaultValueProp !== void 0 ? defaultValueProp : (_children$find = children.find(child => child.props.default)) === null || _children$find === void 0 ? void 0 : _children$find.props.value) !== null && _ref !== void 0 ? _ref : children[0].props.value;
|
|
82
|
+
|
|
83
|
+
if (defaultValue !== null && !values.some(a => a.value === defaultValue)) {
|
|
84
|
+
throw new Error(`Docusaurus error: The <Tabs> has a defaultValue "${defaultValue}" but none of its children has the corresponding value. Available values are: ${values.map(a => a.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const {
|
|
88
|
+
tabGroupChoices,
|
|
89
|
+
setTabGroupChoices
|
|
90
|
+
} = (0, _themeCommon.useTabGroupChoice)();
|
|
91
|
+
const [selectedValue, setSelectedValue] = (0, _react.useState)(defaultValue);
|
|
92
|
+
const tabRefs = [];
|
|
93
|
+
const {
|
|
94
|
+
blockElementScrollPositionUntilNextRender
|
|
95
|
+
} = (0, _themeCommon.useScrollPositionBlocker)();
|
|
96
|
+
|
|
97
|
+
if (groupId != null) {
|
|
98
|
+
const relevantTabGroupChoice = tabGroupChoices[groupId];
|
|
99
|
+
|
|
100
|
+
if (relevantTabGroupChoice != null && relevantTabGroupChoice !== selectedValue && values.some(value => value.value === relevantTabGroupChoice)) {
|
|
101
|
+
setSelectedValue(relevantTabGroupChoice);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const handleTabChange = event => {
|
|
106
|
+
const newTab = event.currentTarget;
|
|
107
|
+
const newTabIndex = tabRefs.indexOf(newTab);
|
|
108
|
+
const newTabValue = values[newTabIndex].value;
|
|
109
|
+
|
|
110
|
+
if (newTabValue !== selectedValue) {
|
|
111
|
+
blockElementScrollPositionUntilNextRender(newTab);
|
|
112
|
+
setSelectedValue(newTabValue);
|
|
113
|
+
|
|
114
|
+
if (action) {
|
|
115
|
+
const newLanguage = _Curl.languageSet.filter(lang => lang.language === newTabValue);
|
|
116
|
+
|
|
117
|
+
action(newLanguage[0]);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (groupId != null) {
|
|
121
|
+
setTabGroupChoices(groupId, String(newTabValue));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const handleKeydown = event => {
|
|
127
|
+
var _focusElement;
|
|
128
|
+
|
|
129
|
+
let focusElement = null;
|
|
130
|
+
|
|
131
|
+
switch (event.key) {
|
|
132
|
+
case "ArrowRight":
|
|
133
|
+
{
|
|
134
|
+
var _tabRefs$nextTab;
|
|
135
|
+
|
|
136
|
+
const nextTab = tabRefs.indexOf(event.currentTarget) + 1;
|
|
137
|
+
focusElement = (_tabRefs$nextTab = tabRefs[nextTab]) !== null && _tabRefs$nextTab !== void 0 ? _tabRefs$nextTab : tabRefs[0];
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
case "ArrowLeft":
|
|
142
|
+
{
|
|
143
|
+
var _tabRefs$prevTab;
|
|
144
|
+
|
|
145
|
+
const prevTab = tabRefs.indexOf(event.currentTarget) - 1;
|
|
146
|
+
focusElement = (_tabRefs$prevTab = tabRefs[prevTab]) !== null && _tabRefs$prevTab !== void 0 ? _tabRefs$prevTab : tabRefs[tabRefs.length - 1];
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
default:
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
(_focusElement = focusElement) === null || _focusElement === void 0 ? void 0 : _focusElement.focus();
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
return <div className={(0, _clsx.default)("tabs-container", _stylesModule.default.tabList)}>
|
|
158
|
+
<ul role="tablist" aria-orientation="horizontal" className={(0, _clsx.default)("tabs", {
|
|
159
|
+
"tabs--block": block
|
|
160
|
+
}, _stylesModule.default.code__tabs, className)}>
|
|
161
|
+
{values.map(({
|
|
162
|
+
value,
|
|
163
|
+
label,
|
|
164
|
+
attributes
|
|
165
|
+
}) => <li role="tab" tabIndex={selectedValue === value ? 0 : -1} aria-selected={selectedValue === value} key={value} ref={tabControl => tabRefs.push(tabControl)} onKeyDown={handleKeydown} onFocus={handleTabChange} onClick={handleTabChange} {...attributes} className={(0, _clsx.default)("tabs__item", _stylesModule.default.tabItem, attributes === null || attributes === void 0 ? void 0 : attributes.className, {
|
|
166
|
+
"tabs__item--active": selectedValue === value
|
|
167
|
+
})}>
|
|
168
|
+
{label !== null && label !== void 0 ? label : value}
|
|
169
|
+
</li>)}
|
|
170
|
+
</ul>
|
|
171
|
+
|
|
172
|
+
{lazy ? (0, _react.cloneElement)(children.filter(tabItem => tabItem.props.value === selectedValue)[0], {
|
|
173
|
+
className: "margin-top--md"
|
|
174
|
+
}) : <div className="margin-top--md">
|
|
175
|
+
{children.map((tabItem, i) => (0, _react.cloneElement)(tabItem, {
|
|
176
|
+
key: i,
|
|
177
|
+
hidden: tabItem.props.value !== selectedValue
|
|
178
|
+
}))}
|
|
179
|
+
</div>}
|
|
180
|
+
</div>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function CodeTabs(props) {
|
|
184
|
+
const isBrowser = (0, _useIsBrowser.default)();
|
|
185
|
+
return <TabsComponent // Remount tabs after hydration
|
|
186
|
+
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
187
|
+
key={String(isBrowser)} {...props} />;
|
|
188
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.languageSet = exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
@@ -11,16 +11,16 @@ var _useDocusaurusContext = _interopRequireDefault(require("@docusaurus/useDocus
|
|
|
11
11
|
|
|
12
12
|
var _postmanCodeGenerators = _interopRequireDefault(require("@paloaltonetworks/postman-code-generators"));
|
|
13
13
|
|
|
14
|
+
var _CodeBlock = _interopRequireDefault(require("@theme/CodeBlock"));
|
|
15
|
+
|
|
14
16
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
15
17
|
|
|
16
|
-
var
|
|
18
|
+
var _CodeTabs = _interopRequireDefault(require("../CodeTabs"));
|
|
17
19
|
|
|
18
20
|
var _hooks = require("../hooks");
|
|
19
21
|
|
|
20
22
|
var _buildPostmanRequest = _interopRequireDefault(require("./../buildPostmanRequest"));
|
|
21
23
|
|
|
22
|
-
var _FloatingButton = _interopRequireDefault(require("./../FloatingButton"));
|
|
23
|
-
|
|
24
24
|
var _stylesModule = _interopRequireDefault(require("./styles.module.css"));
|
|
25
25
|
|
|
26
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -39,6 +39,7 @@ const languageSet = [{
|
|
|
39
39
|
tabName: "cURL",
|
|
40
40
|
highlight: "bash",
|
|
41
41
|
language: "curl",
|
|
42
|
+
codeLanguage: "bash",
|
|
42
43
|
variant: "curl",
|
|
43
44
|
options: {
|
|
44
45
|
longFormat: false,
|
|
@@ -46,12 +47,12 @@ const languageSet = [{
|
|
|
46
47
|
trimRequestBody: true
|
|
47
48
|
}
|
|
48
49
|
}, {
|
|
49
|
-
tabName: "
|
|
50
|
-
highlight: "
|
|
51
|
-
language: "
|
|
52
|
-
|
|
50
|
+
tabName: "Python",
|
|
51
|
+
highlight: "python",
|
|
52
|
+
language: "python",
|
|
53
|
+
codeLanguage: "python",
|
|
54
|
+
variant: "requests",
|
|
53
55
|
options: {
|
|
54
|
-
ES6_enabled: true,
|
|
55
56
|
followRedirect: true,
|
|
56
57
|
trimRequestBody: true
|
|
57
58
|
}
|
|
@@ -59,74 +60,49 @@ const languageSet = [{
|
|
|
59
60
|
tabName: "Go",
|
|
60
61
|
highlight: "go",
|
|
61
62
|
language: "go",
|
|
63
|
+
codeLanguage: "go",
|
|
62
64
|
variant: "native",
|
|
63
65
|
options: {
|
|
64
66
|
followRedirect: true,
|
|
65
67
|
trimRequestBody: true
|
|
66
68
|
}
|
|
67
69
|
}, {
|
|
68
|
-
tabName: "
|
|
69
|
-
highlight: "
|
|
70
|
-
language: "
|
|
71
|
-
|
|
70
|
+
tabName: "Node",
|
|
71
|
+
highlight: "javascript",
|
|
72
|
+
language: "nodejs",
|
|
73
|
+
codeLanguage: "javascript",
|
|
74
|
+
variant: "axios",
|
|
72
75
|
options: {
|
|
76
|
+
ES6_enabled: true,
|
|
73
77
|
followRedirect: true,
|
|
74
78
|
trimRequestBody: true
|
|
75
79
|
}
|
|
76
80
|
}];
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}, {
|
|
92
|
-
types: ["builtin", "char", "constant", "function"],
|
|
93
|
-
style: {
|
|
94
|
-
color: "var(--openapi-code-blue)"
|
|
95
|
-
}
|
|
96
|
-
}, {
|
|
97
|
-
types: ["punctuation", "operator"],
|
|
98
|
-
style: {
|
|
99
|
-
color: "var(--openapi-code-dim)"
|
|
100
|
-
}
|
|
101
|
-
}, {
|
|
102
|
-
types: ["class-name"],
|
|
103
|
-
style: {
|
|
104
|
-
color: "var(--openapi-code-orange)"
|
|
105
|
-
}
|
|
106
|
-
}, {
|
|
107
|
-
types: ["tag", "arrow", "keyword"],
|
|
108
|
-
style: {
|
|
109
|
-
color: "var(--openapi-code-purple)"
|
|
110
|
-
}
|
|
111
|
-
}, {
|
|
112
|
-
types: ["boolean"],
|
|
113
|
-
style: {
|
|
114
|
-
color: "var(--openapi-code-red)"
|
|
115
|
-
}
|
|
116
|
-
}]
|
|
117
|
-
};
|
|
81
|
+
exports.languageSet = languageSet;
|
|
82
|
+
|
|
83
|
+
function CodeTab({
|
|
84
|
+
children,
|
|
85
|
+
hidden,
|
|
86
|
+
className,
|
|
87
|
+
onClick
|
|
88
|
+
}) {
|
|
89
|
+
return <div role="tabpanel" className={(0, _clsx.default)(_stylesModule.default.tabItem, className)} {...{
|
|
90
|
+
hidden
|
|
91
|
+
}}>
|
|
92
|
+
{children}
|
|
93
|
+
</div>;
|
|
94
|
+
}
|
|
118
95
|
|
|
119
96
|
function Curl({
|
|
120
97
|
postman,
|
|
121
98
|
codeSamples
|
|
122
99
|
}) {
|
|
123
|
-
var _ref, _siteConfig$themeConf
|
|
100
|
+
var _ref, _siteConfig$themeConf, _defaultLang$;
|
|
124
101
|
|
|
125
102
|
// TODO: match theme for vscode.
|
|
126
103
|
const {
|
|
127
104
|
siteConfig
|
|
128
105
|
} = (0, _useDocusaurusContext.default)();
|
|
129
|
-
const [copyText, setCopyText] = (0, _react.useState)("Copy");
|
|
130
106
|
const contentType = (0, _hooks.useTypedSelector)(state => state.contentType.value);
|
|
131
107
|
const accept = (0, _hooks.useTypedSelector)(state => state.accept.value);
|
|
132
108
|
const server = (0, _hooks.useTypedSelector)(state => state.server.value);
|
|
@@ -138,7 +114,8 @@ function Curl({
|
|
|
138
114
|
const auth = (0, _hooks.useTypedSelector)(state => state.auth); // TODO
|
|
139
115
|
|
|
140
116
|
const langs = [...((_ref = siteConfig === null || siteConfig === void 0 ? void 0 : (_siteConfig$themeConf = siteConfig.themeConfig) === null || _siteConfig$themeConf === void 0 ? void 0 : _siteConfig$themeConf.languageTabs) !== null && _ref !== void 0 ? _ref : languageSet), ...codeSamples];
|
|
141
|
-
const
|
|
117
|
+
const defaultLang = languageSet.filter(lang => lang.codeLanguage === localStorage.getItem("docusaurus.tab.code-samples"));
|
|
118
|
+
const [language, setLanguage] = (0, _react.useState)((_defaultLang$ = defaultLang[0]) !== null && _defaultLang$ !== void 0 ? _defaultLang$ : langs[0]);
|
|
142
119
|
const [codeText, setCodeText] = (0, _react.useState)("");
|
|
143
120
|
(0, _react.useEffect)(() => {
|
|
144
121
|
if (language && !!language.options) {
|
|
@@ -167,67 +144,21 @@ function Curl({
|
|
|
167
144
|
setCodeText("");
|
|
168
145
|
}
|
|
169
146
|
}, [accept, body, contentType, cookieParams, headerParams, language, pathParams, postman, queryParams, server, auth]);
|
|
170
|
-
const ref = (0, _react.useRef)(null);
|
|
171
|
-
|
|
172
|
-
const handleCurlCopy = () => {
|
|
173
|
-
var _ref$current;
|
|
174
|
-
|
|
175
|
-
setCopyText("Copied");
|
|
176
|
-
setTimeout(() => {
|
|
177
|
-
setCopyText("Copy");
|
|
178
|
-
}, 2000);
|
|
179
|
-
|
|
180
|
-
if ((_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.innerText) {
|
|
181
|
-
navigator.clipboard.writeText(ref.current.innerText);
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
147
|
|
|
185
148
|
if (language === undefined) {
|
|
186
149
|
return null;
|
|
187
150
|
}
|
|
188
151
|
|
|
189
152
|
return <>
|
|
190
|
-
<
|
|
153
|
+
<_CodeTabs.default groupId="code-samples" action={setLanguage}>
|
|
191
154
|
{langs.map(lang => {
|
|
192
|
-
return <
|
|
193
|
-
|
|
194
|
-
</button>;
|
|
195
|
-
})}
|
|
196
|
-
</div>
|
|
197
|
-
|
|
198
|
-
<_prismReactRenderer.default {..._prismReactRenderer.defaultProps} theme={languageTheme} code={codeText} language={language.highlight || language.lang}>
|
|
199
|
-
{({
|
|
200
|
-
className,
|
|
201
|
-
tokens,
|
|
202
|
-
getLineProps,
|
|
203
|
-
getTokenProps
|
|
204
|
-
}) => <_FloatingButton.default onClick={handleCurlCopy} label={copyText}>
|
|
205
|
-
<pre className={className} style={{
|
|
206
|
-
background: "var(--openapi-card-background-color)",
|
|
207
|
-
paddingRight: "60px",
|
|
208
|
-
borderRadius: "2px 2px var(--openapi-card-border-radius) var(--openapi-card-border-radius)"
|
|
155
|
+
return <CodeTab value={lang.language} label={""} key={lang.tabName || lang.label} attributes={{
|
|
156
|
+
className: `code__tab--${lang.codeLanguage}`
|
|
209
157
|
}}>
|
|
210
|
-
<
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
})}>
|
|
215
|
-
{line.map((token, key) => {
|
|
216
|
-
if (token.types.includes("arrow")) {
|
|
217
|
-
token.types = ["arrow"];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return <span {...getTokenProps({
|
|
221
|
-
token,
|
|
222
|
-
key
|
|
223
|
-
})} />;
|
|
224
|
-
})}
|
|
225
|
-
{"\n"}
|
|
226
|
-
</span>)}
|
|
227
|
-
</code>
|
|
228
|
-
</pre>
|
|
229
|
-
</_FloatingButton.default>}
|
|
230
|
-
</_prismReactRenderer.default>
|
|
158
|
+
<_CodeBlock.default language={lang.codeLanguage}>{codeText}</_CodeBlock.default>
|
|
159
|
+
</CodeTab>;
|
|
160
|
+
})}
|
|
161
|
+
</_CodeTabs.default>
|
|
231
162
|
</>;
|
|
232
163
|
}
|
|
233
164
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _themeCommon = require("@docusaurus/theme-common");
|
|
11
|
+
|
|
12
|
+
var _useIsBrowser = _interopRequireDefault(require("@docusaurus/useIsBrowser"));
|
|
13
|
+
|
|
14
|
+
var _reactLive = require("react-live");
|
|
15
|
+
|
|
16
|
+
var _slice = require("../Body/slice");
|
|
17
|
+
|
|
18
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.css"));
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
/* ============================================================================
|
|
23
|
+
* Copyright (c) Palo Alto Networks
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the MIT license found in the
|
|
26
|
+
* LICENSE file in the root directory of this source tree.
|
|
27
|
+
* ========================================================================== */
|
|
28
|
+
function Live({
|
|
29
|
+
onEdit
|
|
30
|
+
}) {
|
|
31
|
+
const isBrowser = (0, _useIsBrowser.default)();
|
|
32
|
+
return <>
|
|
33
|
+
<_reactLive.LiveEditor key={String(isBrowser)} className={_stylesModule.default.playgroundEditor} onChange={onEdit} />
|
|
34
|
+
</>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const LiveComponent = (0, _reactLive.withLive)(Live);
|
|
38
|
+
|
|
39
|
+
function App({
|
|
40
|
+
children,
|
|
41
|
+
transformCode,
|
|
42
|
+
value,
|
|
43
|
+
language,
|
|
44
|
+
action,
|
|
45
|
+
...props
|
|
46
|
+
}) {
|
|
47
|
+
const prismTheme = (0, _themeCommon.usePrismTheme)();
|
|
48
|
+
|
|
49
|
+
const [code, setCode] = _react.default.useState(children);
|
|
50
|
+
|
|
51
|
+
action((0, _slice.setStringRawBody)(code));
|
|
52
|
+
return <div className={_stylesModule.default.playgroundContainer}>
|
|
53
|
+
<_reactLive.LiveProvider code={children.replace(/\n$/, "")} transformCode={transformCode !== null && transformCode !== void 0 ? transformCode : code => `${code};`} theme={prismTheme} language={language} {...props}>
|
|
54
|
+
<LiveComponent onEdit={setCode} />
|
|
55
|
+
</_reactLive.LiveProvider>
|
|
56
|
+
</div>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const LiveApp = (0, _reactLive.withLive)(App);
|
|
60
|
+
var _default = LiveApp;
|
|
61
|
+
exports.default = _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.playgroundContainer {
|
|
2
|
+
margin-top: 1rem;
|
|
3
|
+
margin-bottom: var(--ifm-leading);
|
|
4
|
+
border-radius: var(--ifm-global-radius);
|
|
5
|
+
box-shadow: var(--ifm-global-shadow-lw);
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.playgroundHeader {
|
|
10
|
+
letter-spacing: 0.08rem;
|
|
11
|
+
padding: 0.75rem;
|
|
12
|
+
text-transform: uppercase;
|
|
13
|
+
font-weight: bold;
|
|
14
|
+
background: var(--ifm-color-emphasis-200);
|
|
15
|
+
color: var(--ifm-color-content);
|
|
16
|
+
font-size: var(--ifm-code-font-size);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.playgroundHeader:first-of-type {
|
|
20
|
+
background: var(--ifm-color-emphasis-600);
|
|
21
|
+
color: var(--ifm-color-content-inverse);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.playgroundEditor {
|
|
25
|
+
font: var(--ifm-code-font-size) / var(--ifm-pre-line-height)
|
|
26
|
+
var(--ifm-font-family-monospace) !important;
|
|
27
|
+
/* rtl:ignore */
|
|
28
|
+
direction: ltr;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.playgroundPreview {
|
|
32
|
+
padding: 1rem;
|
|
33
|
+
background-color: var(--ifm-pre-background);
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path fill="none" d="M4.24 4.24h119.53v119.53H4.24z"/><path fill="#293138" d="M109.01 28.64L71.28 6.24c-2.25-1.33-4.77-2-7.28-2s-5.03.67-7.28 2.01l-37.74 22.4c-4.5 2.67-7.28 7.61-7.28 12.96v44.8c0 5.35 2.77 10.29 7.28 12.96l37.73 22.4c2.25 1.34 4.76 2 7.28 2 2.51 0 5.03-.67 7.28-2l37.74-22.4c4.5-2.67 7.28-7.62 7.28-12.96V41.6c0-5.34-2.77-10.29-7.28-12.96zM79.79 98.59l.06 3.22c0 .39-.25.83-.55.99l-1.91 1.1c-.3.15-.56-.03-.56-.42l-.03-3.17c-1.63.68-3.29.84-4.34.42-.2-.08-.29-.37-.21-.71l.69-2.91c.06-.23.18-.46.34-.6.06-.06.12-.1.18-.13.11-.06.22-.07.31-.03 1.14.38 2.59.2 3.99-.5 1.78-.9 2.97-2.72 2.95-4.52-.02-1.64-.9-2.31-3.05-2.33-2.74.01-5.3-.53-5.34-4.57-.03-3.32 1.69-6.78 4.43-8.96l-.03-3.25c0-.4.24-.84.55-1l1.85-1.18c.3-.15.56.04.56.43l.03 3.25c1.36-.54 2.54-.69 3.61-.44.23.06.34.38.24.75l-.72 2.88c-.06.22-.18.44-.33.58a.77.77 0 01-.19.14c-.1.05-.19.06-.28.05-.49-.11-1.65-.36-3.48.56-1.92.97-2.59 2.64-2.58 3.88.02 1.48.77 1.93 3.39 1.97 3.49.06 4.99 1.58 5.03 5.09.05 3.44-1.79 7.15-4.61 9.41zm26.34-60.5l-35.7 22.05c-4.45 2.6-7.73 5.52-7.74 10.89v43.99c0 3.21 1.3 5.29 3.29 5.9-.65.11-1.32.19-1.98.19-2.09 0-4.15-.57-5.96-1.64l-37.73-22.4c-3.69-2.19-5.98-6.28-5.98-10.67V41.6c0-4.39 2.29-8.48 5.98-10.67l37.74-22.4c1.81-1.07 3.87-1.64 5.96-1.64s4.15.57 5.96 1.64l37.74 22.4c3.11 1.85 5.21 5.04 5.8 8.63-1.27-2.67-4.09-3.39-7.38-1.47z"/><path fill="#4FA847" d="M99.12 90.73l-9.4 5.62c-.25.15-.43.31-.43.61v2.46c0 .3.2.43.45.28l9.54-5.8c.25-.15.29-.42.29-.72v-2.17c0-.3-.2-.42-.45-.28z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><g fill="#00acd7" fill-rule="evenodd"><path d="M11.156 54.829c-.243 0-.303-.122-.182-.303l1.273-1.637c.12-.182.424-.303.666-.303H34.55c.243 0 .303.182.182.364l-1.03 1.576c-.121.181-.424.363-.606.363zM2.004 60.404c-.242 0-.303-.12-.182-.303l1.273-1.636c.121-.182.424-.303.667-.303h27.636c.242 0 .364.182.303.364l-.485 1.454c-.06.243-.303.364-.545.364zM16.67 65.98c-.242 0-.302-.182-.181-.364l.848-1.515c.122-.182.364-.363.607-.363h12.12c.243 0 .364.181.364.424l-.12 1.454c0 .243-.243.425-.425.425zM79.58 53.738c-3.819.97-6.425 1.697-10.182 2.666-.91.243-.97.303-1.758-.606-.909-1.03-1.576-1.697-2.848-2.303-3.819-1.878-7.516-1.333-10.97.91-4.121 2.666-6.242 6.605-6.182 11.514.06 4.849 3.394 8.849 8.182 9.516 4.121.545 7.576-.91 10.303-4 .545-.667 1.03-1.394 1.636-2.243H56.064c-1.272 0-1.575-.788-1.151-1.818.788-1.879 2.242-5.03 3.09-6.606.183-.364.607-.97 1.516-.97h22.06c-.12 1.637-.12 3.273-.363 4.91-.667 4.363-2.303 8.363-4.97 11.878-4.364 5.758-10.06 9.333-17.273 10.303-5.939.788-11.454-.364-16.302-4-4.485-3.394-7.03-7.879-7.697-13.454-.788-6.606 1.151-12.546 5.151-17.758 4.303-5.636 10-9.212 16.97-10.485 5.697-1.03 11.151-.363 16.06 2.97 3.212 2.121 5.515 5.03 7.03 8.545.364.546.122.849-.606 1.03z"/><path d="M99.64 87.253c-5.515-.122-10.546-1.697-14.788-5.334-3.576-3.09-5.818-7.03-6.545-11.697-1.091-6.848.787-12.909 4.909-18.302 4.424-5.819 9.757-8.849 16.97-10.122 6.181-1.09 12-.484 17.272 3.091 4.788 3.273 7.757 7.697 8.545 13.515 1.03 8.182-1.333 14.849-6.97 20.546-4 4.06-8.909 6.606-14.545 7.757-1.636.303-3.273.364-4.848.546zm14.424-24.485c-.06-.788-.06-1.394-.182-2-1.09-6-6.606-9.394-12.363-8.06-5.637 1.272-9.273 4.848-10.606 10.545-1.091 4.727 1.212 9.515 5.575 11.454 3.334 1.455 6.667 1.273 9.879-.363 4.788-2.485 7.394-6.364 7.697-11.576z" fill-rule="nonzero"/></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path fill="#F0DB4F" d="M1.408 1.408h125.184v125.185H1.408z"/><path fill="#323330" d="M116.347 96.736c-.917-5.711-4.641-10.508-15.672-14.981-3.832-1.761-8.104-3.022-9.377-5.926-.452-1.69-.512-2.642-.226-3.665.821-3.32 4.784-4.355 7.925-3.403 2.023.678 3.938 2.237 5.093 4.724 5.402-3.498 5.391-3.475 9.163-5.879-1.381-2.141-2.118-3.129-3.022-4.045-3.249-3.629-7.676-5.498-14.756-5.355l-3.688.477c-3.534.893-6.902 2.748-8.877 5.235-5.926 6.724-4.236 18.492 2.975 23.335 7.104 5.332 17.54 6.545 18.873 11.531 1.297 6.104-4.486 8.08-10.234 7.378-4.236-.881-6.592-3.034-9.139-6.949-4.688 2.713-4.688 2.713-9.508 5.485 1.143 2.499 2.344 3.63 4.26 5.795 9.068 9.198 31.76 8.746 35.83-5.176.165-.478 1.261-3.666.38-8.581zM69.462 58.943H57.753l-.048 30.272c0 6.438.333 12.34-.714 14.149-1.713 3.558-6.152 3.117-8.175 2.427-2.059-1.012-3.106-2.451-4.319-4.485-.333-.584-.583-1.036-.667-1.071l-9.52 5.83c1.583 3.249 3.915 6.069 6.902 7.901 4.462 2.678 10.459 3.499 16.731 2.059 4.082-1.189 7.604-3.652 9.448-7.401 2.666-4.915 2.094-10.864 2.07-17.444.06-10.735.001-21.468.001-32.237z"/></svg>
|