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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Palo Alto Networks
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/babel.config.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
env: {
|
|
10
|
+
// USED FOR NODE/RUNTIME
|
|
11
|
+
// maybe we should differenciate both cases because
|
|
12
|
+
// we mostly need to transpile some features so that node does not crash...
|
|
13
|
+
lib: {
|
|
14
|
+
presets: [
|
|
15
|
+
["@babel/preset-typescript", { isTSX: true, allExtensions: true }],
|
|
16
|
+
],
|
|
17
|
+
// Useful to transpile for older node versions
|
|
18
|
+
plugins: [
|
|
19
|
+
"@babel/plugin-transform-modules-commonjs",
|
|
20
|
+
"@babel/plugin-proposal-nullish-coalescing-operator",
|
|
21
|
+
"@babel/plugin-proposal-optional-chaining",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
// USED FOR JS SWIZZLE
|
|
26
|
+
// /lib-next folder is used as source to swizzle JS source code
|
|
27
|
+
// This JS code is created from TS source code
|
|
28
|
+
// This source code should look clean/human readable to be usable
|
|
29
|
+
"lib-next": {
|
|
30
|
+
presets: [
|
|
31
|
+
["@babel/preset-typescript", { isTSX: true, allExtensions: true }],
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = docusaurusThemeOpenAPI;
|
|
7
|
+
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
|
|
10
|
+
var _webpack = require("webpack");
|
|
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 docusaurusThemeOpenAPI() {
|
|
21
|
+
return {
|
|
22
|
+
name: "docusaurus-theme-openapi",
|
|
23
|
+
|
|
24
|
+
getThemePath() {
|
|
25
|
+
return _path.default.join(__dirname, "..", "lib-next", "theme");
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
getTypeScriptThemePath() {
|
|
29
|
+
return _path.default.resolve(__dirname, "..", "src", "theme");
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
configureWebpack() {
|
|
33
|
+
return {
|
|
34
|
+
plugins: [new _webpack.ProvidePlugin({
|
|
35
|
+
Buffer: [require.resolve("buffer/"), "Buffer"],
|
|
36
|
+
process: require.resolve("process/browser")
|
|
37
|
+
})],
|
|
38
|
+
resolve: {
|
|
39
|
+
fallback: {
|
|
40
|
+
buffer: require.resolve("buffer/"),
|
|
41
|
+
process: require.resolve("process/browser")
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createDescription = createDescription;
|
|
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
|
+
function createDescription(description) {
|
|
15
|
+
if (!description) {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return `\n\n${description}\n\n`;
|
|
20
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getQualifierMessage = getQualifierMessage;
|
|
7
|
+
exports.getSchemaName = getSchemaName;
|
|
8
|
+
|
|
9
|
+
/* ============================================================================
|
|
10
|
+
* Copyright (c) Palo Alto Networks
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the MIT license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
* ========================================================================== */
|
|
15
|
+
function prettyName(schema, circular) {
|
|
16
|
+
var _schema$title;
|
|
17
|
+
|
|
18
|
+
if (schema.$ref) {
|
|
19
|
+
return schema.$ref.replace("#/components/schemas/", "") + circular ? " (circular)" : "";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (schema.format) {
|
|
23
|
+
return schema.format;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (schema.allOf) {
|
|
27
|
+
return "object";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (schema.type === "object") {
|
|
31
|
+
var _schema$xml$name, _schema$xml;
|
|
32
|
+
|
|
33
|
+
return (_schema$xml$name = (_schema$xml = schema.xml) === null || _schema$xml === void 0 ? void 0 : _schema$xml.name) !== null && _schema$xml$name !== void 0 ? _schema$xml$name : schema.type;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (_schema$title = schema.title) !== null && _schema$title !== void 0 ? _schema$title : schema.type;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getSchemaName(schema, circular) {
|
|
40
|
+
var _prettyName;
|
|
41
|
+
|
|
42
|
+
if (schema.items) {
|
|
43
|
+
return prettyName(schema.items, circular) + "[]";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (_prettyName = prettyName(schema, circular)) !== null && _prettyName !== void 0 ? _prettyName : "";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getQualifierMessage(schema) {
|
|
50
|
+
// TODO:
|
|
51
|
+
// - maxItems
|
|
52
|
+
// - minItems
|
|
53
|
+
// - uniqueItems
|
|
54
|
+
// - maxProperties
|
|
55
|
+
// - minProperties
|
|
56
|
+
// - multipleOf
|
|
57
|
+
if (!schema) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (schema.items) {
|
|
62
|
+
return getQualifierMessage(schema.items);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let message = "**Possible values:** ";
|
|
66
|
+
let qualifierGroups = [];
|
|
67
|
+
|
|
68
|
+
if (schema.minLength || schema.maxLength) {
|
|
69
|
+
let lengthQualifier = "";
|
|
70
|
+
|
|
71
|
+
if (schema.minLength) {
|
|
72
|
+
lengthQualifier += `${schema.minLength} ≤ `;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
lengthQualifier += "length";
|
|
76
|
+
|
|
77
|
+
if (schema.maxLength) {
|
|
78
|
+
lengthQualifier += ` ≤ ${schema.maxLength}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
qualifierGroups.push(lengthQualifier);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (schema.minimum || schema.maximum || typeof schema.exclusiveMinimum === "number" || typeof schema.exclusiveMaximum === "number") {
|
|
85
|
+
let minmaxQualifier = "";
|
|
86
|
+
|
|
87
|
+
if (typeof schema.exclusiveMinimum === "number") {
|
|
88
|
+
minmaxQualifier += `${schema.exclusiveMinimum} < `;
|
|
89
|
+
} else if (schema.minimum && !schema.exclusiveMinimum) {
|
|
90
|
+
minmaxQualifier += `${schema.minimum} ≤ `;
|
|
91
|
+
} else if (schema.minimum && schema.exclusiveMinimum === true) {
|
|
92
|
+
minmaxQualifier += `${schema.minimum} < `;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
minmaxQualifier += "value";
|
|
96
|
+
|
|
97
|
+
if (typeof schema.exclusiveMaximum === "number") {
|
|
98
|
+
minmaxQualifier += ` < ${schema.exclusiveMaximum}`;
|
|
99
|
+
} else if (schema.maximum && !schema.exclusiveMaximum) {
|
|
100
|
+
minmaxQualifier += ` ≤ ${schema.maximum}`;
|
|
101
|
+
} else if (schema.maximum && schema.exclusiveMaximum === true) {
|
|
102
|
+
minmaxQualifier += ` < ${schema.maximum}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
qualifierGroups.push(minmaxQualifier);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (schema.pattern) {
|
|
109
|
+
qualifierGroups.push(`Value must match regular expression \`${schema.pattern}\``);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (schema.enum) {
|
|
113
|
+
qualifierGroups.push(`[${schema.enum.map(e => `\`${e}\``).join(", ")}]`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (qualifierGroups.length === 0) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return message + qualifierGroups.join(", ");
|
|
121
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.create = create;
|
|
7
|
+
exports.guard = guard;
|
|
8
|
+
exports.render = render;
|
|
9
|
+
|
|
10
|
+
/* ============================================================================
|
|
11
|
+
* Copyright (c) Palo Alto Networks
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the MIT license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
* ========================================================================== */
|
|
16
|
+
function create(tag, props) {
|
|
17
|
+
const {
|
|
18
|
+
children,
|
|
19
|
+
...rest
|
|
20
|
+
} = props;
|
|
21
|
+
let propString = "";
|
|
22
|
+
|
|
23
|
+
for (const [key, value] of Object.entries(rest)) {
|
|
24
|
+
propString += ` ${key}={${JSON.stringify(value)}}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return `<${tag}${propString}>${render(children)}</${tag}>`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function guard(value, cb) {
|
|
31
|
+
if (value) {
|
|
32
|
+
const children = cb(value);
|
|
33
|
+
return render(children);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return "";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function render(children) {
|
|
40
|
+
if (Array.isArray(children)) {
|
|
41
|
+
return children.filter(c => c !== undefined).join("");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return children !== null && children !== void 0 ? children : "";
|
|
45
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 _FormItem = _interopRequireDefault(require("./../FormItem"));
|
|
13
|
+
|
|
14
|
+
var _FormSelect = _interopRequireDefault(require("./../FormSelect"));
|
|
15
|
+
|
|
16
|
+
var _slice = require("./slice");
|
|
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 Accept() {
|
|
27
|
+
const value = (0, _hooks.useTypedSelector)(state => state.accept.value);
|
|
28
|
+
const options = (0, _hooks.useTypedSelector)(state => state.accept.options);
|
|
29
|
+
const dispatch = (0, _hooks.useTypedDispatch)();
|
|
30
|
+
|
|
31
|
+
if (options.length <= 1) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return <_FormItem.default label="Accept">
|
|
36
|
+
<_FormSelect.default value={value} options={options} onChange={e => dispatch((0, _slice.setAccept)(e.target.value))} />
|
|
37
|
+
</_FormItem.default>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var _default = Accept;
|
|
41
|
+
exports.default = _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.slice = exports.setAccept = exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _toolkit = require("@reduxjs/toolkit");
|
|
9
|
+
|
|
10
|
+
/* ============================================================================
|
|
11
|
+
* Copyright (c) Palo Alto Networks
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the MIT license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
* ========================================================================== */
|
|
16
|
+
const initialState = {};
|
|
17
|
+
const slice = (0, _toolkit.createSlice)({
|
|
18
|
+
name: "accept",
|
|
19
|
+
initialState,
|
|
20
|
+
reducers: {
|
|
21
|
+
setAccept: (state, action) => {
|
|
22
|
+
state.value = action.payload;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
exports.slice = slice;
|
|
27
|
+
const {
|
|
28
|
+
setAccept
|
|
29
|
+
} = slice.actions;
|
|
30
|
+
exports.setAccept = setAccept;
|
|
31
|
+
var _default = slice.reducer;
|
|
32
|
+
exports.default = _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAuthDataKeys = getAuthDataKeys;
|
|
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
|
+
function getAuthDataKeys(security) {
|
|
15
|
+
// Bearer Auth
|
|
16
|
+
if (security.type === "http" && security.scheme === "bearer") {
|
|
17
|
+
return ["token"];
|
|
18
|
+
} // Basic Auth
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
if (security.type === "http" && security.scheme === "basic") {
|
|
22
|
+
return ["username", "password"];
|
|
23
|
+
} // API Auth
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if (security.type === "apiKey") {
|
|
27
|
+
return ["apiKey"];
|
|
28
|
+
} // none
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
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 _clsx = _interopRequireDefault(require("clsx"));
|
|
11
|
+
|
|
12
|
+
var _FormItem = _interopRequireDefault(require("../FormItem"));
|
|
13
|
+
|
|
14
|
+
var _FormSelect = _interopRequireDefault(require("../FormSelect"));
|
|
15
|
+
|
|
16
|
+
var _FormTextInput = _interopRequireDefault(require("../FormTextInput"));
|
|
17
|
+
|
|
18
|
+
var _hooks = require("../hooks");
|
|
19
|
+
|
|
20
|
+
var _stylesModule = _interopRequireDefault(require("../styles.module.css"));
|
|
21
|
+
|
|
22
|
+
var _slice = require("./slice");
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
|
|
26
|
+
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); }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
/* ============================================================================
|
|
31
|
+
* Copyright (c) Palo Alto Networks
|
|
32
|
+
*
|
|
33
|
+
* This source code is licensed under the MIT license found in the
|
|
34
|
+
* LICENSE file in the root directory of this source tree.
|
|
35
|
+
* ========================================================================== */
|
|
36
|
+
function LockButton({
|
|
37
|
+
mode,
|
|
38
|
+
children,
|
|
39
|
+
style,
|
|
40
|
+
...rest
|
|
41
|
+
}) {
|
|
42
|
+
return <button className={(0, _clsx.default)("button", "button--primary", {
|
|
43
|
+
"button--outline": mode !== "locked"
|
|
44
|
+
})} style={{
|
|
45
|
+
marginLeft: "auto",
|
|
46
|
+
display: "flex",
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
marginBottom: "var(--ifm-spacing-vertical)",
|
|
49
|
+
...style
|
|
50
|
+
}} {...rest}>
|
|
51
|
+
<span>{children}</span>
|
|
52
|
+
|
|
53
|
+
<svg style={{
|
|
54
|
+
marginLeft: "12px",
|
|
55
|
+
width: "18px",
|
|
56
|
+
height: "18px",
|
|
57
|
+
fill: "currentColor"
|
|
58
|
+
}} viewBox="0 0 20 20" id={mode}>
|
|
59
|
+
{mode === "locked" ? <path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"></path> : <path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>}
|
|
60
|
+
</svg>
|
|
61
|
+
</button>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function validateData(selectedAuth, data) {
|
|
65
|
+
for (const scheme of selectedAuth) {
|
|
66
|
+
if (data[scheme.key] === undefined) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const hasMissingKeys = Object.values(data[scheme.key]).includes(undefined);
|
|
71
|
+
|
|
72
|
+
if (hasMissingKeys) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function Authorization() {
|
|
81
|
+
const [editing, setEditing] = (0, _react.useState)(false);
|
|
82
|
+
const data = (0, _hooks.useTypedSelector)(state => state.auth.data);
|
|
83
|
+
const options = (0, _hooks.useTypedSelector)(state => state.auth.options);
|
|
84
|
+
const selected = (0, _hooks.useTypedSelector)(state => state.auth.selected);
|
|
85
|
+
const dispatch = (0, _hooks.useTypedDispatch)();
|
|
86
|
+
|
|
87
|
+
if (selected === undefined) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const selectedAuth = options[selected];
|
|
92
|
+
const authenticated = validateData(selectedAuth, data);
|
|
93
|
+
const optionKeys = Object.keys(options);
|
|
94
|
+
|
|
95
|
+
if (editing) {
|
|
96
|
+
return <div className={_stylesModule.default.optionsPanel}>
|
|
97
|
+
{optionKeys.length > 1 && <_FormItem.default label="Security Scheme">
|
|
98
|
+
<_FormSelect.default options={optionKeys} value={selected} onChange={e => {
|
|
99
|
+
dispatch((0, _slice.setSelectedAuth)(e.target.value));
|
|
100
|
+
}} />
|
|
101
|
+
</_FormItem.default>}
|
|
102
|
+
{selectedAuth.map(a => {
|
|
103
|
+
if (a.type === "http" && a.scheme === "bearer") {
|
|
104
|
+
var _data$a$key$token;
|
|
105
|
+
|
|
106
|
+
return <_FormItem.default label="Bearer Token" key={selected + "-bearer"}>
|
|
107
|
+
<_FormTextInput.default placeholder="Bearer Token" value={(_data$a$key$token = data[a.key].token) !== null && _data$a$key$token !== void 0 ? _data$a$key$token : ""} onChange={e => {
|
|
108
|
+
const value = e.target.value.trim();
|
|
109
|
+
dispatch((0, _slice.setAuthData)({
|
|
110
|
+
scheme: a.key,
|
|
111
|
+
key: "token",
|
|
112
|
+
value: value ? value : undefined
|
|
113
|
+
}));
|
|
114
|
+
}} />
|
|
115
|
+
</_FormItem.default>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (a.type === "http" && a.scheme === "basic") {
|
|
119
|
+
var _data$a$key$username, _data$a$key$password;
|
|
120
|
+
|
|
121
|
+
return <_react.default.Fragment key={selected + "-basic"}>
|
|
122
|
+
<_FormItem.default label="Username">
|
|
123
|
+
<_FormTextInput.default placeholder="Username" value={(_data$a$key$username = data[a.key].username) !== null && _data$a$key$username !== void 0 ? _data$a$key$username : ""} onChange={e => {
|
|
124
|
+
const value = e.target.value.trim();
|
|
125
|
+
dispatch((0, _slice.setAuthData)({
|
|
126
|
+
scheme: a.key,
|
|
127
|
+
key: "username",
|
|
128
|
+
value: value ? value : undefined
|
|
129
|
+
}));
|
|
130
|
+
}} />
|
|
131
|
+
</_FormItem.default>
|
|
132
|
+
<_FormItem.default label="Password">
|
|
133
|
+
<_FormTextInput.default placeholder="Password" password value={(_data$a$key$password = data[a.key].password) !== null && _data$a$key$password !== void 0 ? _data$a$key$password : ""} onChange={e => {
|
|
134
|
+
const value = e.target.value.trim();
|
|
135
|
+
dispatch((0, _slice.setAuthData)({
|
|
136
|
+
scheme: a.key,
|
|
137
|
+
key: "password",
|
|
138
|
+
value: value ? value : undefined
|
|
139
|
+
}));
|
|
140
|
+
}} />
|
|
141
|
+
</_FormItem.default>
|
|
142
|
+
</_react.default.Fragment>;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return null;
|
|
146
|
+
})}
|
|
147
|
+
<LockButton mode="unlocked" style={{
|
|
148
|
+
marginTop: "var(--ifm-spacing-vertical)",
|
|
149
|
+
marginBottom: 0
|
|
150
|
+
}} onClick={() => {
|
|
151
|
+
setEditing(false);
|
|
152
|
+
}}>
|
|
153
|
+
Save
|
|
154
|
+
</LockButton>
|
|
155
|
+
</div>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (authenticated) {
|
|
159
|
+
return <LockButton mode="locked" onClick={() => {
|
|
160
|
+
setEditing(true);
|
|
161
|
+
}}>
|
|
162
|
+
Authorized
|
|
163
|
+
</LockButton>;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return <LockButton mode="unlocked" onClick={() => {
|
|
167
|
+
setEditing(true);
|
|
168
|
+
}}>
|
|
169
|
+
Authorize
|
|
170
|
+
</LockButton>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
var _default = Authorization;
|
|
174
|
+
exports.default = _default;
|