docusaurus-theme-openapi-docs 0.0.0-1130 → 0.0.0-1153
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/ApiExplorer/Body/FileArrayFormBodyItem/index.js +0 -4
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +2 -1
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +86 -12
- package/lib/theme/ApiExplorer/Body/index.js +82 -13
- package/lib/theme/ApiExplorer/Body/slice.d.ts +136 -544
- package/lib/theme/ApiExplorer/Request/index.js +1 -1
- package/lib/theme/ApiItem/index.js +1 -1
- package/package.json +3 -3
- package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +0 -5
- package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +36 -21
- package/src/theme/ApiExplorer/Body/index.tsx +79 -15
- package/src/theme/ApiExplorer/Request/index.tsx +1 -1
- package/src/theme/ApiItem/index.tsx +1 -1
|
@@ -92,10 +92,6 @@ function FileArrayFormBodyItem({ id, description }) {
|
|
|
92
92
|
);
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
|
-
let maxIndex = 0;
|
|
96
|
-
newItems.keys().forEach((item) => {
|
|
97
|
-
maxIndex = item > maxIndex ? item : maxIndex;
|
|
98
|
-
});
|
|
99
95
|
newItems.set(index, {
|
|
100
96
|
src: `/path/to/${file.name}`,
|
|
101
97
|
content: file,
|
|
@@ -6,6 +6,7 @@ interface FormBodyItemProps {
|
|
|
6
6
|
schema: SchemaObject;
|
|
7
7
|
label?: string;
|
|
8
8
|
required?: boolean;
|
|
9
|
+
exampleValue?: SchemaObject["example"];
|
|
9
10
|
}
|
|
10
|
-
export default function FormBodyItem({ schemaObject, id, schema, label, required, }: FormBodyItemProps): React.JSX.Element;
|
|
11
|
+
export default function FormBodyItem({ schemaObject, id, schema, label, required, exampleValue, }: FormBodyItemProps): React.JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -5,6 +5,62 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
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
|
+
})();
|
|
8
64
|
var __importDefault =
|
|
9
65
|
(this && this.__importDefault) ||
|
|
10
66
|
function (mod) {
|
|
@@ -12,7 +68,7 @@ var __importDefault =
|
|
|
12
68
|
};
|
|
13
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
70
|
exports.default = FormBodyItem;
|
|
15
|
-
const react_1 =
|
|
71
|
+
const react_1 = __importStar(require("react"));
|
|
16
72
|
const FormFileUpload_1 = __importDefault(
|
|
17
73
|
require("@theme/ApiExplorer/FormFileUpload")
|
|
18
74
|
);
|
|
@@ -27,8 +83,30 @@ const FileArrayFormBodyItem_1 = __importDefault(
|
|
|
27
83
|
require("../FileArrayFormBodyItem")
|
|
28
84
|
);
|
|
29
85
|
const slice_1 = require("../slice");
|
|
30
|
-
function FormBodyItem({
|
|
86
|
+
function FormBodyItem({
|
|
87
|
+
schemaObject,
|
|
88
|
+
id,
|
|
89
|
+
schema,
|
|
90
|
+
label,
|
|
91
|
+
required,
|
|
92
|
+
exampleValue,
|
|
93
|
+
}) {
|
|
31
94
|
const dispatch = (0, hooks_1.useTypedDispatch)();
|
|
95
|
+
const [value, setValue] = (0, react_1.useState)(() => {
|
|
96
|
+
let initialValue = exampleValue ?? "";
|
|
97
|
+
if (schemaObject.type === "object" && exampleValue) {
|
|
98
|
+
initialValue = JSON.stringify(exampleValue, null, 2);
|
|
99
|
+
}
|
|
100
|
+
return initialValue;
|
|
101
|
+
});
|
|
102
|
+
(0, react_1.useEffect)(() => {
|
|
103
|
+
if (value) {
|
|
104
|
+
dispatch((0, slice_1.setStringFormBody)({ key: id, value }));
|
|
105
|
+
} else {
|
|
106
|
+
dispatch((0, slice_1.clearFormBodyKey)(id));
|
|
107
|
+
}
|
|
108
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
109
|
+
}, []);
|
|
32
110
|
if (
|
|
33
111
|
schemaObject.type === "array" &&
|
|
34
112
|
schemaObject.items?.format === "binary"
|
|
@@ -76,15 +154,7 @@ function FormBodyItem({ schemaObject, id, schema, label, required }) {
|
|
|
76
154
|
})
|
|
77
155
|
);
|
|
78
156
|
}
|
|
79
|
-
if (
|
|
80
|
-
schemaObject.type === "object" &&
|
|
81
|
-
(schemaObject.example || schemaObject.examples)
|
|
82
|
-
) {
|
|
83
|
-
const objectExample = JSON.stringify(
|
|
84
|
-
schemaObject.example ?? schemaObject.examples[0],
|
|
85
|
-
null,
|
|
86
|
-
2
|
|
87
|
-
);
|
|
157
|
+
if (schemaObject.type === "object") {
|
|
88
158
|
return react_1.default.createElement(
|
|
89
159
|
react_1.default.Fragment,
|
|
90
160
|
null,
|
|
@@ -99,7 +169,7 @@ function FormBodyItem({ schemaObject, id, schema, label, required }) {
|
|
|
99
169
|
action: (code) =>
|
|
100
170
|
dispatch((0, slice_1.setStringFormBody)({ key: id, value: code })),
|
|
101
171
|
},
|
|
102
|
-
|
|
172
|
+
value
|
|
103
173
|
)
|
|
104
174
|
);
|
|
105
175
|
}
|
|
@@ -110,9 +180,11 @@ function FormBodyItem({ schemaObject, id, schema, label, required }) {
|
|
|
110
180
|
return react_1.default.createElement(FormSelect_1.default, {
|
|
111
181
|
label: label,
|
|
112
182
|
required: required,
|
|
183
|
+
value: value,
|
|
113
184
|
options: ["---", ...schemaObject.enum],
|
|
114
185
|
onChange: (e) => {
|
|
115
186
|
const val = e.target.value;
|
|
187
|
+
setValue(val);
|
|
116
188
|
if (val === "---") {
|
|
117
189
|
dispatch((0, slice_1.clearFormBodyKey)(id));
|
|
118
190
|
} else {
|
|
@@ -130,10 +202,12 @@ function FormBodyItem({ schemaObject, id, schema, label, required }) {
|
|
|
130
202
|
return react_1.default.createElement(FormTextInput_1.default, {
|
|
131
203
|
label: label,
|
|
132
204
|
required: required,
|
|
205
|
+
value: value,
|
|
133
206
|
paramName: id,
|
|
134
207
|
isRequired: Array.isArray(schema.required) && schema.required.includes(id),
|
|
135
208
|
placeholder: schemaObject.description || id,
|
|
136
209
|
onChange: (e) => {
|
|
210
|
+
setValue(e.target.value);
|
|
137
211
|
dispatch(
|
|
138
212
|
(0, slice_1.setStringFormBody)({ key: id, value: e.target.value })
|
|
139
213
|
);
|
|
@@ -365,20 +365,89 @@ function Body({
|
|
|
365
365
|
return react_1.default.createElement(
|
|
366
366
|
FormItem_1.default,
|
|
367
367
|
{ className: "openapi-explorer__form-item-body-container" },
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
368
|
+
react_1.default.createElement(
|
|
369
|
+
SchemaTabs_1.default,
|
|
370
|
+
{ className: "openapi-tabs__schema", lazy: true },
|
|
371
|
+
react_1.default.createElement(
|
|
372
|
+
TabItem_1.default,
|
|
373
|
+
{
|
|
374
|
+
label: (0, Translate_1.translate)({
|
|
375
|
+
id: translationIds_1.OPENAPI_BODY.EXAMPLE_FROM_SCHEMA,
|
|
376
|
+
message: "Example (from schema)",
|
|
377
|
+
}),
|
|
378
|
+
value: "Example (from schema)",
|
|
379
|
+
default: true,
|
|
380
|
+
},
|
|
381
|
+
Object.entries(schema.properties ?? {}).map(([key, val]) => {
|
|
382
|
+
return react_1.default.createElement(
|
|
383
|
+
FormItem_1.default,
|
|
384
|
+
{ key: key },
|
|
385
|
+
react_1.default.createElement(FormBodyItem_1.default, {
|
|
386
|
+
schemaObject: val,
|
|
387
|
+
id: key,
|
|
388
|
+
schema: schema,
|
|
389
|
+
exampleValue: val.example,
|
|
390
|
+
label: key,
|
|
391
|
+
required:
|
|
392
|
+
Array.isArray(schema.required) &&
|
|
393
|
+
schema.required.includes(key),
|
|
394
|
+
})
|
|
395
|
+
);
|
|
379
396
|
})
|
|
380
|
-
)
|
|
381
|
-
|
|
397
|
+
),
|
|
398
|
+
example &&
|
|
399
|
+
// @ts-ignore
|
|
400
|
+
react_1.default.createElement(
|
|
401
|
+
TabItem_1.default,
|
|
402
|
+
{ label: "Example", value: "example" },
|
|
403
|
+
Object.entries(schema.properties ?? {}).map(
|
|
404
|
+
([schemaKey, schemaVal]) => {
|
|
405
|
+
return react_1.default.createElement(
|
|
406
|
+
FormItem_1.default,
|
|
407
|
+
{ key: schemaKey },
|
|
408
|
+
react_1.default.createElement(FormBodyItem_1.default, {
|
|
409
|
+
schemaObject: schemaVal,
|
|
410
|
+
id: schemaKey,
|
|
411
|
+
schema: schema,
|
|
412
|
+
exampleValue: example[schemaKey],
|
|
413
|
+
label: schemaKey,
|
|
414
|
+
required:
|
|
415
|
+
Array.isArray(schema.required) &&
|
|
416
|
+
schema.required.includes(schemaKey),
|
|
417
|
+
})
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
)
|
|
421
|
+
),
|
|
422
|
+
examples &&
|
|
423
|
+
Object.entries(examples).map(([key, value]) => {
|
|
424
|
+
return (
|
|
425
|
+
// @ts-ignore
|
|
426
|
+
react_1.default.createElement(
|
|
427
|
+
TabItem_1.default,
|
|
428
|
+
{ label: key, value: key, key: key },
|
|
429
|
+
Object.entries(schema.properties ?? {}).map(
|
|
430
|
+
([schemaKey, schemaVal]) => {
|
|
431
|
+
return react_1.default.createElement(
|
|
432
|
+
FormItem_1.default,
|
|
433
|
+
{ key: schemaKey },
|
|
434
|
+
react_1.default.createElement(FormBodyItem_1.default, {
|
|
435
|
+
schemaObject: schemaVal,
|
|
436
|
+
id: schemaKey,
|
|
437
|
+
schema: schema,
|
|
438
|
+
exampleValue: value.value?.[schemaKey],
|
|
439
|
+
label: schemaKey,
|
|
440
|
+
required:
|
|
441
|
+
Array.isArray(schema.required) &&
|
|
442
|
+
schema.required.includes(schemaKey),
|
|
443
|
+
})
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
)
|
|
447
|
+
)
|
|
448
|
+
);
|
|
449
|
+
})
|
|
450
|
+
)
|
|
382
451
|
);
|
|
383
452
|
}
|
|
384
453
|
if (exampleBody) {
|