docusaurus-theme-openapi-docs 0.0.0-348 → 0.0.0-351
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/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/postman-code-generators.d.ts +9 -0
- package/lib/react-magic-dropzone.d.ts +9 -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/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 +235 -0
- package/lib/theme/ApiDemoPanel/Curl/styles.module.css +84 -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 +96 -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 +69 -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 +332 -0
- package/lib/theme/ApiDemoPanel/hooks.js +20 -0
- package/lib/theme/ApiDemoPanel/index.js +132 -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 +113 -0
- package/lib/theme/ApiTabs/index.js +258 -0
- package/lib/theme/ApiTabs/styles.module.css +118 -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-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/postman-code-generators.d.ts +9 -0
- package/lib-next/react-magic-dropzone.d.ts +9 -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/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 +262 -0
- package/lib-next/theme/ApiDemoPanel/Curl/styles.module.css +84 -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 +112 -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 +71 -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 +313 -0
- package/lib-next/theme/ApiDemoPanel/hooks.js +9 -0
- package/lib-next/theme/ApiDemoPanel/index.js +108 -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 +113 -0
- package/lib-next/theme/ApiTabs/index.js +258 -0
- package/lib-next/theme/ApiTabs/styles.module.css +118 -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-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 +3 -3
- package/src/theme/ApiDemoPanel/SecuritySchemes/index.tsx +26 -3
- package/src/theme/ApiDemoPanel/buildPostmanRequest.ts +5 -1
- package/src/theme/ApiDemoPanel/Authorization/index.tsx +0 -211
- package/src/theme/ApiDemoPanel/Execute/index.tsx +0 -87
- package/src/theme/ApiDemoPanel/Execute/makeRequest.ts +0 -182
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,9 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
// TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
|
|
9
|
+
declare module "@paloaltonetworks/postman-code-generators";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
// TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
|
|
9
|
+
declare module "react-magic-dropzone";
|
|
@@ -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,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createAuth = createAuth;
|
|
7
|
+
exports.slice = exports.setSelectedAuth = exports.setAuthData = exports.default = void 0;
|
|
8
|
+
|
|
9
|
+
var _toolkit = require("@reduxjs/toolkit");
|
|
10
|
+
|
|
11
|
+
var _storageUtils = require("../storage-utils");
|
|
12
|
+
|
|
13
|
+
var _authTypes = require("./auth-types");
|
|
14
|
+
|
|
15
|
+
/* ============================================================================
|
|
16
|
+
* Copyright (c) Palo Alto Networks
|
|
17
|
+
*
|
|
18
|
+
* This source code is licensed under the MIT license found in the
|
|
19
|
+
* LICENSE file in the root directory of this source tree.
|
|
20
|
+
* ========================================================================== */
|
|
21
|
+
// The global definitions
|
|
22
|
+
// "securitySchemes": {
|
|
23
|
+
// "BearerAuth": { "type": "http", "scheme": "BeAreR" },
|
|
24
|
+
// "BasicAuth": { "type": "http", "scheme": "basic" }
|
|
25
|
+
// },
|
|
26
|
+
// The operation level requirements
|
|
27
|
+
// "security": [
|
|
28
|
+
// { "BearerAuth": [] },
|
|
29
|
+
// { "BearerAuth": [], "BasicAuth": [] }
|
|
30
|
+
// ],
|
|
31
|
+
// SLICE_STATE
|
|
32
|
+
// data:
|
|
33
|
+
// BearerAuth:
|
|
34
|
+
// token=xxx
|
|
35
|
+
// BasicAuth:
|
|
36
|
+
// username=xxx
|
|
37
|
+
// password=xxx
|
|
38
|
+
//
|
|
39
|
+
// options:
|
|
40
|
+
// "BearerAuth": [{ key: "BearerAuth", scopes: [], ...rest }]
|
|
41
|
+
// "BearerAuth and BasicAuth": [{ key: "BearerAuth", scopes: [], ...rest }, { key: "BasicAuth", scopes: [], ...rest }]
|
|
42
|
+
//
|
|
43
|
+
// selected: "BearerAuth and BasicAuth"
|
|
44
|
+
// LOCAL_STORAGE
|
|
45
|
+
// hash(SLICE_STATE.options) -> "BearerAuth and BasicAuth"
|
|
46
|
+
// BearerAuth -> { token: xxx }
|
|
47
|
+
// BasicAuth -> { username: xxx, password: xxx }
|
|
48
|
+
function createAuth({
|
|
49
|
+
security,
|
|
50
|
+
securitySchemes,
|
|
51
|
+
options: opts
|
|
52
|
+
}) {
|
|
53
|
+
var _persisted;
|
|
54
|
+
|
|
55
|
+
const storage = (0, _storageUtils.createStorage)(opts === null || opts === void 0 ? void 0 : opts.authPersistance);
|
|
56
|
+
let data = {};
|
|
57
|
+
let options = {};
|
|
58
|
+
|
|
59
|
+
for (const option of security !== null && security !== void 0 ? security : []) {
|
|
60
|
+
const id = Object.keys(option).join(" and ");
|
|
61
|
+
|
|
62
|
+
for (const [schemeID, scopes] of Object.entries(option)) {
|
|
63
|
+
const scheme = securitySchemes === null || securitySchemes === void 0 ? void 0 : securitySchemes[schemeID];
|
|
64
|
+
|
|
65
|
+
if (scheme) {
|
|
66
|
+
if (options[id] === undefined) {
|
|
67
|
+
options[id] = [];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const dataKeys = (0, _authTypes.getAuthDataKeys)(scheme);
|
|
71
|
+
|
|
72
|
+
for (const key of dataKeys) {
|
|
73
|
+
if (data[schemeID] === undefined) {
|
|
74
|
+
data[schemeID] = {};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
let persisted = undefined;
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
var _storage$getItem;
|
|
81
|
+
|
|
82
|
+
persisted = JSON.parse((_storage$getItem = storage.getItem(schemeID)) !== null && _storage$getItem !== void 0 ? _storage$getItem : "")[key];
|
|
83
|
+
} catch {}
|
|
84
|
+
|
|
85
|
+
data[schemeID][key] = persisted;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
options[id].push({ ...scheme,
|
|
89
|
+
key: schemeID,
|
|
90
|
+
scopes
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let persisted = undefined;
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
var _storage$getItem2;
|
|
100
|
+
|
|
101
|
+
persisted = (_storage$getItem2 = storage.getItem((0, _storageUtils.hashArray)(Object.keys(options)))) !== null && _storage$getItem2 !== void 0 ? _storage$getItem2 : undefined;
|
|
102
|
+
} catch {}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
data,
|
|
106
|
+
options,
|
|
107
|
+
selected: (_persisted = persisted) !== null && _persisted !== void 0 ? _persisted : Object.keys(options)[0]
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const initialState = {};
|
|
112
|
+
const slice = (0, _toolkit.createSlice)({
|
|
113
|
+
name: "auth",
|
|
114
|
+
initialState,
|
|
115
|
+
reducers: {
|
|
116
|
+
setAuthData: (state, action) => {
|
|
117
|
+
const {
|
|
118
|
+
scheme,
|
|
119
|
+
key,
|
|
120
|
+
value
|
|
121
|
+
} = action.payload;
|
|
122
|
+
state.data[scheme][key] = value;
|
|
123
|
+
},
|
|
124
|
+
setSelectedAuth: (state, action) => {
|
|
125
|
+
state.selected = action.payload;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
exports.slice = slice;
|
|
130
|
+
const {
|
|
131
|
+
setAuthData,
|
|
132
|
+
setSelectedAuth
|
|
133
|
+
} = slice.actions;
|
|
134
|
+
exports.setSelectedAuth = setSelectedAuth;
|
|
135
|
+
exports.setAuthData = setAuthData;
|
|
136
|
+
var _default = slice.reducer;
|
|
137
|
+
exports.default = _default;
|
|
@@ -0,0 +1,185 @@
|
|
|
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 _ContentType = _interopRequireDefault(require("../ContentType"));
|
|
11
|
+
|
|
12
|
+
var _FormSelect = _interopRequireDefault(require("../FormSelect"));
|
|
13
|
+
|
|
14
|
+
var _hooks = require("../hooks");
|
|
15
|
+
|
|
16
|
+
var _FormFileUpload = _interopRequireDefault(require("./../FormFileUpload"));
|
|
17
|
+
|
|
18
|
+
var _FormItem = _interopRequireDefault(require("./../FormItem"));
|
|
19
|
+
|
|
20
|
+
var _FormTextInput = _interopRequireDefault(require("./../FormTextInput"));
|
|
21
|
+
|
|
22
|
+
var _VSCode = _interopRequireDefault(require("./../VSCode"));
|
|
23
|
+
|
|
24
|
+
var _slice = require("./slice");
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
/* ============================================================================
|
|
29
|
+
* Copyright (c) Palo Alto Networks
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
* ========================================================================== */
|
|
34
|
+
function BodyWrap({
|
|
35
|
+
requestBodyMetadata,
|
|
36
|
+
jsonRequestBodyExample
|
|
37
|
+
}) {
|
|
38
|
+
const contentType = (0, _hooks.useTypedSelector)(state => state.contentType.value); // NOTE: We used to check if body was required, but opted to always show the request body
|
|
39
|
+
// to reduce confusion, see: https://github.com/cloud-annotations/docusaurus-openapi/issues/145
|
|
40
|
+
// No body
|
|
41
|
+
|
|
42
|
+
if (contentType === undefined) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return <>
|
|
47
|
+
<_ContentType.default />
|
|
48
|
+
<Body requestBodyMetadata={requestBodyMetadata} jsonRequestBodyExample={jsonRequestBodyExample} />
|
|
49
|
+
</>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function Body({
|
|
53
|
+
requestBodyMetadata,
|
|
54
|
+
jsonRequestBodyExample
|
|
55
|
+
}) {
|
|
56
|
+
var _requestBodyMetadata$, _requestBodyMetadata$2;
|
|
57
|
+
|
|
58
|
+
const contentType = (0, _hooks.useTypedSelector)(state => state.contentType.value);
|
|
59
|
+
const dispatch = (0, _hooks.useTypedDispatch)(); // Lot's of possible content-types:
|
|
60
|
+
// - application/json
|
|
61
|
+
// - application/xml
|
|
62
|
+
// - text/plain
|
|
63
|
+
// - text/css
|
|
64
|
+
// - text/html
|
|
65
|
+
// - text/javascript
|
|
66
|
+
// - application/javascript
|
|
67
|
+
// - multipart/form-data
|
|
68
|
+
// - application/x-www-form-urlencoded
|
|
69
|
+
// - image/svg+xml;charset=US-ASCII
|
|
70
|
+
// Show editor:
|
|
71
|
+
// - application/json
|
|
72
|
+
// - application/xml
|
|
73
|
+
// - */*
|
|
74
|
+
// Show form:
|
|
75
|
+
// - multipart/form-data
|
|
76
|
+
// - application/x-www-form-urlencoded
|
|
77
|
+
|
|
78
|
+
const schema = requestBodyMetadata === null || requestBodyMetadata === void 0 ? void 0 : (_requestBodyMetadata$ = requestBodyMetadata.content) === null || _requestBodyMetadata$ === void 0 ? void 0 : (_requestBodyMetadata$2 = _requestBodyMetadata$[contentType]) === null || _requestBodyMetadata$2 === void 0 ? void 0 : _requestBodyMetadata$2.schema;
|
|
79
|
+
|
|
80
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.format) === "binary") {
|
|
81
|
+
return <_FormItem.default label="Body">
|
|
82
|
+
<_FormFileUpload.default placeholder={schema.description || "Body"} onChange={file => {
|
|
83
|
+
if (file === undefined) {
|
|
84
|
+
dispatch((0, _slice.clearRawBody)());
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
dispatch((0, _slice.setFileRawBody)({
|
|
89
|
+
src: `/path/to/${file.name}`,
|
|
90
|
+
content: file
|
|
91
|
+
}));
|
|
92
|
+
}} />
|
|
93
|
+
</_FormItem.default>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if ((contentType === "multipart/form-data" || contentType === "application/x-www-form-urlencoded") && (schema === null || schema === void 0 ? void 0 : schema.type) === "object") {
|
|
97
|
+
var _schema$properties;
|
|
98
|
+
|
|
99
|
+
return <_FormItem.default label="Body">
|
|
100
|
+
<div style={{
|
|
101
|
+
marginTop: "calc(var(--ifm-pre-padding) / 2)",
|
|
102
|
+
borderRadius: "4px",
|
|
103
|
+
padding: "var(--ifm-pre-padding)",
|
|
104
|
+
border: "1px solid var(--openapi-monaco-border-color)"
|
|
105
|
+
}}>
|
|
106
|
+
{Object.entries((_schema$properties = schema.properties) !== null && _schema$properties !== void 0 ? _schema$properties : {}).map(([key, val]) => {
|
|
107
|
+
if (val.format === "binary") {
|
|
108
|
+
return <_FormItem.default key={key} label={key}>
|
|
109
|
+
<_FormFileUpload.default placeholder={val.description || key} onChange={file => {
|
|
110
|
+
if (file === undefined) {
|
|
111
|
+
dispatch((0, _slice.clearFormBodyKey)(key));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
dispatch((0, _slice.setFileFormBody)({
|
|
116
|
+
key: key,
|
|
117
|
+
value: {
|
|
118
|
+
src: `/path/to/${file.name}`,
|
|
119
|
+
content: file
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
122
|
+
}} />
|
|
123
|
+
</_FormItem.default>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (val.enum) {
|
|
127
|
+
return <_FormItem.default key={key} label={key}>
|
|
128
|
+
<_FormSelect.default options={["---", ...val.enum]} onChange={e => {
|
|
129
|
+
const val = e.target.value;
|
|
130
|
+
|
|
131
|
+
if (val === "---") {
|
|
132
|
+
dispatch((0, _slice.clearFormBodyKey)(key));
|
|
133
|
+
} else {
|
|
134
|
+
dispatch((0, _slice.setStringFormBody)({
|
|
135
|
+
key: key,
|
|
136
|
+
value: val
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
}} />
|
|
140
|
+
</_FormItem.default>;
|
|
141
|
+
} // TODO: support all the other types.
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
return <_FormItem.default key={key} label={key}>
|
|
145
|
+
<_FormTextInput.default placeholder={val.description || key} onChange={e => {
|
|
146
|
+
dispatch((0, _slice.setStringFormBody)({
|
|
147
|
+
key: key,
|
|
148
|
+
value: e.target.value
|
|
149
|
+
}));
|
|
150
|
+
}} />
|
|
151
|
+
</_FormItem.default>;
|
|
152
|
+
})}
|
|
153
|
+
</div>
|
|
154
|
+
</_FormItem.default>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
let language = "plaintext";
|
|
158
|
+
let exampleBodyString = ""; //"body content";
|
|
159
|
+
|
|
160
|
+
if (contentType === "application/json") {
|
|
161
|
+
if (jsonRequestBodyExample) {
|
|
162
|
+
exampleBodyString = JSON.stringify(jsonRequestBodyExample, null, 2);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
language = "json";
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (contentType === "application/xml") {
|
|
169
|
+
language = "xml";
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return <_FormItem.default label="Body">
|
|
173
|
+
<_VSCode.default value={exampleBodyString} language={language} onChange={value => {
|
|
174
|
+
if (value.trim() === "") {
|
|
175
|
+
dispatch((0, _slice.clearRawBody)());
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
dispatch((0, _slice.setStringRawBody)(value));
|
|
180
|
+
}} />
|
|
181
|
+
</_FormItem.default>;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
var _default = BodyWrap;
|
|
185
|
+
exports.default = _default;
|