docusaurus-theme-openapi-docs 0.0.0-1241 → 0.0.0-1247
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/theme/ApiItem/index.js +43 -32
- package/lib/theme/RequestSchema/index.js +58 -56
- package/lib/theme/ResponseSchema/index.js +25 -22
- package/lib/theme/Schema/index.js +15 -5
- package/lib/theme/SchemaExpansion/_SchemaExpansion.scss +113 -0
- package/lib/theme/SchemaExpansion/context.d.ts +24 -0
- package/lib/theme/SchemaExpansion/context.js +187 -0
- package/lib/theme/SchemaExpansion/index.d.ts +4 -0
- package/lib/theme/SchemaExpansion/index.js +315 -0
- package/lib/theme/styles.scss +1 -0
- package/lib/theme/translationIds.d.ts +6 -0
- package/lib/theme/translationIds.js +7 -0
- package/package.json +3 -3
- package/src/theme/ApiItem/index.tsx +25 -20
- package/src/theme/RequestSchema/index.tsx +38 -39
- package/src/theme/ResponseSchema/index.tsx +15 -15
- package/src/theme/Schema/index.tsx +17 -5
- package/src/theme/SchemaExpansion/_SchemaExpansion.scss +113 -0
- package/src/theme/SchemaExpansion/context.tsx +154 -0
- package/src/theme/SchemaExpansion/index.tsx +237 -0
- package/src/theme/styles.scss +1 -0
- package/src/theme/translationIds.ts +7 -0
- package/src/types.d.ts +18 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export { SchemaExpansionProvider, SchemaDepthProvider, useSchemaExpansion, useSchemaDepth, normalizeLevel, SCHEMA_EXPANSION_STORAGE_KEY, } from "./context";
|
|
3
|
+
declare const SchemaExpansionControl: React.FC;
|
|
4
|
+
export default SchemaExpansionControl;
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
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 () {
|
|
43
|
+
var ownKeys = function (o) {
|
|
44
|
+
ownKeys =
|
|
45
|
+
Object.getOwnPropertyNames ||
|
|
46
|
+
function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o)
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
return ownKeys(o);
|
|
53
|
+
};
|
|
54
|
+
return function (mod) {
|
|
55
|
+
if (mod && mod.__esModule) return mod;
|
|
56
|
+
var result = {};
|
|
57
|
+
if (mod != null)
|
|
58
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
59
|
+
if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
60
|
+
__setModuleDefault(result, mod);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
})();
|
|
64
|
+
var __importDefault =
|
|
65
|
+
(this && this.__importDefault) ||
|
|
66
|
+
function (mod) {
|
|
67
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
68
|
+
};
|
|
69
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
+
exports.SCHEMA_EXPANSION_STORAGE_KEY =
|
|
71
|
+
exports.normalizeLevel =
|
|
72
|
+
exports.useSchemaDepth =
|
|
73
|
+
exports.useSchemaExpansion =
|
|
74
|
+
exports.SchemaDepthProvider =
|
|
75
|
+
exports.SchemaExpansionProvider =
|
|
76
|
+
void 0;
|
|
77
|
+
const react_1 = __importStar(require("react"));
|
|
78
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
79
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
80
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
81
|
+
const context_1 = require("./context");
|
|
82
|
+
var context_2 = require("./context");
|
|
83
|
+
Object.defineProperty(exports, "SchemaExpansionProvider", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function () {
|
|
86
|
+
return context_2.SchemaExpansionProvider;
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, "SchemaDepthProvider", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () {
|
|
92
|
+
return context_2.SchemaDepthProvider;
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(exports, "useSchemaExpansion", {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function () {
|
|
98
|
+
return context_2.useSchemaExpansion;
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(exports, "useSchemaDepth", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () {
|
|
104
|
+
return context_2.useSchemaDepth;
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(exports, "normalizeLevel", {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function () {
|
|
110
|
+
return context_2.normalizeLevel;
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(exports, "SCHEMA_EXPANSION_STORAGE_KEY", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function () {
|
|
116
|
+
return context_2.SCHEMA_EXPANSION_STORAGE_KEY;
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
const ALL_VALUE = Number.POSITIVE_INFINITY;
|
|
120
|
+
const ExpandIcon = () =>
|
|
121
|
+
react_1.default.createElement(
|
|
122
|
+
"svg",
|
|
123
|
+
{
|
|
124
|
+
"aria-hidden": "true",
|
|
125
|
+
focusable: "false",
|
|
126
|
+
width: "14",
|
|
127
|
+
height: "14",
|
|
128
|
+
viewBox: "0 0 16 16",
|
|
129
|
+
fill: "none",
|
|
130
|
+
stroke: "currentColor",
|
|
131
|
+
strokeWidth: "1.6",
|
|
132
|
+
strokeLinecap: "round",
|
|
133
|
+
strokeLinejoin: "round",
|
|
134
|
+
},
|
|
135
|
+
react_1.default.createElement("polyline", { points: "4 6 8 2 12 6" }),
|
|
136
|
+
react_1.default.createElement("polyline", { points: "4 10 8 14 12 10" })
|
|
137
|
+
);
|
|
138
|
+
const SchemaExpansionControl = () => {
|
|
139
|
+
const { config, level, setLevel } = (0, context_1.useSchemaExpansion)();
|
|
140
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
141
|
+
const [coords, setCoords] = (0, react_1.useState)(null);
|
|
142
|
+
const buttonRef = (0, react_1.useRef)(null);
|
|
143
|
+
const popoverRef = (0, react_1.useRef)(null);
|
|
144
|
+
const optionRefs = (0, react_1.useRef)([]);
|
|
145
|
+
const popoverId = (0, react_1.useId)();
|
|
146
|
+
const options = (0, react_1.useMemo)(() => {
|
|
147
|
+
const numbers = Array.from({ length: config.max + 1 }, (_, i) => i);
|
|
148
|
+
return [...numbers, ALL_VALUE];
|
|
149
|
+
}, [config.max]);
|
|
150
|
+
const activeIndex = (0, react_1.useMemo)(() => {
|
|
151
|
+
const idx = options.indexOf(level);
|
|
152
|
+
return idx >= 0 ? idx : 0;
|
|
153
|
+
}, [options, level]);
|
|
154
|
+
const updatePosition = (0, react_1.useCallback)(() => {
|
|
155
|
+
if (!buttonRef.current || typeof window === "undefined") return;
|
|
156
|
+
const rect = buttonRef.current.getBoundingClientRect();
|
|
157
|
+
setCoords({
|
|
158
|
+
top: rect.bottom + 4,
|
|
159
|
+
right: window.innerWidth - rect.right,
|
|
160
|
+
});
|
|
161
|
+
}, []);
|
|
162
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
163
|
+
if (!open) return;
|
|
164
|
+
updatePosition();
|
|
165
|
+
const handleScroll = () => setOpen(false);
|
|
166
|
+
window.addEventListener("scroll", handleScroll, true);
|
|
167
|
+
window.addEventListener("resize", updatePosition);
|
|
168
|
+
return () => {
|
|
169
|
+
window.removeEventListener("scroll", handleScroll, true);
|
|
170
|
+
window.removeEventListener("resize", updatePosition);
|
|
171
|
+
};
|
|
172
|
+
}, [open, updatePosition]);
|
|
173
|
+
(0, react_1.useEffect)(() => {
|
|
174
|
+
if (!open) return;
|
|
175
|
+
optionRefs.current[activeIndex]?.focus();
|
|
176
|
+
}, [open, activeIndex]);
|
|
177
|
+
(0, react_1.useEffect)(() => {
|
|
178
|
+
if (!open) return;
|
|
179
|
+
const handlePointer = (event) => {
|
|
180
|
+
const target = event.target;
|
|
181
|
+
if (buttonRef.current?.contains(target)) return;
|
|
182
|
+
if (popoverRef.current?.contains(target)) return;
|
|
183
|
+
setOpen(false);
|
|
184
|
+
};
|
|
185
|
+
const handleKey = (event) => {
|
|
186
|
+
if (event.key === "Escape") {
|
|
187
|
+
event.stopPropagation();
|
|
188
|
+
setOpen(false);
|
|
189
|
+
buttonRef.current?.focus();
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
document.addEventListener("mousedown", handlePointer);
|
|
193
|
+
document.addEventListener("keydown", handleKey);
|
|
194
|
+
return () => {
|
|
195
|
+
document.removeEventListener("mousedown", handlePointer);
|
|
196
|
+
document.removeEventListener("keydown", handleKey);
|
|
197
|
+
};
|
|
198
|
+
}, [open]);
|
|
199
|
+
const choose = (0, react_1.useCallback)(
|
|
200
|
+
(next) => {
|
|
201
|
+
setLevel(next);
|
|
202
|
+
setOpen(false);
|
|
203
|
+
buttonRef.current?.focus();
|
|
204
|
+
},
|
|
205
|
+
[setLevel]
|
|
206
|
+
);
|
|
207
|
+
const onMenuKeyDown = (event) => {
|
|
208
|
+
if (event.key !== "ArrowRight" && event.key !== "ArrowLeft") return;
|
|
209
|
+
event.preventDefault();
|
|
210
|
+
const current = optionRefs.current.findIndex(
|
|
211
|
+
(el) => el === document.activeElement
|
|
212
|
+
);
|
|
213
|
+
if (current < 0) return;
|
|
214
|
+
const next =
|
|
215
|
+
event.key === "ArrowRight"
|
|
216
|
+
? (current + 1) % options.length
|
|
217
|
+
: (current - 1 + options.length) % options.length;
|
|
218
|
+
optionRefs.current[next]?.focus();
|
|
219
|
+
};
|
|
220
|
+
if (!config.enabled) return null;
|
|
221
|
+
const buttonLabel = (0, Translate_1.translate)({
|
|
222
|
+
id: translationIds_1.OPENAPI_SCHEMA_EXPANSION.BUTTON_LABEL,
|
|
223
|
+
message: "Schema expansion depth",
|
|
224
|
+
description: "Aria/title tooltip for the schema expansion icon button",
|
|
225
|
+
});
|
|
226
|
+
const menuLabel = (0, Translate_1.translate)({
|
|
227
|
+
id: translationIds_1.OPENAPI_SCHEMA_EXPANSION.MENU_LABEL,
|
|
228
|
+
message: "Schema expansion depth options",
|
|
229
|
+
description: "Accessible label for the expansion options menu",
|
|
230
|
+
});
|
|
231
|
+
const allLabel = (0, Translate_1.translate)({
|
|
232
|
+
id: translationIds_1.OPENAPI_SCHEMA_EXPANSION.ALL,
|
|
233
|
+
message: "All",
|
|
234
|
+
description: "Label for the expand-all option",
|
|
235
|
+
});
|
|
236
|
+
return react_1.default.createElement(
|
|
237
|
+
"span",
|
|
238
|
+
{ className: "openapi-schema-expansion" },
|
|
239
|
+
react_1.default.createElement(
|
|
240
|
+
"button",
|
|
241
|
+
{
|
|
242
|
+
ref: buttonRef,
|
|
243
|
+
type: "button",
|
|
244
|
+
className: "openapi-schema-expansion__trigger",
|
|
245
|
+
"aria-haspopup": "menu",
|
|
246
|
+
"aria-expanded": open,
|
|
247
|
+
"aria-controls": open ? popoverId : undefined,
|
|
248
|
+
"aria-label": buttonLabel,
|
|
249
|
+
title: buttonLabel,
|
|
250
|
+
onClick: (event) => {
|
|
251
|
+
event.preventDefault();
|
|
252
|
+
event.stopPropagation();
|
|
253
|
+
setOpen((prev) => !prev);
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
react_1.default.createElement(ExpandIcon, null)
|
|
257
|
+
),
|
|
258
|
+
open &&
|
|
259
|
+
coords &&
|
|
260
|
+
react_1.default.createElement(
|
|
261
|
+
"div",
|
|
262
|
+
{
|
|
263
|
+
ref: popoverRef,
|
|
264
|
+
id: popoverId,
|
|
265
|
+
role: "menu",
|
|
266
|
+
"aria-label": menuLabel,
|
|
267
|
+
className: "openapi-schema-expansion__popover",
|
|
268
|
+
style: { top: coords.top, right: coords.right },
|
|
269
|
+
onKeyDown: onMenuKeyDown,
|
|
270
|
+
onClick: (event) => {
|
|
271
|
+
event.preventDefault();
|
|
272
|
+
event.stopPropagation();
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
options.map((value, index) => {
|
|
276
|
+
const isAll = value === ALL_VALUE;
|
|
277
|
+
const label = isAll ? allLabel : String(value);
|
|
278
|
+
const optionAriaLabel = isAll
|
|
279
|
+
? allLabel
|
|
280
|
+
: (0, Translate_1.translate)(
|
|
281
|
+
{
|
|
282
|
+
id: translationIds_1.OPENAPI_SCHEMA_EXPANSION.DEPTH_OPTION,
|
|
283
|
+
message: "Expand to depth {depth}",
|
|
284
|
+
description: "Accessible label for a depth option",
|
|
285
|
+
},
|
|
286
|
+
{ depth: value }
|
|
287
|
+
);
|
|
288
|
+
const isActive = level === value;
|
|
289
|
+
return react_1.default.createElement(
|
|
290
|
+
"button",
|
|
291
|
+
{
|
|
292
|
+
key: isAll ? "all" : value,
|
|
293
|
+
ref: (el) => {
|
|
294
|
+
optionRefs.current[index] = el;
|
|
295
|
+
},
|
|
296
|
+
type: "button",
|
|
297
|
+
role: "menuitemradio",
|
|
298
|
+
"aria-checked": isActive,
|
|
299
|
+
"aria-label": optionAriaLabel,
|
|
300
|
+
tabIndex: index === activeIndex ? 0 : -1,
|
|
301
|
+
className: (0, clsx_1.default)(
|
|
302
|
+
"openapi-schema-expansion__option",
|
|
303
|
+
{
|
|
304
|
+
"openapi-schema-expansion__option--active": isActive,
|
|
305
|
+
}
|
|
306
|
+
),
|
|
307
|
+
onClick: () => choose(value),
|
|
308
|
+
},
|
|
309
|
+
label
|
|
310
|
+
);
|
|
311
|
+
})
|
|
312
|
+
)
|
|
313
|
+
);
|
|
314
|
+
};
|
|
315
|
+
exports.default = SchemaExpansionControl;
|
package/lib/theme/styles.scss
CHANGED
|
@@ -59,6 +59,12 @@ export declare const OPENAPI_STATUS_CODES: {
|
|
|
59
59
|
export declare const OPENAPI_SCHEMA: {
|
|
60
60
|
NO_SCHEMA: string;
|
|
61
61
|
};
|
|
62
|
+
export declare const OPENAPI_SCHEMA_EXPANSION: {
|
|
63
|
+
BUTTON_LABEL: string;
|
|
64
|
+
MENU_LABEL: string;
|
|
65
|
+
ALL: string;
|
|
66
|
+
DEPTH_OPTION: string;
|
|
67
|
+
};
|
|
62
68
|
export declare const OPENAPI_SCHEMA_ITEM: {
|
|
63
69
|
CHARACTERS: string;
|
|
64
70
|
NON_EMPTY: string;
|
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.OPENAPI_SECURITY_SCHEMES =
|
|
10
10
|
exports.OPENAPI_PARAMS_DETAILS =
|
|
11
11
|
exports.OPENAPI_SCHEMA_ITEM =
|
|
12
|
+
exports.OPENAPI_SCHEMA_EXPANSION =
|
|
12
13
|
exports.OPENAPI_SCHEMA =
|
|
13
14
|
exports.OPENAPI_STATUS_CODES =
|
|
14
15
|
exports.OPENAPI_BODY =
|
|
@@ -83,6 +84,12 @@ exports.OPENAPI_STATUS_CODES = {
|
|
|
83
84
|
exports.OPENAPI_SCHEMA = {
|
|
84
85
|
NO_SCHEMA: "theme.openapi.schema.noSchema",
|
|
85
86
|
};
|
|
87
|
+
exports.OPENAPI_SCHEMA_EXPANSION = {
|
|
88
|
+
BUTTON_LABEL: "theme.openapi.schema.expansion.button",
|
|
89
|
+
MENU_LABEL: "theme.openapi.schema.expansion.menu",
|
|
90
|
+
ALL: "theme.openapi.schema.expansion.all",
|
|
91
|
+
DEPTH_OPTION: "theme.openapi.schema.expansion.depthOption",
|
|
92
|
+
};
|
|
86
93
|
exports.OPENAPI_SCHEMA_ITEM = {
|
|
87
94
|
CHARACTERS: "theme.openapi.schemaItem.characters",
|
|
88
95
|
NON_EMPTY: "theme.openapi.schemaItem.nonEmpty",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-theme-openapi-docs",
|
|
3
3
|
"description": "OpenAPI theme for Docusaurus.",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-1247",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/postman-collection": "^3.5.11",
|
|
39
39
|
"@types/react-modal": "^3.16.3",
|
|
40
40
|
"concurrently": "^9.2.0",
|
|
41
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
41
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-1247",
|
|
42
42
|
"docusaurus-plugin-sass": "^0.2.6",
|
|
43
43
|
"eslint-plugin-prettier": "^5.5.1"
|
|
44
44
|
},
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=14"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "2e6e04573a1c30d9b0ef899da2e75518ce7c046f"
|
|
86
86
|
}
|
|
@@ -20,6 +20,7 @@ import DocItemLayout from "@theme/ApiItem/Layout";
|
|
|
20
20
|
import CodeBlock from "@theme/CodeBlock";
|
|
21
21
|
import type { Props } from "@theme/DocItem";
|
|
22
22
|
import DocItemMetadata from "@theme/DocItem/Metadata";
|
|
23
|
+
import { SchemaExpansionProvider } from "@theme/SchemaExpansion";
|
|
23
24
|
import SkeletonLoader from "@theme/SkeletonLoader";
|
|
24
25
|
import clsx from "clsx";
|
|
25
26
|
import type {
|
|
@@ -177,18 +178,20 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
177
178
|
<DocItemMetadata />
|
|
178
179
|
<DocItemLayout>
|
|
179
180
|
<Provider store={store2}>
|
|
180
|
-
<
|
|
181
|
-
<div className="
|
|
182
|
-
<
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
<
|
|
186
|
-
{
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
181
|
+
<SchemaExpansionProvider>
|
|
182
|
+
<div className={clsx("row", "theme-api-markdown")}>
|
|
183
|
+
<div className="col col--7 openapi-left-panel__container">
|
|
184
|
+
<MDXComponent />
|
|
185
|
+
</div>
|
|
186
|
+
<div className="col col--5 openapi-right-panel__container">
|
|
187
|
+
<BrowserOnly fallback={<SkeletonLoader size="lg" />}>
|
|
188
|
+
{() => {
|
|
189
|
+
return <ApiExplorer item={api} infoPath={infoPath} />;
|
|
190
|
+
}}
|
|
191
|
+
</BrowserOnly>
|
|
192
|
+
</div>
|
|
190
193
|
</div>
|
|
191
|
-
</
|
|
194
|
+
</SchemaExpansionProvider>
|
|
192
195
|
</Provider>
|
|
193
196
|
</DocItemLayout>
|
|
194
197
|
</HtmlClassNameProvider>
|
|
@@ -200,16 +203,18 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
200
203
|
<HtmlClassNameProvider className={docHtmlClassName}>
|
|
201
204
|
<DocItemMetadata />
|
|
202
205
|
<DocItemLayout>
|
|
203
|
-
<
|
|
204
|
-
<div className="
|
|
205
|
-
<
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
<
|
|
209
|
-
{
|
|
210
|
-
|
|
206
|
+
<SchemaExpansionProvider>
|
|
207
|
+
<div className={clsx("row", "theme-api-markdown")}>
|
|
208
|
+
<div className="col col--7 openapi-left-panel__container schema">
|
|
209
|
+
<MDXComponent />
|
|
210
|
+
</div>
|
|
211
|
+
<div className="col col--5 openapi-right-panel__container">
|
|
212
|
+
<CodeBlock language="json" title={`${frontMatter.title}`}>
|
|
213
|
+
{JSON.stringify(sample, null, 2)}
|
|
214
|
+
</CodeBlock>
|
|
215
|
+
</div>
|
|
211
216
|
</div>
|
|
212
|
-
</
|
|
217
|
+
</SchemaExpansionProvider>
|
|
213
218
|
</DocItemLayout>
|
|
214
219
|
</HtmlClassNameProvider>
|
|
215
220
|
</DocProvider>
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
ResponseExamples,
|
|
19
19
|
} from "@theme/ResponseExamples";
|
|
20
20
|
import SchemaNode from "@theme/Schema";
|
|
21
|
+
import SchemaExpansionControl from "@theme/SchemaExpansion";
|
|
21
22
|
import SchemaTabs from "@theme/SchemaTabs";
|
|
22
23
|
import SkeletonLoader from "@theme/SkeletonLoader";
|
|
23
24
|
import TabItem from "@theme/TabItem";
|
|
@@ -77,24 +78,23 @@ const RequestSchemaComponent: React.FC<Props> = ({ title, body, style }) => {
|
|
|
77
78
|
open={true}
|
|
78
79
|
style={style}
|
|
79
80
|
summary={
|
|
80
|
-
|
|
81
|
-
<summary>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
</>
|
|
81
|
+
<summary className="openapi-markdown__details-summary--with-control">
|
|
82
|
+
<h3 className="openapi-markdown__details-summary-header-body">
|
|
83
|
+
{translate({
|
|
84
|
+
id: OPENAPI_REQUEST.BODY_TITLE,
|
|
85
|
+
message: title,
|
|
86
|
+
})}
|
|
87
|
+
{body.required === true && (
|
|
88
|
+
<span className="openapi-schema__required">
|
|
89
|
+
{translate({
|
|
90
|
+
id: OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
91
|
+
message: "required",
|
|
92
|
+
})}
|
|
93
|
+
</span>
|
|
94
|
+
)}
|
|
95
|
+
</h3>
|
|
96
|
+
<SchemaExpansionControl />
|
|
97
|
+
</summary>
|
|
98
98
|
}
|
|
99
99
|
>
|
|
100
100
|
<div style={{ textAlign: "left", marginLeft: "1rem" }}>
|
|
@@ -164,27 +164,26 @@ const RequestSchemaComponent: React.FC<Props> = ({ title, body, style }) => {
|
|
|
164
164
|
open={true}
|
|
165
165
|
style={style}
|
|
166
166
|
summary={
|
|
167
|
-
|
|
168
|
-
<summary>
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
{
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
</>
|
|
167
|
+
<summary className="openapi-markdown__details-summary--with-control">
|
|
168
|
+
<h3 className="openapi-markdown__details-summary-header-body">
|
|
169
|
+
{translate({
|
|
170
|
+
id: OPENAPI_REQUEST.BODY_TITLE,
|
|
171
|
+
message: title,
|
|
172
|
+
})}
|
|
173
|
+
{firstBody.type === "array" && (
|
|
174
|
+
<span style={{ opacity: "0.6" }}> array</span>
|
|
175
|
+
)}
|
|
176
|
+
{body.required && (
|
|
177
|
+
<strong className="openapi-schema__required">
|
|
178
|
+
{translate({
|
|
179
|
+
id: OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
180
|
+
message: "required",
|
|
181
|
+
})}
|
|
182
|
+
</strong>
|
|
183
|
+
)}
|
|
184
|
+
</h3>
|
|
185
|
+
<SchemaExpansionControl />
|
|
186
|
+
</summary>
|
|
188
187
|
}
|
|
189
188
|
>
|
|
190
189
|
<div style={{ textAlign: "left", marginLeft: "1rem" }}>
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
ResponseExamples,
|
|
19
19
|
} from "@theme/ResponseExamples";
|
|
20
20
|
import SchemaNode from "@theme/Schema";
|
|
21
|
+
import SchemaExpansionControl from "@theme/SchemaExpansion";
|
|
21
22
|
import SchemaTabs from "@theme/SchemaTabs";
|
|
22
23
|
import SkeletonLoader from "@theme/SkeletonLoader";
|
|
23
24
|
import TabItem from "@theme/TabItem";
|
|
@@ -91,21 +92,20 @@ const ResponseSchemaComponent: React.FC<Props> = ({
|
|
|
91
92
|
open={true}
|
|
92
93
|
style={style}
|
|
93
94
|
summary={
|
|
94
|
-
|
|
95
|
-
<summary>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
</>
|
|
95
|
+
<summary className="openapi-markdown__details-summary--with-control">
|
|
96
|
+
<strong className="openapi-markdown__details-summary-response">
|
|
97
|
+
{title}
|
|
98
|
+
{body.required === true && (
|
|
99
|
+
<span className="openapi-schema__required">
|
|
100
|
+
{translate({
|
|
101
|
+
id: OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
102
|
+
message: "required",
|
|
103
|
+
})}
|
|
104
|
+
</span>
|
|
105
|
+
)}
|
|
106
|
+
</strong>
|
|
107
|
+
<SchemaExpansionControl />
|
|
108
|
+
</summary>
|
|
109
109
|
}
|
|
110
110
|
>
|
|
111
111
|
<div style={{ textAlign: "left", marginLeft: "1rem" }}>
|
|
@@ -14,6 +14,11 @@ import { ClosingArrayBracket, OpeningArrayBracket } from "@theme/ArrayBrackets";
|
|
|
14
14
|
import Details from "@theme/Details";
|
|
15
15
|
import DiscriminatorTabs from "@theme/DiscriminatorTabs";
|
|
16
16
|
import Markdown from "@theme/Markdown";
|
|
17
|
+
import {
|
|
18
|
+
SchemaDepthProvider,
|
|
19
|
+
useSchemaDepth,
|
|
20
|
+
useSchemaExpansion,
|
|
21
|
+
} from "@theme/SchemaExpansion";
|
|
17
22
|
import SchemaItem from "@theme/SchemaItem";
|
|
18
23
|
import SchemaTabs from "@theme/SchemaTabs";
|
|
19
24
|
import TabItem from "@theme/TabItem";
|
|
@@ -676,10 +681,15 @@ const SchemaNodeDetails: React.FC<SchemaEdgeProps> = ({
|
|
|
676
681
|
schemaType,
|
|
677
682
|
schemaPath,
|
|
678
683
|
}) => {
|
|
684
|
+
const depth = useSchemaDepth();
|
|
685
|
+
const { level } = useSchemaExpansion();
|
|
686
|
+
const defaultOpen = depth < level;
|
|
679
687
|
return (
|
|
680
688
|
<SchemaItem collapsible={true}>
|
|
681
689
|
<Details
|
|
690
|
+
key={`level-${level}`}
|
|
682
691
|
className="openapi-markdown__details"
|
|
692
|
+
open={defaultOpen}
|
|
683
693
|
summary={
|
|
684
694
|
<Summary
|
|
685
695
|
name={name}
|
|
@@ -694,11 +704,13 @@ const SchemaNodeDetails: React.FC<SchemaEdgeProps> = ({
|
|
|
694
704
|
{getQualifierMessage(schema) && (
|
|
695
705
|
<MarkdownWrapper text={getQualifierMessage(schema)} />
|
|
696
706
|
)}
|
|
697
|
-
<
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
707
|
+
<SchemaDepthProvider depth={depth + 1}>
|
|
708
|
+
<SchemaNode
|
|
709
|
+
schema={schema}
|
|
710
|
+
schemaType={schemaType}
|
|
711
|
+
schemaPath={schemaPath}
|
|
712
|
+
/>
|
|
713
|
+
</SchemaDepthProvider>
|
|
702
714
|
</div>
|
|
703
715
|
</Details>
|
|
704
716
|
</SchemaItem>
|