docusaurus-theme-openapi-docs 4.5.1 → 4.7.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/lib/markdown/schema.js +14 -1
- package/lib/theme/ApiExplorer/Accept/slice.d.ts +5 -2
- package/lib/theme/ApiExplorer/Authorization/index.js +50 -9
- package/lib/theme/ApiExplorer/Authorization/slice.d.ts +145 -3
- package/lib/theme/ApiExplorer/Authorization/slice.js +3 -1
- package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.js +126 -0
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +9 -0
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +110 -0
- package/lib/theme/ApiExplorer/Body/index.js +322 -193
- package/lib/theme/ApiExplorer/Body/resolveSchemaWithSelections.d.ts +13 -0
- package/lib/theme/ApiExplorer/Body/resolveSchemaWithSelections.js +133 -0
- package/lib/theme/ApiExplorer/Body/slice.d.ts +1056 -11
- package/lib/theme/ApiExplorer/Body/slice.js +22 -2
- package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +2 -1
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +37 -26
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +5 -1
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +3 -3
- package/lib/theme/ApiExplorer/CodeTabs/index.js +2 -2
- package/lib/theme/ApiExplorer/ContentType/slice.d.ts +5 -2
- package/lib/theme/ApiExplorer/FormFileUpload/index.js +6 -1
- package/lib/theme/ApiExplorer/FormItem/index.js +6 -1
- package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +2 -0
- package/lib/theme/ApiExplorer/FormTextInput/index.js +8 -1
- package/lib/theme/ApiExplorer/LiveEditor/index.js +11 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +15 -5
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +11 -3
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +12 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +11 -2
- package/lib/theme/ApiExplorer/ParamOptions/index.js +11 -1
- package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +0 -4
- package/lib/theme/ApiExplorer/ParamOptions/slice.js +4 -4
- package/lib/theme/ApiExplorer/Request/index.js +110 -17
- package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +7 -1
- package/lib/theme/ApiExplorer/Request/makeRequest.js +94 -24
- package/lib/theme/ApiExplorer/Response/index.js +34 -14
- package/lib/theme/ApiExplorer/Response/slice.d.ts +31 -7
- package/lib/theme/ApiExplorer/SchemaSelection/index.d.ts +2 -0
- package/lib/theme/ApiExplorer/SchemaSelection/index.js +36 -0
- package/lib/theme/ApiExplorer/SchemaSelection/slice.d.ts +37 -0
- package/lib/theme/ApiExplorer/SchemaSelection/slice.js +39 -0
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +208 -69
- package/lib/theme/ApiExplorer/Server/index.js +16 -2
- package/lib/theme/ApiExplorer/Server/slice.d.ts +49 -3
- package/lib/theme/ApiExplorer/buildPostmanRequest.js +46 -57
- package/lib/theme/ApiExplorer/index.js +4 -0
- package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +21 -0
- package/lib/theme/ApiExplorer/{persistanceMiddleware.js → persistenceMiddleware.js} +16 -9
- package/lib/theme/ApiExplorer/storage-utils.d.ts +2 -2
- package/lib/theme/ApiExplorer/storage-utils.js +3 -3
- package/lib/theme/ApiItem/Layout/index.d.ts +1 -1
- package/lib/theme/ApiItem/hooks.d.ts +10 -9
- package/lib/theme/ApiItem/index.js +13 -8
- package/lib/theme/ApiItem/store.d.ts +61 -43
- package/lib/theme/ApiItem/store.js +6 -2
- package/lib/theme/ApiTabs/index.js +6 -1
- package/lib/theme/Example/_Example.scss +11 -0
- package/lib/theme/Example/index.d.ts +24 -0
- package/lib/theme/Example/index.js +170 -0
- package/lib/theme/ParamsDetails/index.js +9 -1
- package/lib/theme/ParamsItem/index.d.ts +1 -1
- package/lib/theme/ParamsItem/index.js +43 -74
- package/lib/theme/RequestSchema/index.js +68 -48
- package/lib/theme/ResponseExamples/index.js +23 -3
- package/lib/theme/ResponseSchema/index.js +97 -82
- package/lib/theme/Schema/index.d.ts +6 -0
- package/lib/theme/Schema/index.js +240 -31
- package/lib/theme/SchemaItem/index.js +64 -36
- package/lib/theme/SchemaTabs/index.d.ts +8 -1
- package/lib/theme/SchemaTabs/index.js +14 -2
- package/lib/theme/StatusCodes/index.d.ts +1 -1
- package/lib/theme/StatusCodes/index.js +11 -2
- package/lib/theme/styles.scss +15 -0
- package/lib/theme/translationIds.d.ts +90 -0
- package/lib/theme/translationIds.js +114 -0
- package/package.json +28 -28
- package/src/markdown/schema.ts +17 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +51 -10
- package/src/theme/ApiExplorer/Authorization/slice.ts +1 -1
- package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +77 -0
- package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +120 -0
- package/src/theme/ApiExplorer/Body/index.tsx +262 -198
- package/{lib/types.js → src/theme/ApiExplorer/Body/json2xml.d.ts} +2 -2
- package/src/theme/ApiExplorer/Body/resolveSchemaWithSelections.ts +155 -0
- package/src/theme/ApiExplorer/Body/slice.ts +40 -1
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +43 -29
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +5 -1
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +6 -5
- package/src/theme/ApiExplorer/ContentType/index.tsx +1 -1
- package/src/theme/ApiExplorer/FormFileUpload/index.tsx +6 -1
- package/src/theme/ApiExplorer/FormItem/index.tsx +8 -1
- package/src/theme/ApiExplorer/FormTextInput/index.tsx +10 -1
- package/src/theme/ApiExplorer/LiveEditor/index.tsx +11 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +16 -6
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +12 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +12 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +12 -3
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +10 -2
- package/src/theme/ApiExplorer/ParamOptions/slice.ts +1 -1
- package/src/theme/ApiExplorer/Request/index.tsx +108 -17
- package/src/theme/ApiExplorer/Request/makeRequest.ts +106 -25
- package/src/theme/ApiExplorer/Response/index.tsx +30 -8
- package/src/theme/ApiExplorer/SchemaSelection/index.ts +13 -0
- package/src/theme/ApiExplorer/SchemaSelection/slice.ts +46 -0
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +157 -69
- package/src/theme/ApiExplorer/Server/index.tsx +12 -4
- package/src/theme/ApiExplorer/buildPostmanRequest.ts +47 -63
- package/src/theme/ApiExplorer/index.tsx +5 -0
- package/src/theme/ApiExplorer/{persistanceMiddleware.ts → persistenceMiddleware.ts} +23 -13
- package/src/theme/ApiExplorer/storage-utils.ts +4 -4
- package/src/theme/ApiItem/Layout/index.tsx +1 -1
- package/src/theme/ApiItem/index.tsx +13 -7
- package/src/theme/ApiItem/store.ts +2 -0
- package/src/theme/ApiTabs/index.tsx +6 -1
- package/src/theme/Example/_Example.scss +11 -0
- package/src/theme/Example/index.tsx +168 -0
- package/src/theme/Markdown/index.d.ts +8 -0
- package/src/theme/ParamsDetails/index.tsx +10 -1
- package/src/theme/ParamsItem/index.tsx +38 -54
- package/src/theme/RequestSchema/index.tsx +60 -35
- package/src/theme/ResponseExamples/index.tsx +23 -3
- package/src/theme/ResponseSchema/index.tsx +73 -61
- package/src/theme/Schema/index.tsx +307 -55
- package/src/theme/SchemaItem/index.tsx +51 -33
- package/src/theme/SchemaTabs/index.tsx +19 -5
- package/src/theme/StatusCodes/index.tsx +13 -3
- package/src/theme/styles.scss +15 -0
- package/src/theme/translationIds.ts +111 -0
- package/src/theme-openapi.d.ts +7 -275
- package/src/{types.ts → types.d.ts} +9 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/theme/ApiExplorer/persistanceMiddleware.d.ts +0 -3
- package/lib/types.d.ts +0 -46
|
@@ -5,13 +5,72 @@
|
|
|
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) {
|
|
11
67
|
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
68
|
};
|
|
13
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const react_1 =
|
|
70
|
+
const react_1 = __importStar(require("react"));
|
|
71
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
72
|
+
const slice_1 = require("@theme/ApiExplorer/SchemaSelection/slice");
|
|
73
|
+
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
15
74
|
const ArrayBrackets_1 = require("@theme/ArrayBrackets");
|
|
16
75
|
const Details_1 = __importDefault(require("@theme/Details"));
|
|
17
76
|
const DiscriminatorTabs_1 = __importDefault(
|
|
@@ -21,6 +80,7 @@ const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
|
21
80
|
const SchemaItem_1 = __importDefault(require("@theme/SchemaItem"));
|
|
22
81
|
const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
|
|
23
82
|
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
83
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
24
84
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
25
85
|
const allof_merge_1 = require("allof-merge");
|
|
26
86
|
const clsx_1 = __importDefault(require("clsx"));
|
|
@@ -77,25 +137,66 @@ const Summary = ({ name, schemaName, schema, required }) => {
|
|
|
77
137
|
react_1.default.createElement(
|
|
78
138
|
"span",
|
|
79
139
|
{ className: "openapi-schema__nullable" },
|
|
80
|
-
|
|
140
|
+
(0, Translate_1.translate)({
|
|
141
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.NULLABLE,
|
|
142
|
+
message: "nullable",
|
|
143
|
+
})
|
|
81
144
|
),
|
|
82
145
|
isRequired &&
|
|
83
146
|
react_1.default.createElement(
|
|
84
147
|
"span",
|
|
85
148
|
{ className: "openapi-schema__required" },
|
|
86
|
-
|
|
149
|
+
(0, Translate_1.translate)({
|
|
150
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
151
|
+
message: "required",
|
|
152
|
+
})
|
|
87
153
|
),
|
|
88
154
|
deprecated &&
|
|
89
155
|
react_1.default.createElement(
|
|
90
156
|
"span",
|
|
91
157
|
{ className: "openapi-schema__deprecated" },
|
|
92
|
-
|
|
158
|
+
(0, Translate_1.translate)({
|
|
159
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.DEPRECATED,
|
|
160
|
+
message: "deprecated",
|
|
161
|
+
})
|
|
93
162
|
)
|
|
94
163
|
)
|
|
95
164
|
);
|
|
96
165
|
};
|
|
97
|
-
const AnyOneOf = ({ schema, schemaType }) => {
|
|
98
|
-
const
|
|
166
|
+
const AnyOneOf = ({ schema, schemaType, schemaPath }) => {
|
|
167
|
+
const key = schema.oneOf ? "oneOf" : "anyOf";
|
|
168
|
+
const type = schema.oneOf
|
|
169
|
+
? (0, Translate_1.translate)({
|
|
170
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.ONE_OF,
|
|
171
|
+
message: "oneOf",
|
|
172
|
+
})
|
|
173
|
+
: (0, Translate_1.translate)({
|
|
174
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.ANY_OF,
|
|
175
|
+
message: "anyOf",
|
|
176
|
+
});
|
|
177
|
+
// Generate a unique ID for this anyOf/oneOf to prevent tab value collisions
|
|
178
|
+
const uniqueId = react_1.default.useMemo(
|
|
179
|
+
() => Math.random().toString(36).substring(7),
|
|
180
|
+
[]
|
|
181
|
+
);
|
|
182
|
+
// Try to get Redux dispatch - will be undefined if not inside a Provider
|
|
183
|
+
let dispatch;
|
|
184
|
+
try {
|
|
185
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
186
|
+
dispatch = (0, hooks_1.useTypedDispatch)();
|
|
187
|
+
} catch {
|
|
188
|
+
// Not inside a Redux Provider, which is fine for response schemas
|
|
189
|
+
dispatch = undefined;
|
|
190
|
+
}
|
|
191
|
+
// Handle tab change - dispatch to Redux if schemaPath is provided
|
|
192
|
+
const handleTabChange = (0, react_1.useCallback)(
|
|
193
|
+
(index) => {
|
|
194
|
+
if (schemaPath && dispatch) {
|
|
195
|
+
dispatch((0, slice_1.setSchemaSelection)({ path: schemaPath, index }));
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
[schemaPath, dispatch]
|
|
199
|
+
);
|
|
99
200
|
return react_1.default.createElement(
|
|
100
201
|
react_1.default.Fragment,
|
|
101
202
|
null,
|
|
@@ -106,19 +207,43 @@ const AnyOneOf = ({ schema, schemaType }) => {
|
|
|
106
207
|
),
|
|
107
208
|
react_1.default.createElement(
|
|
108
209
|
SchemaTabs_1.default,
|
|
109
|
-
|
|
110
|
-
schema[
|
|
111
|
-
|
|
210
|
+
{ groupId: `schema-${uniqueId}`, lazy: true, onChange: handleTabChange },
|
|
211
|
+
schema[key]?.map((anyOneSchema, index) => {
|
|
212
|
+
// Use getSchemaName to include format info (e.g., "string<date-time>")
|
|
213
|
+
const computedSchemaName = (0, schema_1.getSchemaName)(anyOneSchema);
|
|
214
|
+
// Determine label for the tab
|
|
215
|
+
// Prefer explicit title, then computed schema name, then raw type
|
|
216
|
+
let label =
|
|
217
|
+
anyOneSchema.title || computedSchemaName || anyOneSchema.type;
|
|
218
|
+
if (!label) {
|
|
219
|
+
if (anyOneSchema.oneOf) {
|
|
220
|
+
label = (0, Translate_1.translate)({
|
|
221
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.ONE_OF,
|
|
222
|
+
message: "oneOf",
|
|
223
|
+
});
|
|
224
|
+
} else if (anyOneSchema.anyOf) {
|
|
225
|
+
label = (0, Translate_1.translate)({
|
|
226
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.ANY_OF,
|
|
227
|
+
message: "anyOf",
|
|
228
|
+
});
|
|
229
|
+
} else {
|
|
230
|
+
label = `Option ${index + 1}`;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Build the nested schemaPath for child anyOf/oneOf
|
|
234
|
+
const childSchemaPath = schemaPath
|
|
235
|
+
? `${schemaPath}.${index}`
|
|
236
|
+
: undefined;
|
|
112
237
|
return (
|
|
113
238
|
// @ts-ignore
|
|
114
239
|
react_1.default.createElement(
|
|
115
240
|
TabItem_1.default,
|
|
116
|
-
{ key: index, label: label, value: `${index}-item
|
|
241
|
+
{ key: index, label: label, value: `${uniqueId}-${index}-item` },
|
|
117
242
|
(isPrimitive(anyOneSchema) || anyOneSchema.const) &&
|
|
118
243
|
react_1.default.createElement(SchemaItem_1.default, {
|
|
119
244
|
collapsible: false,
|
|
120
245
|
name: undefined,
|
|
121
|
-
schemaName:
|
|
246
|
+
schemaName: computedSchemaName,
|
|
122
247
|
qualifierMessage: (0, schema_1.getQualifierMessage)(
|
|
123
248
|
anyOneSchema
|
|
124
249
|
),
|
|
@@ -134,7 +259,7 @@ const AnyOneOf = ({ schema, schemaType }) => {
|
|
|
134
259
|
react_1.default.createElement(SchemaItem_1.default, {
|
|
135
260
|
collapsible: false,
|
|
136
261
|
name: undefined,
|
|
137
|
-
schemaName:
|
|
262
|
+
schemaName: computedSchemaName,
|
|
138
263
|
qualifierMessage: (0, schema_1.getQualifierMessage)(
|
|
139
264
|
anyOneSchema
|
|
140
265
|
),
|
|
@@ -142,31 +267,36 @@ const AnyOneOf = ({ schema, schemaType }) => {
|
|
|
142
267
|
discriminator: false,
|
|
143
268
|
children: null,
|
|
144
269
|
}),
|
|
145
|
-
anyOneSchema.type === "object" &&
|
|
270
|
+
(anyOneSchema.type === "object" || !anyOneSchema.type) &&
|
|
146
271
|
anyOneSchema.properties &&
|
|
147
272
|
react_1.default.createElement(Properties, {
|
|
148
273
|
schema: anyOneSchema,
|
|
149
274
|
schemaType: schemaType,
|
|
275
|
+
schemaPath: childSchemaPath,
|
|
150
276
|
}),
|
|
151
277
|
anyOneSchema.allOf &&
|
|
152
278
|
react_1.default.createElement(SchemaNode, {
|
|
153
279
|
schema: anyOneSchema,
|
|
154
280
|
schemaType: schemaType,
|
|
281
|
+
schemaPath: childSchemaPath,
|
|
155
282
|
}),
|
|
156
283
|
anyOneSchema.oneOf &&
|
|
157
284
|
react_1.default.createElement(SchemaNode, {
|
|
158
285
|
schema: anyOneSchema,
|
|
159
286
|
schemaType: schemaType,
|
|
287
|
+
schemaPath: childSchemaPath,
|
|
160
288
|
}),
|
|
161
289
|
anyOneSchema.anyOf &&
|
|
162
290
|
react_1.default.createElement(SchemaNode, {
|
|
163
291
|
schema: anyOneSchema,
|
|
164
292
|
schemaType: schemaType,
|
|
293
|
+
schemaPath: childSchemaPath,
|
|
165
294
|
}),
|
|
166
295
|
anyOneSchema.items &&
|
|
167
296
|
react_1.default.createElement(Items, {
|
|
168
297
|
schema: anyOneSchema,
|
|
169
298
|
schemaType: schemaType,
|
|
299
|
+
schemaPath: childSchemaPath,
|
|
170
300
|
})
|
|
171
301
|
)
|
|
172
302
|
);
|
|
@@ -174,7 +304,7 @@ const AnyOneOf = ({ schema, schemaType }) => {
|
|
|
174
304
|
)
|
|
175
305
|
);
|
|
176
306
|
};
|
|
177
|
-
const Properties = ({ schema, schemaType }) => {
|
|
307
|
+
const Properties = ({ schema, schemaType, schemaPath }) => {
|
|
178
308
|
const discriminator = schema.discriminator;
|
|
179
309
|
if (discriminator && !discriminator.mapping) {
|
|
180
310
|
const anyOneOf = schema.oneOf ?? schema.anyOf ?? {};
|
|
@@ -213,6 +343,7 @@ const Properties = ({ schema, schemaType }) => {
|
|
|
213
343
|
: false,
|
|
214
344
|
discriminator: discriminator,
|
|
215
345
|
schemaType: schemaType,
|
|
346
|
+
schemaPath: schemaPath ? `${schemaPath}.${key}` : undefined,
|
|
216
347
|
})
|
|
217
348
|
)
|
|
218
349
|
);
|
|
@@ -262,7 +393,10 @@ const PropertyDiscriminator = ({
|
|
|
262
393
|
react_1.default.createElement(
|
|
263
394
|
"span",
|
|
264
395
|
{ className: "openapi-schema__required" },
|
|
265
|
-
|
|
396
|
+
(0, Translate_1.translate)({
|
|
397
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
398
|
+
message: "required",
|
|
399
|
+
})
|
|
266
400
|
)
|
|
267
401
|
),
|
|
268
402
|
react_1.default.createElement(
|
|
@@ -446,6 +580,7 @@ const SchemaNodeDetails = ({
|
|
|
446
580
|
schema,
|
|
447
581
|
required,
|
|
448
582
|
schemaType,
|
|
583
|
+
schemaPath,
|
|
449
584
|
}) => {
|
|
450
585
|
return react_1.default.createElement(
|
|
451
586
|
SchemaItem_1.default,
|
|
@@ -475,12 +610,13 @@ const SchemaNodeDetails = ({
|
|
|
475
610
|
react_1.default.createElement(SchemaNode, {
|
|
476
611
|
schema: schema,
|
|
477
612
|
schemaType: schemaType,
|
|
613
|
+
schemaPath: schemaPath,
|
|
478
614
|
})
|
|
479
615
|
)
|
|
480
616
|
)
|
|
481
617
|
);
|
|
482
618
|
};
|
|
483
|
-
const Items = ({ schema, schemaType }) => {
|
|
619
|
+
const Items = ({ schema, schemaType, schemaPath }) => {
|
|
484
620
|
// Process schema.items to handle allOf merging
|
|
485
621
|
let itemsSchema = schema.items;
|
|
486
622
|
if (schema.items?.allOf) {
|
|
@@ -490,6 +626,8 @@ const Items = ({ schema, schemaType }) => {
|
|
|
490
626
|
const hasOneOfAnyOf = itemsSchema?.oneOf || itemsSchema?.anyOf;
|
|
491
627
|
const hasProperties = itemsSchema?.properties;
|
|
492
628
|
const hasAdditionalProperties = itemsSchema?.additionalProperties;
|
|
629
|
+
// Build the items schema path
|
|
630
|
+
const itemsSchemaPath = schemaPath ? `${schemaPath}.items` : undefined;
|
|
493
631
|
if (hasOneOfAnyOf || hasProperties || hasAdditionalProperties) {
|
|
494
632
|
return react_1.default.createElement(
|
|
495
633
|
react_1.default.Fragment,
|
|
@@ -499,11 +637,13 @@ const Items = ({ schema, schemaType }) => {
|
|
|
499
637
|
react_1.default.createElement(AnyOneOf, {
|
|
500
638
|
schema: itemsSchema,
|
|
501
639
|
schemaType: schemaType,
|
|
640
|
+
schemaPath: itemsSchemaPath,
|
|
502
641
|
}),
|
|
503
642
|
hasProperties &&
|
|
504
643
|
react_1.default.createElement(Properties, {
|
|
505
644
|
schema: itemsSchema,
|
|
506
645
|
schemaType: schemaType,
|
|
646
|
+
schemaPath: itemsSchemaPath,
|
|
507
647
|
}),
|
|
508
648
|
hasAdditionalProperties &&
|
|
509
649
|
react_1.default.createElement(AdditionalProperties, {
|
|
@@ -556,7 +696,14 @@ const Items = ({ schema, schemaType }) => {
|
|
|
556
696
|
react_1.default.createElement(ArrayBrackets_1.ClosingArrayBracket, null)
|
|
557
697
|
);
|
|
558
698
|
};
|
|
559
|
-
const SchemaEdge = ({
|
|
699
|
+
const SchemaEdge = ({
|
|
700
|
+
name,
|
|
701
|
+
schema,
|
|
702
|
+
required,
|
|
703
|
+
discriminator,
|
|
704
|
+
schemaType,
|
|
705
|
+
schemaPath,
|
|
706
|
+
}) => {
|
|
560
707
|
if (
|
|
561
708
|
(schemaType === "request" && schema.readOnly) ||
|
|
562
709
|
(schemaType === "response" && schema.writeOnly)
|
|
@@ -583,6 +730,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
583
730
|
required: required,
|
|
584
731
|
schema: schema,
|
|
585
732
|
nullable: schema.nullable,
|
|
733
|
+
schemaPath: schemaPath,
|
|
586
734
|
});
|
|
587
735
|
}
|
|
588
736
|
if (schema.properties) {
|
|
@@ -593,6 +741,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
593
741
|
required: required,
|
|
594
742
|
schema: schema,
|
|
595
743
|
nullable: schema.nullable,
|
|
744
|
+
schemaPath: schemaPath,
|
|
596
745
|
});
|
|
597
746
|
}
|
|
598
747
|
if (schema.additionalProperties) {
|
|
@@ -603,6 +752,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
603
752
|
required: required,
|
|
604
753
|
schema: schema,
|
|
605
754
|
nullable: schema.nullable,
|
|
755
|
+
schemaPath: schemaPath,
|
|
606
756
|
});
|
|
607
757
|
}
|
|
608
758
|
if (schema.items?.properties) {
|
|
@@ -613,9 +763,10 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
613
763
|
nullable: schema.nullable,
|
|
614
764
|
schema: schema,
|
|
615
765
|
schemaType: schemaType,
|
|
766
|
+
schemaPath: schemaPath,
|
|
616
767
|
});
|
|
617
768
|
}
|
|
618
|
-
if (schema.items?.anyOf || schema.items?.oneOf) {
|
|
769
|
+
if (schema.items?.anyOf || schema.items?.oneOf || schema.items?.allOf) {
|
|
619
770
|
return react_1.default.createElement(SchemaNodeDetails, {
|
|
620
771
|
name: name,
|
|
621
772
|
schemaName: schemaName,
|
|
@@ -623,6 +774,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
623
774
|
nullable: schema.nullable,
|
|
624
775
|
schema: schema,
|
|
625
776
|
schemaType: schemaType,
|
|
777
|
+
schemaPath: schemaPath,
|
|
626
778
|
});
|
|
627
779
|
}
|
|
628
780
|
if (schema.allOf) {
|
|
@@ -656,36 +808,33 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
656
808
|
return react_1.default.createElement(SchemaNodeDetails, {
|
|
657
809
|
name: name,
|
|
658
810
|
schemaName: mergedSchemaName,
|
|
659
|
-
required: Array.isArray(
|
|
660
|
-
? mergedSchemas.required.includes(name)
|
|
661
|
-
: mergedSchemas.required,
|
|
811
|
+
required: Array.isArray(required) ? required.includes(name) : required,
|
|
662
812
|
nullable: mergedSchemas.nullable,
|
|
663
813
|
schema: mergedSchemas,
|
|
664
814
|
schemaType: schemaType,
|
|
815
|
+
schemaPath: schemaPath,
|
|
665
816
|
});
|
|
666
817
|
}
|
|
667
818
|
if (mergedSchemas.properties !== undefined) {
|
|
668
819
|
return react_1.default.createElement(SchemaNodeDetails, {
|
|
669
820
|
name: name,
|
|
670
821
|
schemaName: mergedSchemaName,
|
|
671
|
-
required: Array.isArray(
|
|
672
|
-
? mergedSchemas.required.includes(name)
|
|
673
|
-
: mergedSchemas.required,
|
|
822
|
+
required: Array.isArray(required) ? required.includes(name) : required,
|
|
674
823
|
nullable: mergedSchemas.nullable,
|
|
675
824
|
schema: mergedSchemas,
|
|
676
825
|
schemaType: schemaType,
|
|
826
|
+
schemaPath: schemaPath,
|
|
677
827
|
});
|
|
678
828
|
}
|
|
679
829
|
if (mergedSchemas.items?.properties) {
|
|
680
|
-
react_1.default.createElement(SchemaNodeDetails, {
|
|
830
|
+
return react_1.default.createElement(SchemaNodeDetails, {
|
|
681
831
|
name: name,
|
|
682
832
|
schemaName: mergedSchemaName,
|
|
683
|
-
required: Array.isArray(
|
|
684
|
-
? mergedSchemas.required.includes(name)
|
|
685
|
-
: mergedSchemas.required,
|
|
833
|
+
required: Array.isArray(required) ? required.includes(name) : required,
|
|
686
834
|
nullable: mergedSchemas.nullable,
|
|
687
835
|
schema: mergedSchemas,
|
|
688
836
|
schemaType: schemaType,
|
|
837
|
+
schemaPath: schemaPath,
|
|
689
838
|
});
|
|
690
839
|
}
|
|
691
840
|
return react_1.default.createElement(SchemaItem_1.default, {
|
|
@@ -710,7 +859,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
710
859
|
children: null,
|
|
711
860
|
});
|
|
712
861
|
};
|
|
713
|
-
function renderChildren(schema, schemaType) {
|
|
862
|
+
function renderChildren(schema, schemaType, schemaPath) {
|
|
714
863
|
return react_1.default.createElement(
|
|
715
864
|
react_1.default.Fragment,
|
|
716
865
|
null,
|
|
@@ -718,16 +867,19 @@ function renderChildren(schema, schemaType) {
|
|
|
718
867
|
react_1.default.createElement(AnyOneOf, {
|
|
719
868
|
schema: schema,
|
|
720
869
|
schemaType: schemaType,
|
|
870
|
+
schemaPath: schemaPath,
|
|
721
871
|
}),
|
|
722
872
|
schema.anyOf &&
|
|
723
873
|
react_1.default.createElement(AnyOneOf, {
|
|
724
874
|
schema: schema,
|
|
725
875
|
schemaType: schemaType,
|
|
876
|
+
schemaPath: schemaPath,
|
|
726
877
|
}),
|
|
727
878
|
schema.properties &&
|
|
728
879
|
react_1.default.createElement(Properties, {
|
|
729
880
|
schema: schema,
|
|
730
881
|
schemaType: schemaType,
|
|
882
|
+
schemaPath: schemaPath,
|
|
731
883
|
}),
|
|
732
884
|
schema.additionalProperties &&
|
|
733
885
|
react_1.default.createElement(AdditionalProperties, {
|
|
@@ -738,10 +890,11 @@ function renderChildren(schema, schemaType) {
|
|
|
738
890
|
react_1.default.createElement(Items, {
|
|
739
891
|
schema: schema,
|
|
740
892
|
schemaType: schemaType,
|
|
893
|
+
schemaPath: schemaPath,
|
|
741
894
|
})
|
|
742
895
|
);
|
|
743
896
|
}
|
|
744
|
-
const SchemaNode = ({ schema, schemaType }) => {
|
|
897
|
+
const SchemaNode = ({ schema, schemaType, schemaPath }) => {
|
|
745
898
|
if (
|
|
746
899
|
(schemaType === "request" && schema.readOnly) ||
|
|
747
900
|
(schemaType === "response" && schema.writeOnly)
|
|
@@ -758,6 +911,53 @@ const SchemaNode = ({ schema, schemaType }) => {
|
|
|
758
911
|
}
|
|
759
912
|
// Handle allOf, oneOf, anyOf without discriminators
|
|
760
913
|
if (schema.allOf) {
|
|
914
|
+
// Check if allOf contains multiple oneOf/anyOf items that should be rendered separately
|
|
915
|
+
const oneOfItems = schema.allOf.filter((item) => item.oneOf || item.anyOf);
|
|
916
|
+
const hasMultipleChoices = oneOfItems.length > 1;
|
|
917
|
+
if (hasMultipleChoices) {
|
|
918
|
+
// Render each oneOf/anyOf constraint first, then shared properties
|
|
919
|
+
const mergedSchemas = mergeAllOf(schema);
|
|
920
|
+
if (
|
|
921
|
+
(schemaType === "request" && mergedSchemas.readOnly) ||
|
|
922
|
+
(schemaType === "response" && mergedSchemas.writeOnly)
|
|
923
|
+
) {
|
|
924
|
+
return null;
|
|
925
|
+
}
|
|
926
|
+
return react_1.default.createElement(
|
|
927
|
+
"div",
|
|
928
|
+
null,
|
|
929
|
+
schema.allOf.map((item, index) => {
|
|
930
|
+
if (item.oneOf || item.anyOf) {
|
|
931
|
+
const itemSchemaPath = schemaPath
|
|
932
|
+
? `${schemaPath}.allOf.${index}`
|
|
933
|
+
: undefined;
|
|
934
|
+
return react_1.default.createElement(
|
|
935
|
+
"div",
|
|
936
|
+
{ key: index },
|
|
937
|
+
react_1.default.createElement(AnyOneOf, {
|
|
938
|
+
schema: item,
|
|
939
|
+
schemaType: schemaType,
|
|
940
|
+
schemaPath: itemSchemaPath,
|
|
941
|
+
})
|
|
942
|
+
);
|
|
943
|
+
}
|
|
944
|
+
return null;
|
|
945
|
+
}),
|
|
946
|
+
mergedSchemas.properties &&
|
|
947
|
+
react_1.default.createElement(Properties, {
|
|
948
|
+
schema: mergedSchemas,
|
|
949
|
+
schemaType: schemaType,
|
|
950
|
+
schemaPath: schemaPath,
|
|
951
|
+
}),
|
|
952
|
+
mergedSchemas.items &&
|
|
953
|
+
react_1.default.createElement(Items, {
|
|
954
|
+
schema: mergedSchemas,
|
|
955
|
+
schemaType: schemaType,
|
|
956
|
+
schemaPath: schemaPath,
|
|
957
|
+
})
|
|
958
|
+
);
|
|
959
|
+
}
|
|
960
|
+
// For other allOf cases, use standard merge behavior
|
|
761
961
|
const mergedSchemas = mergeAllOf(schema);
|
|
762
962
|
if (
|
|
763
963
|
(schemaType === "request" && mergedSchemas.readOnly) ||
|
|
@@ -772,21 +972,25 @@ const SchemaNode = ({ schema, schemaType }) => {
|
|
|
772
972
|
react_1.default.createElement(AnyOneOf, {
|
|
773
973
|
schema: mergedSchemas,
|
|
774
974
|
schemaType: schemaType,
|
|
975
|
+
schemaPath: schemaPath,
|
|
775
976
|
}),
|
|
776
977
|
mergedSchemas.anyOf &&
|
|
777
978
|
react_1.default.createElement(AnyOneOf, {
|
|
778
979
|
schema: mergedSchemas,
|
|
779
980
|
schemaType: schemaType,
|
|
981
|
+
schemaPath: schemaPath,
|
|
780
982
|
}),
|
|
781
983
|
mergedSchemas.properties &&
|
|
782
984
|
react_1.default.createElement(Properties, {
|
|
783
985
|
schema: mergedSchemas,
|
|
784
986
|
schemaType: schemaType,
|
|
987
|
+
schemaPath: schemaPath,
|
|
785
988
|
}),
|
|
786
989
|
mergedSchemas.items &&
|
|
787
990
|
react_1.default.createElement(Items, {
|
|
788
991
|
schema: mergedSchemas,
|
|
789
992
|
schemaType: schemaType,
|
|
993
|
+
schemaPath: schemaPath,
|
|
790
994
|
})
|
|
791
995
|
);
|
|
792
996
|
}
|
|
@@ -812,7 +1016,7 @@ const SchemaNode = ({ schema, schemaType }) => {
|
|
|
812
1016
|
children: null,
|
|
813
1017
|
});
|
|
814
1018
|
}
|
|
815
|
-
return renderChildren(schema, schemaType);
|
|
1019
|
+
return renderChildren(schema, schemaType, schemaPath);
|
|
816
1020
|
};
|
|
817
1021
|
exports.default = SchemaNode;
|
|
818
1022
|
const PRIMITIVE_TYPES = {
|
|
@@ -823,5 +1027,10 @@ const PRIMITIVE_TYPES = {
|
|
|
823
1027
|
null: true,
|
|
824
1028
|
};
|
|
825
1029
|
const isPrimitive = (schema) => {
|
|
1030
|
+
// Enum-only schemas (without explicit type) should be treated as primitives
|
|
1031
|
+
// This is valid JSON Schema where enum values define the constraints
|
|
1032
|
+
if (schema.enum && !schema.type) {
|
|
1033
|
+
return true;
|
|
1034
|
+
}
|
|
826
1035
|
return PRIMITIVE_TYPES[schema.type];
|
|
827
1036
|
};
|