docusaurus-theme-openapi-docs 2.1.3 → 3.0.0-beta.10
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/markdown/utils.d.ts +2 -1
- package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.d.ts +13 -0
- package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js +199 -124
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.d.ts +4 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.js +25 -19
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.d.ts +4 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.js +27 -16
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.d.ts +4 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +116 -97
- package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js +115 -54
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.d.ts +6 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js +41 -30
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.d.ts +14 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js +201 -121
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.js +36 -24
- package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js +35 -28
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.js +72 -14
- package/lib/theme/ApiExplorer/CodeSnippets/languages.json +1290 -0
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +4 -2
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +15 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.js +122 -76
- package/lib/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +4 -4
- package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
- package/lib/theme/ApiExplorer/Request/_Request.scss +4 -6
- package/lib/theme/ApiExplorer/Response/_Response.scss +4 -2
- package/lib/theme/ApiExplorer/Response/index.js +19 -19
- package/lib/theme/ApiExplorer/index.js +0 -4
- package/lib/theme/ApiItem/Layout/index.js +3 -0
- package/lib/theme/ApiItem/index.js +6 -5
- package/lib/theme/ApiLogo/index.d.ts +2 -2
- package/lib/theme/ApiTabs/_ApiTabs.scss +3 -1
- package/lib/theme/ApiTabs/index.d.ts +7 -0
- package/lib/theme/ApiTabs/index.js +152 -98
- package/lib/theme/DiscriminatorTabs/index.d.ts +3 -0
- package/lib/theme/DiscriminatorTabs/index.js +146 -94
- package/lib/theme/MimeTabs/index.d.ts +6 -0
- package/lib/theme/MimeTabs/index.js +163 -114
- package/lib/theme/OperationTabs/_OperationTabs.scss +4 -1
- package/lib/theme/OperationTabs/index.d.ts +3 -0
- package/lib/theme/OperationTabs/index.js +148 -103
- package/lib/theme/ParamsItem/index.d.ts +23 -0
- package/lib/theme/ParamsItem/index.js +168 -123
- package/lib/theme/ResponseSamples/index.d.ts +8 -0
- package/lib/theme/ResponseSamples/index.js +18 -13
- package/lib/theme/SchemaItem/index.d.ts +12 -0
- package/lib/theme/SchemaItem/index.js +123 -88
- package/lib/theme/SchemaTabs/_SchemaTabs.scss +0 -4
- package/lib/theme/SchemaTabs/index.d.ts +3 -0
- package/lib/theme/SchemaTabs/index.js +142 -91
- package/lib/theme/styles.scss +4 -0
- package/package.json +8 -7
- package/src/markdown/utils.ts +4 -2
- package/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/{index.js → index.tsx} +21 -8
- package/src/theme/ApiExplorer/ApiCodeBlock/Container/{index.js → index.tsx} +6 -3
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/{Element.js → Element.tsx} +5 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/{String.js → String.tsx} +5 -5
- package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/{index.js → index.tsx} +8 -3
- package/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/{index.js → index.tsx} +9 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/{index.js → index.tsx} +13 -3
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/{index.js → index.tsx} +2 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/{index.js → index.tsx} +11 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/{index.js → index.tsx} +10 -5
- package/src/theme/ApiExplorer/CodeSnippets/languages.json +1290 -0
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +4 -2
- package/src/theme/ApiExplorer/CodeTabs/{index.js → index.tsx} +56 -26
- package/src/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +4 -4
- package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
- package/src/theme/ApiExplorer/Request/_Request.scss +4 -6
- package/src/theme/ApiExplorer/Response/_Response.scss +4 -2
- package/src/theme/ApiExplorer/Response/index.tsx +2 -2
- package/src/theme/ApiExplorer/index.tsx +0 -3
- package/src/theme/ApiItem/Layout/index.tsx +3 -0
- package/src/theme/ApiItem/index.tsx +3 -4
- package/src/theme/ApiLogo/index.tsx +1 -1
- package/src/theme/ApiTabs/_ApiTabs.scss +3 -1
- package/src/theme/ApiTabs/{index.js → index.tsx} +60 -26
- package/src/theme/DiscriminatorTabs/{index.js → index.tsx} +57 -24
- package/src/theme/MimeTabs/{index.js → index.tsx} +58 -26
- package/src/theme/OperationTabs/_OperationTabs.scss +4 -1
- package/src/theme/OperationTabs/{index.js → index.tsx} +54 -25
- package/src/theme/ParamsItem/{index.js → index.tsx} +31 -14
- package/src/theme/ResponseSamples/{index.js → index.tsx} +10 -1
- package/src/theme/SchemaItem/{index.js → index.tsx} +18 -9
- package/src/theme/SchemaTabs/_SchemaTabs.scss +0 -4
- package/src/theme/SchemaTabs/{index.js → index.tsx} +56 -25
- package/src/theme/styles.scss +4 -0
- package/src/theme-classic.d.ts +69 -2
- package/src/theme-openapi.d.ts +2 -0
- package/tsconfig.json +4 -1
|
@@ -1,36 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/* ============================================================================
|
|
2
3
|
* Copyright (c) Palo Alto Networks
|
|
3
4
|
*
|
|
4
5
|
* This source code is licensed under the MIT license found in the
|
|
5
6
|
* LICENSE file in the root directory of this source tree.
|
|
6
7
|
* ========================================================================== */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
var __createBinding =
|
|
9
|
+
(this && this.__createBinding) ||
|
|
10
|
+
(Object.create
|
|
11
|
+
? function (o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (
|
|
15
|
+
!desc ||
|
|
16
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
17
|
+
) {
|
|
18
|
+
desc = {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return m[k];
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}
|
|
27
|
+
: function (o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
});
|
|
31
|
+
var __setModuleDefault =
|
|
32
|
+
(this && this.__setModuleDefault) ||
|
|
33
|
+
(Object.create
|
|
34
|
+
? function (o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}
|
|
37
|
+
: function (o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __importStar =
|
|
41
|
+
(this && this.__importStar) ||
|
|
42
|
+
function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null)
|
|
46
|
+
for (var k in mod)
|
|
47
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
48
|
+
__createBinding(result, mod, k);
|
|
49
|
+
__setModuleDefault(result, mod);
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
var __importDefault =
|
|
53
|
+
(this && this.__importDefault) ||
|
|
54
|
+
function (mod) {
|
|
55
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
56
|
+
};
|
|
57
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
+
const react_1 = __importStar(require("react"));
|
|
59
|
+
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
60
|
+
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
61
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
17
62
|
function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
18
63
|
const tabRefs = [];
|
|
19
|
-
const { blockElementScrollPositionUntilNextRender } =
|
|
20
|
-
|
|
21
|
-
|
|
64
|
+
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
65
|
+
internal_1.useScrollPositionBlocker)();
|
|
22
66
|
const handleTabChange = (event) => {
|
|
23
|
-
event.preventDefault();
|
|
24
67
|
const newTab = event.currentTarget;
|
|
25
68
|
const newTabIndex = tabRefs.indexOf(newTab);
|
|
26
69
|
const newTabValue = tabValues[newTabIndex].value;
|
|
27
|
-
// custom
|
|
28
70
|
if (newTabValue !== selectedValue) {
|
|
29
71
|
blockElementScrollPositionUntilNextRender(newTab);
|
|
30
72
|
selectValue(newTabValue);
|
|
31
73
|
}
|
|
32
74
|
};
|
|
33
|
-
|
|
34
75
|
const handleKeydown = (event) => {
|
|
35
76
|
let focusElement = null;
|
|
36
77
|
switch (event.key) {
|
|
@@ -53,15 +94,13 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
|
53
94
|
}
|
|
54
95
|
focusElement?.focus();
|
|
55
96
|
};
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
useEffect(() => {
|
|
97
|
+
const tabItemListContainerRef = (0, react_1.useRef)(null);
|
|
98
|
+
const [showTabArrows, setShowTabArrows] = (0, react_1.useState)(false);
|
|
99
|
+
(0, react_1.useEffect)(() => {
|
|
61
100
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
62
101
|
for (let entry of entries) {
|
|
63
102
|
requestAnimationFrame(() => {
|
|
64
|
-
if (entry.target.
|
|
103
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
65
104
|
setShowTabArrows(true);
|
|
66
105
|
} else {
|
|
67
106
|
setShowTabArrows(false);
|
|
@@ -69,121 +108,127 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
|
69
108
|
});
|
|
70
109
|
}
|
|
71
110
|
});
|
|
72
|
-
|
|
73
111
|
resizeObserver.observe(tabItemListContainerRef.current);
|
|
74
|
-
|
|
75
112
|
return () => {
|
|
76
113
|
resizeObserver.disconnect();
|
|
77
114
|
};
|
|
78
115
|
}, []);
|
|
79
|
-
|
|
80
116
|
const handleRightClick = () => {
|
|
81
117
|
tabItemListContainerRef.current.scrollLeft += 90;
|
|
82
118
|
};
|
|
83
|
-
|
|
84
119
|
const handleLeftClick = () => {
|
|
85
120
|
tabItemListContainerRef.current.scrollLeft -= 90;
|
|
86
121
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
122
|
+
return react_1.default.createElement(
|
|
123
|
+
"div",
|
|
124
|
+
{ className: "tabs__container" },
|
|
125
|
+
react_1.default.createElement(
|
|
126
|
+
"div",
|
|
127
|
+
{ className: "openapi-tabs__operation-container" },
|
|
128
|
+
showTabArrows &&
|
|
129
|
+
react_1.default.createElement("button", {
|
|
130
|
+
className: (0, clsx_1.default)("openapi-tabs__arrow", "left"),
|
|
131
|
+
onClick: handleLeftClick,
|
|
132
|
+
}),
|
|
133
|
+
react_1.default.createElement(
|
|
134
|
+
"ul",
|
|
135
|
+
{
|
|
136
|
+
ref: tabItemListContainerRef,
|
|
137
|
+
role: "tablist",
|
|
138
|
+
"aria-orientation": "horizontal",
|
|
139
|
+
className: (0, clsx_1.default)(
|
|
102
140
|
"openapi-tabs__operation-list-container",
|
|
103
141
|
"tabs",
|
|
104
142
|
{
|
|
105
143
|
"tabs--block": block,
|
|
106
144
|
},
|
|
107
145
|
className
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
</div>
|
|
146
|
+
),
|
|
147
|
+
},
|
|
148
|
+
tabValues.map(({ value, label, attributes }) => {
|
|
149
|
+
return react_1.default.createElement(
|
|
150
|
+
"li",
|
|
151
|
+
{
|
|
152
|
+
// TODO extract TabListItem
|
|
153
|
+
role: "tab",
|
|
154
|
+
tabIndex: selectedValue === value ? 0 : -1,
|
|
155
|
+
"aria-selected": selectedValue === value,
|
|
156
|
+
key: value,
|
|
157
|
+
ref: (tabControl) => tabRefs.push(tabControl),
|
|
158
|
+
onKeyDown: handleKeydown,
|
|
159
|
+
onFocus: handleTabChange,
|
|
160
|
+
onClick: (e) => handleTabChange(e),
|
|
161
|
+
...attributes,
|
|
162
|
+
className: (0, clsx_1.default)(
|
|
163
|
+
"tabs__item",
|
|
164
|
+
"openapi-tabs__operation-item",
|
|
165
|
+
attributes?.className,
|
|
166
|
+
{
|
|
167
|
+
active: selectedValue === value,
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
},
|
|
171
|
+
label ?? value
|
|
172
|
+
);
|
|
173
|
+
})
|
|
174
|
+
),
|
|
175
|
+
showTabArrows &&
|
|
176
|
+
react_1.default.createElement("button", {
|
|
177
|
+
className: (0, clsx_1.default)("openapi-tabs__arrow", "right"),
|
|
178
|
+
onClick: handleRightClick,
|
|
179
|
+
})
|
|
180
|
+
)
|
|
144
181
|
);
|
|
145
182
|
}
|
|
146
183
|
function TabContent({ lazy, children, selectedValue }) {
|
|
147
|
-
|
|
148
|
-
|
|
184
|
+
const childTabs = (Array.isArray(children) ? children : [children]).filter(
|
|
185
|
+
Boolean
|
|
186
|
+
);
|
|
149
187
|
if (lazy) {
|
|
150
|
-
const selectedTabItem =
|
|
188
|
+
const selectedTabItem = childTabs.find(
|
|
151
189
|
(tabItem) => tabItem.props.value === selectedValue
|
|
152
190
|
);
|
|
153
191
|
if (!selectedTabItem) {
|
|
154
192
|
// fail-safe or fail-fast? not sure what's best here
|
|
155
193
|
return null;
|
|
156
194
|
}
|
|
157
|
-
return cloneElement(selectedTabItem, {
|
|
195
|
+
return (0, react_1.cloneElement)(selectedTabItem, {
|
|
196
|
+
className: "margin-top--md",
|
|
197
|
+
});
|
|
158
198
|
}
|
|
159
|
-
return (
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
)
|
|
167
|
-
|
|
199
|
+
return react_1.default.createElement(
|
|
200
|
+
"div",
|
|
201
|
+
{ className: "margin-top--md" },
|
|
202
|
+
childTabs.map((tabItem, i) =>
|
|
203
|
+
(0, react_1.cloneElement)(tabItem, {
|
|
204
|
+
key: i,
|
|
205
|
+
hidden: tabItem.props.value !== selectedValue,
|
|
206
|
+
})
|
|
207
|
+
)
|
|
168
208
|
);
|
|
169
209
|
}
|
|
170
210
|
function TabsComponent(props) {
|
|
171
|
-
const tabs = useTabs(props);
|
|
172
|
-
return (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
211
|
+
const tabs = (0, internal_1.useTabs)(props);
|
|
212
|
+
return react_1.default.createElement(
|
|
213
|
+
"div",
|
|
214
|
+
{ className: "tabs-container" },
|
|
215
|
+
react_1.default.createElement(TabList, { ...props, ...tabs }),
|
|
216
|
+
react_1.default.createElement(TabContent, { ...props, ...tabs })
|
|
177
217
|
);
|
|
178
218
|
}
|
|
179
|
-
|
|
180
|
-
const isBrowser =
|
|
181
|
-
return (
|
|
182
|
-
|
|
219
|
+
function OperationTabs(props) {
|
|
220
|
+
const isBrowser = (0, useIsBrowser_1.default)();
|
|
221
|
+
return react_1.default.createElement(
|
|
222
|
+
TabsComponent,
|
|
223
|
+
// Remount tabs after hydration
|
|
224
|
+
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
225
|
+
{
|
|
183
226
|
// Remount tabs after hydration
|
|
184
227
|
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
185
|
-
key
|
|
186
|
-
|
|
187
|
-
|
|
228
|
+
key: String(isBrowser),
|
|
229
|
+
...props,
|
|
230
|
+
},
|
|
231
|
+
(0, internal_1.sanitizeTabsChildren)(props.children)
|
|
188
232
|
);
|
|
189
233
|
}
|
|
234
|
+
exports.default = OperationTabs;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface Map<T> {
|
|
3
|
+
[key: string]: T;
|
|
4
|
+
}
|
|
5
|
+
export interface ExampleObject {
|
|
6
|
+
summary?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
value?: any;
|
|
9
|
+
externalValue?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface Props {
|
|
12
|
+
param: {
|
|
13
|
+
description: string;
|
|
14
|
+
example: any;
|
|
15
|
+
examples: Map<ExampleObject>;
|
|
16
|
+
name: string;
|
|
17
|
+
required: boolean;
|
|
18
|
+
deprecated: boolean;
|
|
19
|
+
schema: any;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
declare function ParamsItem({ param: { description, example, examples, name, required, schema, deprecated }, }: Props): React.JSX.Element;
|
|
23
|
+
export default ParamsItem;
|
|
@@ -1,150 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/* ============================================================================
|
|
2
3
|
* Copyright (c) Palo Alto Networks
|
|
3
4
|
*
|
|
4
5
|
* This source code is licensed under the MIT license found in the
|
|
5
6
|
* LICENSE file in the root directory of this source tree.
|
|
6
7
|
* ========================================================================== */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
var __importDefault =
|
|
9
|
+
(this && this.__importDefault) ||
|
|
10
|
+
function (mod) {
|
|
11
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const react_1 = __importDefault(require("react"));
|
|
15
|
+
const CodeBlock_1 = __importDefault(require("@theme/CodeBlock"));
|
|
16
|
+
const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
|
|
17
|
+
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
13
18
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} from "docusaurus-theme-openapi-docs/lib/markdown/schema";
|
|
21
|
-
/* eslint-disable import/no-extraneous-dependencies*/
|
|
22
|
-
import {
|
|
23
|
-
guard,
|
|
24
|
-
toString,
|
|
25
|
-
} from "docusaurus-theme-openapi-docs/lib/markdown/utils";
|
|
26
|
-
import ReactMarkdown from "react-markdown";
|
|
27
|
-
import rehypeRaw from "rehype-raw";
|
|
28
|
-
|
|
19
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
20
|
+
const react_markdown_1 = __importDefault(require("react-markdown"));
|
|
21
|
+
const rehype_raw_1 = __importDefault(require("rehype-raw"));
|
|
22
|
+
const createDescription_1 = require("../../markdown/createDescription");
|
|
23
|
+
const schema_1 = require("../../markdown/schema");
|
|
24
|
+
const utils_1 = require("../../markdown/utils");
|
|
29
25
|
function ParamsItem({
|
|
30
26
|
param: { description, example, examples, name, required, schema, deprecated },
|
|
31
27
|
}) {
|
|
32
28
|
if (!schema || !schema?.type) {
|
|
33
29
|
schema = { type: "any" };
|
|
34
30
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
31
|
+
const renderSchemaName = (0, utils_1.guard)(schema, (schema) =>
|
|
32
|
+
react_1.default.createElement(
|
|
33
|
+
"span",
|
|
34
|
+
{ className: "openapi-schema__type" },
|
|
35
|
+
" ",
|
|
36
|
+
(0, schema_1.getSchemaName)(schema)
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
const renderSchemaRequired = (0, utils_1.guard)(required, () =>
|
|
40
|
+
react_1.default.createElement(
|
|
41
|
+
"span",
|
|
42
|
+
{ className: "openapi-schema__required" },
|
|
43
|
+
"required"
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
const renderDeprecated = (0, utils_1.guard)(deprecated, () =>
|
|
47
|
+
react_1.default.createElement(
|
|
48
|
+
"span",
|
|
49
|
+
{ className: "openapi-schema__deprecated" },
|
|
50
|
+
"deprecated"
|
|
51
|
+
)
|
|
52
|
+
);
|
|
53
|
+
const renderSchema = (0, utils_1.guard)(
|
|
54
|
+
(0, schema_1.getQualifierMessage)(schema),
|
|
55
|
+
(message) =>
|
|
56
|
+
react_1.default.createElement(
|
|
57
|
+
"div",
|
|
58
|
+
null,
|
|
59
|
+
react_1.default.createElement(react_markdown_1.default, {
|
|
60
|
+
children: (0, createDescription_1.createDescription)(message),
|
|
61
|
+
rehypePlugins: [rehype_raw_1.default],
|
|
62
|
+
})
|
|
63
|
+
)
|
|
64
|
+
);
|
|
65
|
+
const renderDescription = (0, utils_1.guard)(description, (description) =>
|
|
66
|
+
react_1.default.createElement(
|
|
67
|
+
"div",
|
|
68
|
+
null,
|
|
69
|
+
react_1.default.createElement(react_markdown_1.default, {
|
|
70
|
+
children: (0, createDescription_1.createDescription)(description),
|
|
71
|
+
components: {
|
|
62
72
|
pre: "div",
|
|
63
73
|
code({ node, inline, className, children, ...props }) {
|
|
64
74
|
const match = /language-(\w+)/.exec(className || "");
|
|
65
|
-
if (inline)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
if (inline)
|
|
76
|
+
return react_1.default.createElement("code", null, children);
|
|
77
|
+
return !inline && match
|
|
78
|
+
? react_1.default.createElement(
|
|
79
|
+
CodeBlock_1.default,
|
|
80
|
+
{ className: className },
|
|
81
|
+
children
|
|
82
|
+
)
|
|
83
|
+
: react_1.default.createElement(
|
|
84
|
+
CodeBlock_1.default,
|
|
85
|
+
null,
|
|
86
|
+
children
|
|
87
|
+
);
|
|
71
88
|
},
|
|
72
|
-
}
|
|
73
|
-
rehypePlugins
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
const renderDefaultValue = guard(
|
|
89
|
+
},
|
|
90
|
+
rehypePlugins: [rehype_raw_1.default],
|
|
91
|
+
})
|
|
92
|
+
)
|
|
93
|
+
);
|
|
94
|
+
const renderDefaultValue = (0, utils_1.guard)(
|
|
79
95
|
schema && schema.items
|
|
80
96
|
? schema.items.default
|
|
81
97
|
: schema
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
(value) =>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
98
|
+
? schema.default
|
|
99
|
+
: undefined,
|
|
100
|
+
(value) =>
|
|
101
|
+
react_1.default.createElement(
|
|
102
|
+
"div",
|
|
103
|
+
null,
|
|
104
|
+
react_1.default.createElement(react_markdown_1.default, {
|
|
105
|
+
children: `**Default value:** \`${value}\``,
|
|
106
|
+
})
|
|
107
|
+
)
|
|
108
|
+
);
|
|
109
|
+
const renderExample = (0, utils_1.guard)(
|
|
110
|
+
(0, utils_1.toString)(example),
|
|
111
|
+
(example) =>
|
|
112
|
+
react_1.default.createElement(
|
|
113
|
+
"div",
|
|
114
|
+
null,
|
|
115
|
+
react_1.default.createElement("strong", null, "Example: "),
|
|
116
|
+
example
|
|
117
|
+
)
|
|
89
118
|
);
|
|
90
|
-
|
|
91
|
-
const renderExample = guard(toString(example), (example) => (
|
|
92
|
-
<div>
|
|
93
|
-
<strong>Example: </strong>
|
|
94
|
-
{example}
|
|
95
|
-
</div>
|
|
96
|
-
));
|
|
97
|
-
|
|
98
|
-
const renderExamples = guard(examples, (examples) => {
|
|
119
|
+
const renderExamples = (0, utils_1.guard)(examples, (examples) => {
|
|
99
120
|
const exampleEntries = Object.entries(examples);
|
|
100
|
-
return (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
return react_1.default.createElement(
|
|
122
|
+
react_1.default.Fragment,
|
|
123
|
+
null,
|
|
124
|
+
react_1.default.createElement("strong", null, "Examples:"),
|
|
125
|
+
react_1.default.createElement(
|
|
126
|
+
SchemaTabs_1.default,
|
|
127
|
+
null,
|
|
128
|
+
exampleEntries.map(([exampleName, exampleProperties]) =>
|
|
129
|
+
// @ts-ignore
|
|
130
|
+
react_1.default.createElement(
|
|
131
|
+
TabItem_1.default,
|
|
132
|
+
{ value: exampleName, label: exampleName },
|
|
133
|
+
exampleProperties.summary &&
|
|
134
|
+
react_1.default.createElement(
|
|
135
|
+
"p",
|
|
136
|
+
null,
|
|
137
|
+
exampleProperties.summary
|
|
138
|
+
),
|
|
139
|
+
exampleProperties.description &&
|
|
140
|
+
react_1.default.createElement(
|
|
141
|
+
"p",
|
|
142
|
+
null,
|
|
143
|
+
react_1.default.createElement("strong", null, "Description: "),
|
|
144
|
+
react_1.default.createElement(
|
|
145
|
+
"span",
|
|
146
|
+
null,
|
|
147
|
+
exampleProperties.description
|
|
148
|
+
)
|
|
149
|
+
),
|
|
150
|
+
react_1.default.createElement(
|
|
151
|
+
"p",
|
|
152
|
+
null,
|
|
153
|
+
react_1.default.createElement("strong", null, "Example: "),
|
|
154
|
+
react_1.default.createElement(
|
|
155
|
+
"code",
|
|
156
|
+
null,
|
|
157
|
+
exampleProperties.value
|
|
158
|
+
)
|
|
159
|
+
)
|
|
160
|
+
)
|
|
161
|
+
)
|
|
162
|
+
)
|
|
121
163
|
);
|
|
122
164
|
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
165
|
+
return react_1.default.createElement(
|
|
166
|
+
"div",
|
|
167
|
+
{ className: "openapi-params__list-item" },
|
|
168
|
+
react_1.default.createElement(
|
|
169
|
+
"span",
|
|
170
|
+
{ className: "openapi-schema__container" },
|
|
171
|
+
react_1.default.createElement(
|
|
172
|
+
"strong",
|
|
173
|
+
{
|
|
174
|
+
className: (0, clsx_1.default)("openapi-schema__property", {
|
|
129
175
|
"openapi-schema__strikethrough": deprecated,
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
176
|
+
}),
|
|
177
|
+
},
|
|
178
|
+
name
|
|
179
|
+
),
|
|
180
|
+
renderSchemaName,
|
|
181
|
+
(required || deprecated) &&
|
|
182
|
+
react_1.default.createElement("span", {
|
|
183
|
+
className: "openapi-schema__divider",
|
|
184
|
+
}),
|
|
185
|
+
renderSchemaRequired,
|
|
186
|
+
renderDeprecated
|
|
187
|
+
),
|
|
188
|
+
renderSchema,
|
|
189
|
+
renderDefaultValue,
|
|
190
|
+
renderDescription,
|
|
191
|
+
renderExample,
|
|
192
|
+
renderExamples
|
|
147
193
|
);
|
|
148
194
|
}
|
|
149
|
-
|
|
150
|
-
export default ParamsItem;
|
|
195
|
+
exports.default = ParamsItem;
|