docusaurus-theme-openapi-docs 1.0.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/LICENSE +21 -0
- package/babel.config.js +35 -0
- package/lib/index.js +48 -0
- package/lib/markdown/createDescription.js +20 -0
- package/lib/markdown/schema.js +121 -0
- package/lib/markdown/utils.js +45 -0
- package/lib/theme/ApiDemoPanel/Accept/index.js +41 -0
- package/lib/theme/ApiDemoPanel/Accept/slice.js +32 -0
- package/lib/theme/ApiDemoPanel/Authorization/auth-types.js +32 -0
- package/lib/theme/ApiDemoPanel/Authorization/index.js +174 -0
- package/lib/theme/ApiDemoPanel/Authorization/slice.js +137 -0
- package/lib/theme/ApiDemoPanel/Body/index.js +185 -0
- package/lib/theme/ApiDemoPanel/Body/slice.js +105 -0
- package/lib/theme/ApiDemoPanel/ContentType/index.js +41 -0
- package/lib/theme/ApiDemoPanel/ContentType/slice.js +32 -0
- package/lib/theme/ApiDemoPanel/Curl/index.js +236 -0
- package/lib/theme/ApiDemoPanel/Curl/styles.module.css +84 -0
- package/lib/theme/ApiDemoPanel/Execute/index.js +85 -0
- package/lib/theme/ApiDemoPanel/Execute/makeRequest.js +202 -0
- package/lib/theme/ApiDemoPanel/FloatingButton/index.js +32 -0
- package/lib/theme/ApiDemoPanel/FloatingButton/styles.module.css +26 -0
- package/lib/theme/ApiDemoPanel/FormFileUpload/index.js +97 -0
- package/lib/theme/ApiDemoPanel/FormFileUpload/styles.module.css +75 -0
- package/lib/theme/ApiDemoPanel/FormItem/index.js +35 -0
- package/lib/theme/ApiDemoPanel/FormItem/styles.module.css +7 -0
- package/lib/theme/ApiDemoPanel/FormMultiSelect/index.js +52 -0
- package/lib/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +38 -0
- package/lib/theme/ApiDemoPanel/FormSelect/index.js +39 -0
- package/lib/theme/ApiDemoPanel/FormSelect/styles.module.css +51 -0
- package/lib/theme/ApiDemoPanel/FormTextInput/index.js +30 -0
- package/lib/theme/ApiDemoPanel/FormTextInput/styles.module.css +21 -0
- package/lib/theme/ApiDemoPanel/MethodEndpoint/index.js +60 -0
- package/lib/theme/ApiDemoPanel/ParamOptions/index.js +248 -0
- package/lib/theme/ApiDemoPanel/ParamOptions/slice.js +35 -0
- package/lib/theme/ApiDemoPanel/ParamOptions/styles.module.css +180 -0
- package/lib/theme/ApiDemoPanel/Response/index.js +75 -0
- package/lib/theme/ApiDemoPanel/Response/slice.js +37 -0
- package/lib/theme/ApiDemoPanel/SecuritySchemes/index.js +51 -0
- package/lib/theme/ApiDemoPanel/Server/index.js +109 -0
- package/lib/theme/ApiDemoPanel/Server/slice.js +41 -0
- package/lib/theme/ApiDemoPanel/Server/styles.module.css +61 -0
- package/lib/theme/ApiDemoPanel/VSCode/index.js +252 -0
- package/lib/theme/ApiDemoPanel/VSCode/styles.module.css +19 -0
- package/lib/theme/ApiDemoPanel/buildPostmanRequest.js +329 -0
- package/lib/theme/ApiDemoPanel/hooks.js +20 -0
- package/lib/theme/ApiDemoPanel/index.js +134 -0
- package/lib/theme/ApiDemoPanel/persistanceMiddleware.js +44 -0
- package/lib/theme/ApiDemoPanel/postman-collection.d.ts +10 -0
- package/lib/theme/ApiDemoPanel/storage-utils.js +47 -0
- package/lib/theme/ApiDemoPanel/store.js +48 -0
- package/lib/theme/ApiDemoPanel/styles.module.css +44 -0
- package/lib/theme/ApiItem/index.js +160 -0
- package/lib/theme/ApiItem/styles.module.css +109 -0
- package/lib/theme/ParamsItem/index.js +68 -0
- package/lib/theme/ParamsItem/styles.module.css +24 -0
- package/lib/theme/SchemaItem/index.js +58 -0
- package/lib/theme/SchemaItem/styles.module.css +24 -0
- package/lib/theme/Tabs/index.js +258 -0
- package/lib/theme/Tabs/styles.module.css +118 -0
- package/lib/theme-classic.d.ts +8 -0
- package/lib/theme-openapi.d.ts +48 -0
- package/lib/theme-translations.d.ts +9 -0
- package/lib/types.js +1 -0
- package/lib-next/index.js +38 -0
- package/lib-next/markdown/createDescription.js +13 -0
- package/lib-next/markdown/schema.js +115 -0
- package/lib-next/markdown/utils.js +31 -0
- package/lib-next/theme/ApiDemoPanel/Accept/index.js +33 -0
- package/lib-next/theme/ApiDemoPanel/Accept/slice.js +19 -0
- package/lib-next/theme/ApiDemoPanel/Authorization/auth-types.js +22 -0
- package/lib-next/theme/ApiDemoPanel/Authorization/index.js +203 -0
- package/lib-next/theme/ApiDemoPanel/Authorization/slice.js +101 -0
- package/lib-next/theme/ApiDemoPanel/Body/index.js +210 -0
- package/lib-next/theme/ApiDemoPanel/Body/slice.js +89 -0
- package/lib-next/theme/ApiDemoPanel/ContentType/index.js +33 -0
- package/lib-next/theme/ApiDemoPanel/ContentType/slice.js +19 -0
- package/lib-next/theme/ApiDemoPanel/Curl/index.js +264 -0
- package/lib-next/theme/ApiDemoPanel/Curl/styles.module.css +84 -0
- package/lib-next/theme/ApiDemoPanel/Execute/index.js +74 -0
- package/lib-next/theme/ApiDemoPanel/Execute/makeRequest.js +183 -0
- package/lib-next/theme/ApiDemoPanel/FloatingButton/index.js +19 -0
- package/lib-next/theme/ApiDemoPanel/FloatingButton/styles.module.css +26 -0
- package/lib-next/theme/ApiDemoPanel/FormFileUpload/index.js +113 -0
- package/lib-next/theme/ApiDemoPanel/FormFileUpload/styles.module.css +75 -0
- package/lib-next/theme/ApiDemoPanel/FormItem/index.js +29 -0
- package/lib-next/theme/ApiDemoPanel/FormItem/styles.module.css +7 -0
- package/lib-next/theme/ApiDemoPanel/FormMultiSelect/index.js +49 -0
- package/lib-next/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +38 -0
- package/lib-next/theme/ApiDemoPanel/FormSelect/index.js +28 -0
- package/lib-next/theme/ApiDemoPanel/FormSelect/styles.module.css +51 -0
- package/lib-next/theme/ApiDemoPanel/FormTextInput/index.js +23 -0
- package/lib-next/theme/ApiDemoPanel/FormTextInput/styles.module.css +21 -0
- package/lib-next/theme/ApiDemoPanel/MethodEndpoint/index.js +53 -0
- package/lib-next/theme/ApiDemoPanel/ParamOptions/index.js +284 -0
- package/lib-next/theme/ApiDemoPanel/ParamOptions/slice.js +22 -0
- package/lib-next/theme/ApiDemoPanel/ParamOptions/styles.module.css +180 -0
- package/lib-next/theme/ApiDemoPanel/Response/index.js +65 -0
- package/lib-next/theme/ApiDemoPanel/Response/slice.js +22 -0
- package/lib-next/theme/ApiDemoPanel/SecuritySchemes/index.js +48 -0
- package/lib-next/theme/ApiDemoPanel/Server/index.js +114 -0
- package/lib-next/theme/ApiDemoPanel/Server/slice.js +25 -0
- package/lib-next/theme/ApiDemoPanel/Server/styles.module.css +61 -0
- package/lib-next/theme/ApiDemoPanel/VSCode/index.js +265 -0
- package/lib-next/theme/ApiDemoPanel/VSCode/styles.module.css +19 -0
- package/lib-next/theme/ApiDemoPanel/buildPostmanRequest.js +310 -0
- package/lib-next/theme/ApiDemoPanel/hooks.js +9 -0
- package/lib-next/theme/ApiDemoPanel/index.js +110 -0
- package/lib-next/theme/ApiDemoPanel/persistanceMiddleware.js +38 -0
- package/lib-next/theme/ApiDemoPanel/postman-collection.d.ts +10 -0
- package/lib-next/theme/ApiDemoPanel/storage-utils.js +35 -0
- package/lib-next/theme/ApiDemoPanel/store.js +30 -0
- package/lib-next/theme/ApiDemoPanel/styles.module.css +44 -0
- package/lib-next/theme/ApiItem/index.js +171 -0
- package/lib-next/theme/ApiItem/styles.module.css +109 -0
- package/lib-next/theme/ParamsItem/index.js +68 -0
- package/lib-next/theme/ParamsItem/styles.module.css +24 -0
- package/lib-next/theme/SchemaItem/index.js +58 -0
- package/lib-next/theme/SchemaItem/styles.module.css +24 -0
- package/lib-next/theme/Tabs/index.js +258 -0
- package/lib-next/theme/Tabs/styles.module.css +118 -0
- package/lib-next/theme-classic.d.ts +8 -0
- package/lib-next/theme-openapi.d.ts +48 -0
- package/lib-next/theme-translations.d.ts +9 -0
- package/lib-next/types.js +1 -0
- package/package.json +68 -0
- package/src/index.ts +42 -0
- package/src/markdown/createDescription.ts +13 -0
- package/src/markdown/schema.ts +115 -0
- package/src/markdown/utils.ts +39 -0
- package/src/theme/ApiDemoPanel/Accept/index.tsx +35 -0
- package/src/theme/ApiDemoPanel/Accept/slice.ts +29 -0
- package/src/theme/ApiDemoPanel/Authorization/auth-types.ts +26 -0
- package/src/theme/ApiDemoPanel/Authorization/index.tsx +211 -0
- package/src/theme/ApiDemoPanel/Authorization/slice.ts +145 -0
- package/src/theme/ApiDemoPanel/Body/index.tsx +218 -0
- package/src/theme/ApiDemoPanel/Body/slice.ts +133 -0
- package/src/theme/ApiDemoPanel/ContentType/index.tsx +35 -0
- package/src/theme/ApiDemoPanel/ContentType/slice.ts +29 -0
- package/src/theme/ApiDemoPanel/Curl/index.tsx +280 -0
- package/src/theme/ApiDemoPanel/Curl/styles.module.css +84 -0
- package/src/theme/ApiDemoPanel/Execute/index.tsx +88 -0
- package/src/theme/ApiDemoPanel/Execute/makeRequest.ts +184 -0
- package/src/theme/ApiDemoPanel/FloatingButton/index.tsx +27 -0
- package/src/theme/ApiDemoPanel/FloatingButton/styles.module.css +26 -0
- package/src/theme/ApiDemoPanel/FormFileUpload/index.tsx +116 -0
- package/src/theme/ApiDemoPanel/FormFileUpload/styles.module.css +75 -0
- package/src/theme/ApiDemoPanel/FormItem/index.tsx +28 -0
- package/src/theme/ApiDemoPanel/FormItem/styles.module.css +7 -0
- package/src/theme/ApiDemoPanel/FormMultiSelect/index.tsx +54 -0
- package/src/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +38 -0
- package/src/theme/ApiDemoPanel/FormSelect/index.tsx +36 -0
- package/src/theme/ApiDemoPanel/FormSelect/styles.module.css +51 -0
- package/src/theme/ApiDemoPanel/FormTextInput/index.tsx +32 -0
- package/src/theme/ApiDemoPanel/FormTextInput/styles.module.css +21 -0
- package/src/theme/ApiDemoPanel/MethodEndpoint/index.tsx +55 -0
- package/src/theme/ApiDemoPanel/ParamOptions/index.tsx +316 -0
- package/src/theme/ApiDemoPanel/ParamOptions/slice.ts +37 -0
- package/src/theme/ApiDemoPanel/ParamOptions/styles.module.css +180 -0
- package/src/theme/ApiDemoPanel/Response/index.tsx +66 -0
- package/src/theme/ApiDemoPanel/Response/slice.ts +31 -0
- package/src/theme/ApiDemoPanel/SecuritySchemes/index.tsx +49 -0
- package/src/theme/ApiDemoPanel/Server/index.tsx +103 -0
- package/src/theme/ApiDemoPanel/Server/slice.ts +40 -0
- package/src/theme/ApiDemoPanel/Server/styles.module.css +61 -0
- package/src/theme/ApiDemoPanel/VSCode/index.tsx +205 -0
- package/src/theme/ApiDemoPanel/VSCode/styles.module.css +19 -0
- package/src/theme/ApiDemoPanel/buildPostmanRequest.ts +307 -0
- package/src/theme/ApiDemoPanel/hooks.ts +13 -0
- package/src/theme/ApiDemoPanel/index.tsx +118 -0
- package/src/theme/ApiDemoPanel/persistanceMiddleware.ts +46 -0
- package/src/theme/ApiDemoPanel/postman-collection.d.ts +10 -0
- package/src/theme/ApiDemoPanel/storage-utils.ts +39 -0
- package/src/theme/ApiDemoPanel/store.ts +41 -0
- package/src/theme/ApiDemoPanel/styles.module.css +44 -0
- package/src/theme/ApiItem/index.tsx +171 -0
- package/src/theme/ApiItem/styles.module.css +109 -0
- package/src/theme/ParamsItem/index.js +68 -0
- package/src/theme/ParamsItem/styles.module.css +24 -0
- package/src/theme/SchemaItem/index.js +58 -0
- package/src/theme/SchemaItem/styles.module.css +24 -0
- package/src/theme/Tabs/index.js +258 -0
- package/src/theme/Tabs/styles.module.css +118 -0
- package/src/theme-classic.d.ts +8 -0
- package/src/theme-openapi.d.ts +48 -0
- package/src/theme-translations.d.ts +9 -0
- package/src/types.ts +70 -0
- package/tsconfig.json +10 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _useDocusaurusContext = _interopRequireDefault(require("@docusaurus/useDocusaurusContext"));
|
|
11
|
+
|
|
12
|
+
var _postmanCodeGenerators = _interopRequireDefault(require("@paloaltonetworks/postman-code-generators"));
|
|
13
|
+
|
|
14
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
15
|
+
|
|
16
|
+
var _prismReactRenderer = _interopRequireWildcard(require("prism-react-renderer"));
|
|
17
|
+
|
|
18
|
+
var _hooks = require("../hooks");
|
|
19
|
+
|
|
20
|
+
var _buildPostmanRequest = _interopRequireDefault(require("./../buildPostmanRequest"));
|
|
21
|
+
|
|
22
|
+
var _FloatingButton = _interopRequireDefault(require("./../FloatingButton"));
|
|
23
|
+
|
|
24
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.css"));
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
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); }
|
|
29
|
+
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
/* ============================================================================
|
|
33
|
+
* Copyright (c) Palo Alto Networks
|
|
34
|
+
*
|
|
35
|
+
* This source code is licensed under the MIT license found in the
|
|
36
|
+
* LICENSE file in the root directory of this source tree.
|
|
37
|
+
* ========================================================================== */
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
const languageSet = [{
|
|
40
|
+
tabName: "cURL",
|
|
41
|
+
highlight: "bash",
|
|
42
|
+
language: "curl",
|
|
43
|
+
variant: "curl",
|
|
44
|
+
options: {
|
|
45
|
+
longFormat: false,
|
|
46
|
+
followRedirect: true,
|
|
47
|
+
trimRequestBody: true
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
tabName: "Node",
|
|
51
|
+
highlight: "javascript",
|
|
52
|
+
language: "nodejs",
|
|
53
|
+
variant: "axios",
|
|
54
|
+
options: {
|
|
55
|
+
ES6_enabled: true,
|
|
56
|
+
followRedirect: true,
|
|
57
|
+
trimRequestBody: true
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
tabName: "Go",
|
|
61
|
+
highlight: "go",
|
|
62
|
+
language: "go",
|
|
63
|
+
variant: "native",
|
|
64
|
+
options: {
|
|
65
|
+
followRedirect: true,
|
|
66
|
+
trimRequestBody: true
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
tabName: "Python",
|
|
70
|
+
highlight: "python",
|
|
71
|
+
language: "python",
|
|
72
|
+
variant: "requests",
|
|
73
|
+
options: {
|
|
74
|
+
followRedirect: true,
|
|
75
|
+
trimRequestBody: true
|
|
76
|
+
}
|
|
77
|
+
}];
|
|
78
|
+
const languageTheme = {
|
|
79
|
+
plain: {
|
|
80
|
+
color: "var(--ifm-code-color)"
|
|
81
|
+
},
|
|
82
|
+
styles: [{
|
|
83
|
+
types: ["inserted", "attr-name"],
|
|
84
|
+
style: {
|
|
85
|
+
color: "var(--openapi-code-green)"
|
|
86
|
+
}
|
|
87
|
+
}, {
|
|
88
|
+
types: ["string", "url"],
|
|
89
|
+
style: {
|
|
90
|
+
color: "var(--openapi-code-green)"
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
types: ["builtin", "char", "constant", "function"],
|
|
94
|
+
style: {
|
|
95
|
+
color: "var(--openapi-code-blue)"
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
types: ["punctuation", "operator"],
|
|
99
|
+
style: {
|
|
100
|
+
color: "var(--openapi-code-dim)"
|
|
101
|
+
}
|
|
102
|
+
}, {
|
|
103
|
+
types: ["class-name"],
|
|
104
|
+
style: {
|
|
105
|
+
color: "var(--openapi-code-orange)"
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
types: ["tag", "arrow", "keyword"],
|
|
109
|
+
style: {
|
|
110
|
+
color: "var(--openapi-code-purple)"
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
types: ["boolean"],
|
|
114
|
+
style: {
|
|
115
|
+
color: "var(--openapi-code-red)"
|
|
116
|
+
}
|
|
117
|
+
}]
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
function Curl({
|
|
121
|
+
postman,
|
|
122
|
+
codeSamples
|
|
123
|
+
}) {
|
|
124
|
+
var _ref, _siteConfig$themeConf;
|
|
125
|
+
|
|
126
|
+
// TODO: match theme for vscode.
|
|
127
|
+
const {
|
|
128
|
+
siteConfig
|
|
129
|
+
} = (0, _useDocusaurusContext.default)();
|
|
130
|
+
const [copyText, setCopyText] = (0, _react.useState)("Copy");
|
|
131
|
+
const contentType = (0, _hooks.useTypedSelector)(state => state.contentType.value);
|
|
132
|
+
const accept = (0, _hooks.useTypedSelector)(state => state.accept.value);
|
|
133
|
+
const server = (0, _hooks.useTypedSelector)(state => state.server.value);
|
|
134
|
+
const body = (0, _hooks.useTypedSelector)(state => state.body);
|
|
135
|
+
const pathParams = (0, _hooks.useTypedSelector)(state => state.params.path);
|
|
136
|
+
const queryParams = (0, _hooks.useTypedSelector)(state => state.params.query);
|
|
137
|
+
const cookieParams = (0, _hooks.useTypedSelector)(state => state.params.cookie);
|
|
138
|
+
const headerParams = (0, _hooks.useTypedSelector)(state => state.params.header);
|
|
139
|
+
const auth = (0, _hooks.useTypedSelector)(state => state.auth); // TODO
|
|
140
|
+
|
|
141
|
+
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];
|
|
142
|
+
const [language, setLanguage] = (0, _react.useState)(langs[0]);
|
|
143
|
+
const [codeText, setCodeText] = (0, _react.useState)("");
|
|
144
|
+
(0, _react.useEffect)(() => {
|
|
145
|
+
if (language && !!language.options) {
|
|
146
|
+
const postmanRequest = (0, _buildPostmanRequest.default)(postman, {
|
|
147
|
+
queryParams,
|
|
148
|
+
pathParams,
|
|
149
|
+
cookieParams,
|
|
150
|
+
contentType,
|
|
151
|
+
accept,
|
|
152
|
+
headerParams,
|
|
153
|
+
body,
|
|
154
|
+
server,
|
|
155
|
+
auth
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
_postmanCodeGenerators.default.convert(language.language, language.variant, postmanRequest, language.options, (error, snippet) => {
|
|
159
|
+
if (error) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
setCodeText(snippet);
|
|
164
|
+
});
|
|
165
|
+
} else if (language && !!language.source) {
|
|
166
|
+
setCodeText(language.source);
|
|
167
|
+
} else {
|
|
168
|
+
setCodeText("");
|
|
169
|
+
}
|
|
170
|
+
}, [accept, body, contentType, cookieParams, headerParams, language, pathParams, postman, queryParams, server, auth]);
|
|
171
|
+
const ref = (0, _react.useRef)(null);
|
|
172
|
+
|
|
173
|
+
const handleCurlCopy = () => {
|
|
174
|
+
var _ref$current;
|
|
175
|
+
|
|
176
|
+
setCopyText("Copied");
|
|
177
|
+
setTimeout(() => {
|
|
178
|
+
setCopyText("Copy");
|
|
179
|
+
}, 2000);
|
|
180
|
+
|
|
181
|
+
if ((_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.innerText) {
|
|
182
|
+
navigator.clipboard.writeText(ref.current.innerText);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
if (language === undefined) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return <>
|
|
191
|
+
<div className={(0, _clsx.default)(_stylesModule.default.buttonGroup, "api-code-tab-group")}>
|
|
192
|
+
{langs.map(lang => {
|
|
193
|
+
return <button key={lang.tabName || lang.label} className={(0, _clsx.default)(language === lang ? _stylesModule.default.selected : undefined, language === lang ? "api-code-tab--active" : undefined, "api-code-tab")} onClick={() => setLanguage(lang)}>
|
|
194
|
+
{lang.tabName || lang.label}
|
|
195
|
+
</button>;
|
|
196
|
+
})}
|
|
197
|
+
</div>
|
|
198
|
+
|
|
199
|
+
<_prismReactRenderer.default {..._prismReactRenderer.defaultProps} theme={languageTheme} code={codeText} language={language.highlight || language.lang}>
|
|
200
|
+
{({
|
|
201
|
+
className,
|
|
202
|
+
tokens,
|
|
203
|
+
getLineProps,
|
|
204
|
+
getTokenProps
|
|
205
|
+
}) => <_FloatingButton.default onClick={handleCurlCopy} label={copyText}>
|
|
206
|
+
<pre className={className} style={{
|
|
207
|
+
background: "var(--openapi-card-background-color)",
|
|
208
|
+
paddingRight: "60px",
|
|
209
|
+
borderRadius: "2px 2px var(--openapi-card-border-radius) var(--openapi-card-border-radius)"
|
|
210
|
+
}}>
|
|
211
|
+
<code ref={ref}>
|
|
212
|
+
{tokens.map((line, i) => <span {...getLineProps({
|
|
213
|
+
line,
|
|
214
|
+
key: i
|
|
215
|
+
})}>
|
|
216
|
+
{line.map((token, key) => {
|
|
217
|
+
if (token.types.includes("arrow")) {
|
|
218
|
+
token.types = ["arrow"];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return <span {...getTokenProps({
|
|
222
|
+
token,
|
|
223
|
+
key
|
|
224
|
+
})} />;
|
|
225
|
+
})}
|
|
226
|
+
{"\n"}
|
|
227
|
+
</span>)}
|
|
228
|
+
</code>
|
|
229
|
+
</pre>
|
|
230
|
+
</_FloatingButton.default>}
|
|
231
|
+
</_prismReactRenderer.default>
|
|
232
|
+
</>;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
var _default = Curl;
|
|
236
|
+
exports.default = _default;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
.buttonGroup {
|
|
2
|
+
background: var(--openapi-card-background-color);
|
|
3
|
+
color: var(--ifm-pre-color);
|
|
4
|
+
font-family: var(--ifm-font-family-monospace);
|
|
5
|
+
/* font-size: var(--ifm-code-font-size); */
|
|
6
|
+
/* line-height: var(--ifm-pre-line-height); */
|
|
7
|
+
/* margin-bottom: calc(var(--ifm-spacing-vertical) / 4); */
|
|
8
|
+
margin-bottom: 1px;
|
|
9
|
+
margin-top: 0;
|
|
10
|
+
border-radius: var(--openapi-card-border-radius)
|
|
11
|
+
var(--openapi-card-border-radius) 2px 2px;
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: flex-end;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.buttonGroup button {
|
|
17
|
+
-webkit-appearance: none;
|
|
18
|
+
-moz-appearance: none;
|
|
19
|
+
appearance: none;
|
|
20
|
+
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
/* font-size: calc(0.875rem * var(--ifm-button-size-multiplier)); */
|
|
23
|
+
/* line-height: 1.5; */
|
|
24
|
+
/* font-weight: var(--ifm-button-font-weight); */
|
|
25
|
+
|
|
26
|
+
/* font-size: var(--ifm-code-font-size); */
|
|
27
|
+
font-size: 13.3333px;
|
|
28
|
+
line-height: var(--ifm-pre-line-height);
|
|
29
|
+
font-weight: var(--ifm-font-weight-semibold);
|
|
30
|
+
|
|
31
|
+
padding: calc(
|
|
32
|
+
var(--ifm-button-padding-vertical) * var(--ifm-button-size-multiplier)
|
|
33
|
+
)
|
|
34
|
+
calc(
|
|
35
|
+
var(--ifm-button-padding-horizontal) * var(--ifm-button-size-multiplier)
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
text-align: center;
|
|
39
|
+
|
|
40
|
+
transition: color var(--ifm-button-transition-duration)
|
|
41
|
+
cubic-bezier(0.08, 0.52, 0.52, 1),
|
|
42
|
+
background var(--ifm-button-transition-duration)
|
|
43
|
+
cubic-bezier(0.08, 0.52, 0.52, 1),
|
|
44
|
+
border-color var(--ifm-button-transition-duration)
|
|
45
|
+
cubic-bezier(0.08, 0.52, 0.52, 1);
|
|
46
|
+
-webkit-user-select: none;
|
|
47
|
+
user-select: none;
|
|
48
|
+
white-space: nowrap;
|
|
49
|
+
|
|
50
|
+
background: transparent;
|
|
51
|
+
|
|
52
|
+
color: var(--ifm-menu-color);
|
|
53
|
+
border: 0px solid transparent;
|
|
54
|
+
/* border-radius: var(--ifm-pre-border-radius); */
|
|
55
|
+
|
|
56
|
+
--margin: 0.25rem;
|
|
57
|
+
|
|
58
|
+
border-radius: calc(var(--margin));
|
|
59
|
+
/* border-radius: 0.25rem; */
|
|
60
|
+
|
|
61
|
+
display: block;
|
|
62
|
+
width: 100%;
|
|
63
|
+
|
|
64
|
+
/* margin: 2px; */
|
|
65
|
+
margin: var(--margin);
|
|
66
|
+
margin-right: 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.buttonGroup button:last-child {
|
|
70
|
+
margin-right: 0.25rem;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.buttonGroup button:hover {
|
|
74
|
+
background: var(--ifm-menu-color-background-active);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.buttonGroup button:focus {
|
|
78
|
+
outline: 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.buttonGroup button.selected {
|
|
82
|
+
background: var(--ifm-menu-color-background-active);
|
|
83
|
+
color: var(--ifm-menu-color-active);
|
|
84
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
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 _hooks = require("../hooks");
|
|
11
|
+
|
|
12
|
+
var _slice = require("../Response/slice");
|
|
13
|
+
|
|
14
|
+
var _buildPostmanRequest = _interopRequireDefault(require("./../buildPostmanRequest"));
|
|
15
|
+
|
|
16
|
+
var _makeRequest = _interopRequireDefault(require("./makeRequest"));
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
/* ============================================================================
|
|
21
|
+
* Copyright (c) Palo Alto Networks
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
* ========================================================================== */
|
|
26
|
+
function validateRequest(params) {
|
|
27
|
+
for (let paramList of Object.values(params)) {
|
|
28
|
+
for (let param of paramList) {
|
|
29
|
+
if (param.required && !param.value) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function Execute({
|
|
39
|
+
postman,
|
|
40
|
+
proxy
|
|
41
|
+
}) {
|
|
42
|
+
const pathParams = (0, _hooks.useTypedSelector)(state => state.params.path);
|
|
43
|
+
const queryParams = (0, _hooks.useTypedSelector)(state => state.params.query);
|
|
44
|
+
const cookieParams = (0, _hooks.useTypedSelector)(state => state.params.cookie);
|
|
45
|
+
const headerParams = (0, _hooks.useTypedSelector)(state => state.params.header);
|
|
46
|
+
const contentType = (0, _hooks.useTypedSelector)(state => state.contentType.value);
|
|
47
|
+
const body = (0, _hooks.useTypedSelector)(state => state.body);
|
|
48
|
+
const accept = (0, _hooks.useTypedSelector)(state => state.accept.value);
|
|
49
|
+
const server = (0, _hooks.useTypedSelector)(state => state.server.value);
|
|
50
|
+
const params = (0, _hooks.useTypedSelector)(state => state.params);
|
|
51
|
+
const auth = (0, _hooks.useTypedSelector)(state => state.auth);
|
|
52
|
+
const isValidRequest = validateRequest(params);
|
|
53
|
+
const dispatch = (0, _hooks.useTypedDispatch)();
|
|
54
|
+
const postmanRequest = (0, _buildPostmanRequest.default)(postman, {
|
|
55
|
+
queryParams,
|
|
56
|
+
pathParams,
|
|
57
|
+
cookieParams,
|
|
58
|
+
contentType,
|
|
59
|
+
accept,
|
|
60
|
+
headerParams,
|
|
61
|
+
body,
|
|
62
|
+
server,
|
|
63
|
+
auth
|
|
64
|
+
});
|
|
65
|
+
return <button className="button button--block button--primary" style={{
|
|
66
|
+
height: "48px",
|
|
67
|
+
marginBottom: "var(--ifm-spacing-vertical)"
|
|
68
|
+
}} disabled={!isValidRequest} onClick={async () => {
|
|
69
|
+
dispatch((0, _slice.setResponse)("loading..."));
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
const res = await (0, _makeRequest.default)(postmanRequest, proxy, body);
|
|
73
|
+
dispatch((0, _slice.setResponse)(res));
|
|
74
|
+
} catch (e) {
|
|
75
|
+
var _e$message;
|
|
76
|
+
|
|
77
|
+
dispatch((0, _slice.setResponse)((_e$message = e.message) !== null && _e$message !== void 0 ? _e$message : "Error fetching."));
|
|
78
|
+
}
|
|
79
|
+
}}>
|
|
80
|
+
Execute
|
|
81
|
+
</button>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var _default = Execute;
|
|
85
|
+
exports.default = _default;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
/* ============================================================================
|
|
9
|
+
* Copyright (c) Palo Alto Networks
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the MIT license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
* ========================================================================== */
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
async function loadImage(content) {
|
|
16
|
+
return new Promise((accept, reject) => {
|
|
17
|
+
const reader = new FileReader();
|
|
18
|
+
|
|
19
|
+
reader.onabort = () => {
|
|
20
|
+
console.log("file reading was aborted");
|
|
21
|
+
reject();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
reader.onerror = () => {
|
|
25
|
+
console.log("file reading has failed");
|
|
26
|
+
reject();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
reader.onload = () => {
|
|
30
|
+
// Do whatever you want with the file contents
|
|
31
|
+
const binaryStr = reader.result;
|
|
32
|
+
accept(binaryStr);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
reader.readAsArrayBuffer(content);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function makeRequest(request, proxy, _body) {
|
|
40
|
+
var _request$body;
|
|
41
|
+
|
|
42
|
+
const headers = request.toJSON().header;
|
|
43
|
+
let myHeaders = new Headers();
|
|
44
|
+
|
|
45
|
+
if (headers) {
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
headers.forEach(header => {
|
|
48
|
+
if (header.key && header.value) {
|
|
49
|
+
myHeaders.append(header.key, header.value);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
} // The following code handles multiple files in the same formdata param.
|
|
53
|
+
// It removes the form data params where the src property is an array of filepath strings
|
|
54
|
+
// Splits that array into different form data params with src set as a single filepath string
|
|
55
|
+
// TODO:
|
|
56
|
+
// if (request.body && request.body.mode === 'formdata') {
|
|
57
|
+
// let formdata = request.body.formdata,
|
|
58
|
+
// formdataArray = [];
|
|
59
|
+
// formdata.members.forEach((param) => {
|
|
60
|
+
// let key = param.key,
|
|
61
|
+
// type = param.type,
|
|
62
|
+
// disabled = param.disabled,
|
|
63
|
+
// contentType = param.contentType;
|
|
64
|
+
// // check if type is file or text
|
|
65
|
+
// if (type === 'file') {
|
|
66
|
+
// // if src is not of type string we check for array(multiple files)
|
|
67
|
+
// if (typeof param.src !== 'string') {
|
|
68
|
+
// // if src is an array(not empty), iterate over it and add files as separate form fields
|
|
69
|
+
// if (Array.isArray(param.src) && param.src.length) {
|
|
70
|
+
// param.src.forEach((filePath) => {
|
|
71
|
+
// addFormParam(
|
|
72
|
+
// formdataArray,
|
|
73
|
+
// key,
|
|
74
|
+
// param.type,
|
|
75
|
+
// filePath,
|
|
76
|
+
// disabled,
|
|
77
|
+
// contentType
|
|
78
|
+
// );
|
|
79
|
+
// });
|
|
80
|
+
// }
|
|
81
|
+
// // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
|
|
82
|
+
// else {
|
|
83
|
+
// addFormParam(
|
|
84
|
+
// formdataArray,
|
|
85
|
+
// key,
|
|
86
|
+
// param.type,
|
|
87
|
+
// '/path/to/file',
|
|
88
|
+
// disabled,
|
|
89
|
+
// contentType
|
|
90
|
+
// );
|
|
91
|
+
// }
|
|
92
|
+
// }
|
|
93
|
+
// // if src is string, directly add the param with src as filepath
|
|
94
|
+
// else {
|
|
95
|
+
// addFormParam(
|
|
96
|
+
// formdataArray,
|
|
97
|
+
// key,
|
|
98
|
+
// param.type,
|
|
99
|
+
// param.src,
|
|
100
|
+
// disabled,
|
|
101
|
+
// contentType
|
|
102
|
+
// );
|
|
103
|
+
// }
|
|
104
|
+
// }
|
|
105
|
+
// // if type is text, directly add it to formdata array
|
|
106
|
+
// else {
|
|
107
|
+
// addFormParam(
|
|
108
|
+
// formdataArray,
|
|
109
|
+
// key,
|
|
110
|
+
// param.type,
|
|
111
|
+
// param.value,
|
|
112
|
+
// disabled,
|
|
113
|
+
// contentType
|
|
114
|
+
// );
|
|
115
|
+
// }
|
|
116
|
+
// });
|
|
117
|
+
// request.body.update({
|
|
118
|
+
// mode: 'formdata',
|
|
119
|
+
// formdata: formdataArray,
|
|
120
|
+
// });
|
|
121
|
+
// }
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
const body = (_request$body = request.body) === null || _request$body === void 0 ? void 0 : _request$body.toJSON();
|
|
125
|
+
let myBody = undefined;
|
|
126
|
+
|
|
127
|
+
if (body !== undefined && Object.keys(body).length > 0) {
|
|
128
|
+
switch (body.mode) {
|
|
129
|
+
case "urlencoded":
|
|
130
|
+
{
|
|
131
|
+
myBody = new URLSearchParams();
|
|
132
|
+
|
|
133
|
+
if (Array.isArray(body.urlencoded)) {
|
|
134
|
+
for (const data of body.urlencoded) {
|
|
135
|
+
if (data.key && data.value) {
|
|
136
|
+
myBody.append(data.key, data.value);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
case "raw":
|
|
145
|
+
{
|
|
146
|
+
var _body$raw;
|
|
147
|
+
|
|
148
|
+
myBody = ((_body$raw = body.raw) !== null && _body$raw !== void 0 ? _body$raw : "").toString();
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
case "formdata":
|
|
153
|
+
{
|
|
154
|
+
myBody = new FormData();
|
|
155
|
+
|
|
156
|
+
if (Array.isArray(body.formdata)) {
|
|
157
|
+
for (const data of body.formdata) {
|
|
158
|
+
if (data.key && data.value) {
|
|
159
|
+
myBody.append(data.key, data.value);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
case "file":
|
|
168
|
+
{
|
|
169
|
+
var _body$content;
|
|
170
|
+
|
|
171
|
+
if (_body.type === "raw" && ((_body$content = _body.content) === null || _body$content === void 0 ? void 0 : _body$content.type) === "file") {
|
|
172
|
+
myBody = await loadImage(_body.content.value.content);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
default:
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const requestOptions = {
|
|
184
|
+
method: request.method,
|
|
185
|
+
headers: myHeaders,
|
|
186
|
+
body: myBody
|
|
187
|
+
};
|
|
188
|
+
let finalUrl = request.url.toString();
|
|
189
|
+
|
|
190
|
+
if (proxy) {
|
|
191
|
+
// Ensure the proxy ends with a slash.
|
|
192
|
+
let normalizedProxy = proxy.replace(/\/$/, "") + "/";
|
|
193
|
+
finalUrl = normalizedProxy + request.url.toString();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return await fetch(finalUrl, requestOptions).then(response => {
|
|
197
|
+
return response.text();
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
var _default = makeRequest;
|
|
202
|
+
exports.default = _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 _stylesModule = _interopRequireDefault(require("./styles.module.css"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
/* ============================================================================
|
|
15
|
+
* Copyright (c) Palo Alto Networks
|
|
16
|
+
*
|
|
17
|
+
* This source code is licensed under the MIT license found in the
|
|
18
|
+
* LICENSE file in the root directory of this source tree.
|
|
19
|
+
* ========================================================================== */
|
|
20
|
+
function FloatingButton({
|
|
21
|
+
label,
|
|
22
|
+
onClick,
|
|
23
|
+
children
|
|
24
|
+
}) {
|
|
25
|
+
return <div className={_stylesModule.default.floatingButton}>
|
|
26
|
+
{label && <button onClick={onClick}>{label}</button>}
|
|
27
|
+
{children}
|
|
28
|
+
</div>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var _default = FloatingButton;
|
|
32
|
+
exports.default = _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.floatingButton {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.floatingButton button {
|
|
6
|
+
position: relative;
|
|
7
|
+
background: rgba(25, 26, 27, 0.9);
|
|
8
|
+
border: none;
|
|
9
|
+
border-radius: var(--ifm-global-radius);
|
|
10
|
+
color: var(--ifm-color-white);
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
outline: none;
|
|
13
|
+
padding: 0.4rem 0.5rem;
|
|
14
|
+
opacity: 0;
|
|
15
|
+
visibility: hidden;
|
|
16
|
+
transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out,
|
|
17
|
+
bottom 0.2s ease-in-out;
|
|
18
|
+
position: absolute;
|
|
19
|
+
top: calc(var(--ifm-pre-padding) / 2);
|
|
20
|
+
right: calc(var(--ifm-pre-padding) / 2);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.floatingButton:hover button {
|
|
24
|
+
visibility: visible;
|
|
25
|
+
opacity: 1;
|
|
26
|
+
}
|