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,109 @@
|
|
|
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 _FloatingButton = _interopRequireDefault(require("../FloatingButton"));
|
|
11
|
+
|
|
12
|
+
var _hooks = require("../hooks");
|
|
13
|
+
|
|
14
|
+
var _FormItem = _interopRequireDefault(require("./../FormItem"));
|
|
15
|
+
|
|
16
|
+
var _FormSelect = _interopRequireDefault(require("./../FormSelect"));
|
|
17
|
+
|
|
18
|
+
var _FormTextInput = _interopRequireDefault(require("./../FormTextInput"));
|
|
19
|
+
|
|
20
|
+
var _slice = require("./slice");
|
|
21
|
+
|
|
22
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.css"));
|
|
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 Server() {
|
|
37
|
+
const [isEditing, setIsEditing] = (0, _react.useState)(false);
|
|
38
|
+
const value = (0, _hooks.useTypedSelector)(state => state.server.value);
|
|
39
|
+
const options = (0, _hooks.useTypedSelector)(state => state.server.options);
|
|
40
|
+
const dispatch = (0, _hooks.useTypedDispatch)();
|
|
41
|
+
|
|
42
|
+
if (options.length <= 0) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (options.length <= 1 && (value === null || value === void 0 ? void 0 : value.variables) === undefined) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!isEditing) {
|
|
51
|
+
let url = "";
|
|
52
|
+
|
|
53
|
+
if (value) {
|
|
54
|
+
url = value.url.replace(/\/$/, "");
|
|
55
|
+
|
|
56
|
+
if (value.variables) {
|
|
57
|
+
Object.keys(value.variables).forEach(variable => {
|
|
58
|
+
var _value$variables$vari, _value$variables;
|
|
59
|
+
|
|
60
|
+
url = url.replace(`{${variable}}`, (_value$variables$vari = (_value$variables = value.variables) === null || _value$variables === void 0 ? void 0 : _value$variables[variable].default) !== null && _value$variables$vari !== void 0 ? _value$variables$vari : "");
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return <_FloatingButton.default onClick={() => setIsEditing(true)} label="Edit">
|
|
66
|
+
<pre style={{
|
|
67
|
+
background: "var(--openapi-card-background-color)",
|
|
68
|
+
paddingRight: "60px"
|
|
69
|
+
}}>
|
|
70
|
+
<code>{url}</code>
|
|
71
|
+
</pre>
|
|
72
|
+
</_FloatingButton.default>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return <div className={_stylesModule.default.optionsPanel}>
|
|
76
|
+
<button className={_stylesModule.default.showMoreButton} onClick={() => setIsEditing(false)}>
|
|
77
|
+
Hide
|
|
78
|
+
</button>
|
|
79
|
+
<_FormItem.default label="Endpoint">
|
|
80
|
+
<_FormSelect.default options={options.map(s => s.url)} onChange={e => dispatch((0, _slice.setServer)(e.target.value))} />
|
|
81
|
+
</_FormItem.default>
|
|
82
|
+
{(value === null || value === void 0 ? void 0 : value.variables) && Object.keys(value.variables).map(key => {
|
|
83
|
+
var _value$variables2, _value$variables3;
|
|
84
|
+
|
|
85
|
+
if (((_value$variables2 = value.variables) === null || _value$variables2 === void 0 ? void 0 : _value$variables2[key].enum) !== undefined) {
|
|
86
|
+
return <_FormItem.default label={key}>
|
|
87
|
+
<_FormSelect.default options={value.variables[key].enum} onChange={e => {
|
|
88
|
+
dispatch((0, _slice.setServerVariable)({
|
|
89
|
+
key,
|
|
90
|
+
value: e.target.value
|
|
91
|
+
}));
|
|
92
|
+
}} />
|
|
93
|
+
</_FormItem.default>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return <_FormItem.default label={key}>
|
|
97
|
+
<_FormTextInput.default placeholder={(_value$variables3 = value.variables) === null || _value$variables3 === void 0 ? void 0 : _value$variables3[key].default} onChange={e => {
|
|
98
|
+
dispatch((0, _slice.setServerVariable)({
|
|
99
|
+
key,
|
|
100
|
+
value: e.target.value
|
|
101
|
+
}));
|
|
102
|
+
}} />
|
|
103
|
+
</_FormItem.default>;
|
|
104
|
+
})}
|
|
105
|
+
</div>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
var _default = Server;
|
|
109
|
+
exports.default = _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.slice = exports.setServerVariable = exports.setServer = 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: "server",
|
|
19
|
+
initialState,
|
|
20
|
+
reducers: {
|
|
21
|
+
setServer: (state, action) => {
|
|
22
|
+
state.value = state.options.find(s => s.url === action.payload);
|
|
23
|
+
},
|
|
24
|
+
setServerVariable: (state, action) => {
|
|
25
|
+
var _state$value;
|
|
26
|
+
|
|
27
|
+
if ((_state$value = state.value) !== null && _state$value !== void 0 && _state$value.variables) {
|
|
28
|
+
state.value.variables[action.payload.key].default = action.payload.value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
exports.slice = slice;
|
|
34
|
+
const {
|
|
35
|
+
setServer,
|
|
36
|
+
setServerVariable
|
|
37
|
+
} = slice.actions;
|
|
38
|
+
exports.setServerVariable = setServerVariable;
|
|
39
|
+
exports.setServer = setServer;
|
|
40
|
+
var _default = slice.reducer;
|
|
41
|
+
exports.default = _default;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
.showMoreButton {
|
|
2
|
+
-webkit-appearance: none;
|
|
3
|
+
-moz-appearance: none;
|
|
4
|
+
appearance: none;
|
|
5
|
+
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
font-size: var(--ifm-code-font-size);
|
|
8
|
+
/* font-weight: var(--ifm-button-font-weight); */
|
|
9
|
+
/* line-height: 1.5; */
|
|
10
|
+
|
|
11
|
+
padding: 0;
|
|
12
|
+
|
|
13
|
+
user-select: none;
|
|
14
|
+
white-space: nowrap;
|
|
15
|
+
|
|
16
|
+
border: 0px solid transparent;
|
|
17
|
+
|
|
18
|
+
display: block;
|
|
19
|
+
/* width: 100%; */
|
|
20
|
+
|
|
21
|
+
background-color: transparent;
|
|
22
|
+
|
|
23
|
+
color: var(--ifm-color-primary);
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
margin-top: var(--ifm-pre-padding);
|
|
26
|
+
margin-bottom: 0;
|
|
27
|
+
text-align: left;
|
|
28
|
+
display: block;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.showMoreButton:focus {
|
|
32
|
+
outline: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.showMoreButton:hover {
|
|
36
|
+
/* text-decoration: underline; */
|
|
37
|
+
/* background-color: red; */
|
|
38
|
+
color: var(--ifm-color-primary-hover);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.showMoreButton:first-child {
|
|
42
|
+
margin-top: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.optionsPanel:empty {
|
|
46
|
+
display: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.optionsPanel {
|
|
50
|
+
background: var(--openapi-card-background-color);
|
|
51
|
+
border-radius: var(--openapi-card-border-radius);
|
|
52
|
+
color: var(--ifm-pre-color);
|
|
53
|
+
line-height: var(--ifm-pre-line-height);
|
|
54
|
+
margin-bottom: var(--ifm-spacing-vertical);
|
|
55
|
+
margin-top: 0;
|
|
56
|
+
overflow: auto;
|
|
57
|
+
padding: var(--ifm-pre-padding);
|
|
58
|
+
|
|
59
|
+
/* hack for view calculation when monaco is hidden */
|
|
60
|
+
position: relative;
|
|
61
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
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 _themeCommon = require("@docusaurus/theme-common");
|
|
11
|
+
|
|
12
|
+
var _react2 = _interopRequireDefault(require("@monaco-editor/react"));
|
|
13
|
+
|
|
14
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.css"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
/* ============================================================================
|
|
23
|
+
* Copyright (c) Palo Alto Networks
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the MIT license found in the
|
|
26
|
+
* LICENSE file in the root directory of this source tree.
|
|
27
|
+
* ========================================================================== */
|
|
28
|
+
function VSCode({
|
|
29
|
+
value,
|
|
30
|
+
language,
|
|
31
|
+
onChange
|
|
32
|
+
}) {
|
|
33
|
+
var _ref;
|
|
34
|
+
|
|
35
|
+
const [focused, setFocused] = (0, _react.useState)(false);
|
|
36
|
+
const isDarkTheme = (_ref = (0, _themeCommon.useColorMode)().colorMode === "dark") !== null && _ref !== void 0 ? _ref : false;
|
|
37
|
+
|
|
38
|
+
function handleEditorWillMount(monaco) {
|
|
39
|
+
const styles = getComputedStyle(document.documentElement);
|
|
40
|
+
|
|
41
|
+
function getColor(property) {
|
|
42
|
+
// Weird chrome bug, returns " #ffffff " instead of "#ffffff", see: https://github.com/cloud-annotations/docusaurus-openapi/issues/144
|
|
43
|
+
const color = styles.getPropertyValue(property).trim();
|
|
44
|
+
const isColorRgb = color.includes("rgb");
|
|
45
|
+
const isColorHexShortened = color.length === 4; // Convert "rgb(r, g, b)" to color hex code
|
|
46
|
+
|
|
47
|
+
const getColorHex = color => {
|
|
48
|
+
const rgbValues = color.substring(4).split(")")[0].split(",");
|
|
49
|
+
const [r, g, b] = rgbValues;
|
|
50
|
+
|
|
51
|
+
const colorToHex = rgb => {
|
|
52
|
+
const hexadecimal = parseInt(rgb).toString(16);
|
|
53
|
+
return hexadecimal.length === 1 ? "0" + hexadecimal : hexadecimal;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return "#" + colorToHex(r) + colorToHex(g) + colorToHex(b);
|
|
57
|
+
}; // Extend shortened hex codes ie. "#aaa" => "#aaaaaa" or "#xyz" => "#xxyyzz"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
const getFullColorHex = color => {
|
|
61
|
+
let fullColorHex = "#";
|
|
62
|
+
const hexValues = color.slice(1);
|
|
63
|
+
|
|
64
|
+
for (let i = 0; i < hexValues.length; i++) {
|
|
65
|
+
for (let j = 0; j < 2; j++) {
|
|
66
|
+
fullColorHex += hexValues[i];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return fullColorHex.toLowerCase();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
if (isColorRgb) {
|
|
74
|
+
return getColorHex(color);
|
|
75
|
+
} else if (isColorHexShortened) {
|
|
76
|
+
return getFullColorHex(color);
|
|
77
|
+
} else {
|
|
78
|
+
return color;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const LIGHT_BACKGROUND = getColor("--openapi-monaco-background-color-light");
|
|
83
|
+
const LIGHT_BRIGHT = getColor("--openapi-code-bright-light");
|
|
84
|
+
const LIGHT_DIM = getColor("--openapi-code-dim-light");
|
|
85
|
+
const LIGHT_BLUE = getColor("--openapi-code-blue-light");
|
|
86
|
+
const LIGHT_GREEN = getColor("--openapi-code-green-light");
|
|
87
|
+
const LIGHT_SELECT = getColor("--openapi-code-select-light");
|
|
88
|
+
const DARK_BACKGROUND = getColor("--openapi-monaco-background-color-dark");
|
|
89
|
+
const DARK_BRIGHT = getColor("--openapi-code-bright-dark");
|
|
90
|
+
const DARK_DIM = getColor("--openapi-code-dim-dark");
|
|
91
|
+
const DARK_BLUE = getColor("--openapi-code-blue-dark");
|
|
92
|
+
const DARK_GREEN = getColor("--openapi-code-green-dark");
|
|
93
|
+
const DARK_SELECT = getColor("--openapi-code-select-dark");
|
|
94
|
+
monaco.editor.defineTheme("OpenApiDark", {
|
|
95
|
+
base: "vs-dark",
|
|
96
|
+
inherit: true,
|
|
97
|
+
rules: [{
|
|
98
|
+
token: "",
|
|
99
|
+
foreground: DARK_BRIGHT
|
|
100
|
+
}, {
|
|
101
|
+
token: "string.key.json",
|
|
102
|
+
foreground: DARK_BRIGHT
|
|
103
|
+
}, {
|
|
104
|
+
token: "string.value.json",
|
|
105
|
+
foreground: DARK_GREEN
|
|
106
|
+
}, {
|
|
107
|
+
token: "number",
|
|
108
|
+
foreground: DARK_BLUE
|
|
109
|
+
}, {
|
|
110
|
+
token: "keyword.json",
|
|
111
|
+
foreground: DARK_BLUE
|
|
112
|
+
}, {
|
|
113
|
+
token: "delimiter",
|
|
114
|
+
foreground: DARK_DIM
|
|
115
|
+
}, {
|
|
116
|
+
token: "tag.xml",
|
|
117
|
+
foreground: DARK_DIM
|
|
118
|
+
}, {
|
|
119
|
+
token: "metatag.xml",
|
|
120
|
+
foreground: DARK_DIM
|
|
121
|
+
}, {
|
|
122
|
+
token: "attribute.name.xml",
|
|
123
|
+
foreground: DARK_BRIGHT
|
|
124
|
+
}, {
|
|
125
|
+
token: "attribute.value.xml",
|
|
126
|
+
foreground: DARK_GREEN
|
|
127
|
+
}, {
|
|
128
|
+
token: "metatag.xml",
|
|
129
|
+
foreground: DARK_BLUE
|
|
130
|
+
}, {
|
|
131
|
+
token: "tag.xml",
|
|
132
|
+
foreground: DARK_BLUE
|
|
133
|
+
}],
|
|
134
|
+
colors: {
|
|
135
|
+
"editor.background": DARK_BACKGROUND,
|
|
136
|
+
"editor.lineHighlightBackground": DARK_BACKGROUND,
|
|
137
|
+
"editorBracketMatch.background": DARK_BACKGROUND,
|
|
138
|
+
"editorBracketMatch.border": DARK_BACKGROUND,
|
|
139
|
+
"editor.selectionBackground": DARK_SELECT
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
monaco.editor.defineTheme("OpenApiLight", {
|
|
143
|
+
base: "vs",
|
|
144
|
+
inherit: true,
|
|
145
|
+
rules: [{
|
|
146
|
+
token: "",
|
|
147
|
+
foreground: LIGHT_BRIGHT
|
|
148
|
+
}, {
|
|
149
|
+
token: "string.key.json",
|
|
150
|
+
foreground: LIGHT_BRIGHT
|
|
151
|
+
}, {
|
|
152
|
+
token: "string.value.json",
|
|
153
|
+
foreground: LIGHT_GREEN
|
|
154
|
+
}, {
|
|
155
|
+
token: "number",
|
|
156
|
+
foreground: LIGHT_BLUE
|
|
157
|
+
}, {
|
|
158
|
+
token: "keyword.json",
|
|
159
|
+
foreground: LIGHT_BLUE
|
|
160
|
+
}, {
|
|
161
|
+
token: "delimiter",
|
|
162
|
+
foreground: LIGHT_DIM
|
|
163
|
+
}, {
|
|
164
|
+
token: "tag.xml",
|
|
165
|
+
foreground: LIGHT_DIM
|
|
166
|
+
}, {
|
|
167
|
+
token: "metatag.xml",
|
|
168
|
+
foreground: LIGHT_DIM
|
|
169
|
+
}, {
|
|
170
|
+
token: "attribute.name.xml",
|
|
171
|
+
foreground: LIGHT_BRIGHT
|
|
172
|
+
}, {
|
|
173
|
+
token: "attribute.value.xml",
|
|
174
|
+
foreground: LIGHT_GREEN
|
|
175
|
+
}, {
|
|
176
|
+
token: "metatag.xml",
|
|
177
|
+
foreground: LIGHT_BLUE
|
|
178
|
+
}, {
|
|
179
|
+
token: "tag.xml",
|
|
180
|
+
foreground: LIGHT_BLUE
|
|
181
|
+
}],
|
|
182
|
+
colors: {
|
|
183
|
+
"editor.background": LIGHT_BACKGROUND,
|
|
184
|
+
"editor.lineHighlightBackground": LIGHT_BACKGROUND,
|
|
185
|
+
"editorBracketMatch.background": LIGHT_BACKGROUND,
|
|
186
|
+
"editorBracketMatch.border": LIGHT_BACKGROUND,
|
|
187
|
+
"editor.selectionBackground": LIGHT_SELECT
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return <div className={focused ? _stylesModule.default.monacoFocus : _stylesModule.default.monaco}>
|
|
193
|
+
<_react2.default value={value} language={language} theme={isDarkTheme ? "OpenApiDark" : "OpenApiLight"} beforeMount={handleEditorWillMount} options={{
|
|
194
|
+
lineNumbers: "off",
|
|
195
|
+
scrollBeyondLastLine: false,
|
|
196
|
+
scrollBeyondLastColumn: 3,
|
|
197
|
+
readOnly: false,
|
|
198
|
+
minimap: {
|
|
199
|
+
enabled: false
|
|
200
|
+
},
|
|
201
|
+
fontFamily: "SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace",
|
|
202
|
+
fontSize: 14.4,
|
|
203
|
+
overviewRulerLanes: 0,
|
|
204
|
+
folding: false,
|
|
205
|
+
lineDecorationsWidth: 0,
|
|
206
|
+
contextmenu: false,
|
|
207
|
+
scrollbar: {
|
|
208
|
+
horizontal: "hidden"
|
|
209
|
+
}
|
|
210
|
+
}} onMount={editor => {
|
|
211
|
+
editor.onDidFocusEditorText(() => {
|
|
212
|
+
setFocused(true);
|
|
213
|
+
});
|
|
214
|
+
editor.onDidBlurEditorText(() => {
|
|
215
|
+
setFocused(false);
|
|
216
|
+
});
|
|
217
|
+
editor.onDidChangeModelDecorations(() => {
|
|
218
|
+
updateEditorHeight(); // typing
|
|
219
|
+
|
|
220
|
+
requestAnimationFrame(updateEditorHeight); // folding
|
|
221
|
+
});
|
|
222
|
+
let prevHeight = 0;
|
|
223
|
+
|
|
224
|
+
const updateEditorHeight = () => {
|
|
225
|
+
var _editor$getModel;
|
|
226
|
+
|
|
227
|
+
onChange(editor.getValue());
|
|
228
|
+
const editorElement = editor.getDomNode();
|
|
229
|
+
|
|
230
|
+
if (!editorElement) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const lineHeight = 22;
|
|
235
|
+
const lineCount = ((_editor$getModel = editor.getModel()) === null || _editor$getModel === void 0 ? void 0 : _editor$getModel.getLineCount()) || 1;
|
|
236
|
+
const height = editor.getTopForLineNumber(lineCount + 1) + lineHeight;
|
|
237
|
+
const clippedHeight = Math.min(height, 500);
|
|
238
|
+
|
|
239
|
+
if (prevHeight !== clippedHeight) {
|
|
240
|
+
prevHeight = clippedHeight;
|
|
241
|
+
editorElement.style.height = `${clippedHeight}px`;
|
|
242
|
+
editor.layout();
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
updateEditorHeight();
|
|
247
|
+
}} />
|
|
248
|
+
</div>;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
var _default = VSCode;
|
|
252
|
+
exports.default = _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.monacoBase {
|
|
2
|
+
margin-top: calc(var(--ifm-pre-padding) / 2);
|
|
3
|
+
border-radius: 4px;
|
|
4
|
+
padding: var(--ifm-pre-padding);
|
|
5
|
+
background-color: var(--openapi-monaco-background-color);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.monaco {
|
|
9
|
+
composes: monacoBase;
|
|
10
|
+
|
|
11
|
+
box-shadow: 0 0 0 1px var(--openapi-monaco-border-color);
|
|
12
|
+
border: 2px solid transparent;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.monacoFocus {
|
|
16
|
+
composes: monacoBase;
|
|
17
|
+
|
|
18
|
+
border: 2px solid var(--openapi-input-border);
|
|
19
|
+
}
|