docusaurus-plugin-openapi-docs 0.0.0-775 → 0.0.0-780
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.
|
@@ -90,6 +90,10 @@ function createAnyOneOf(schema) {
|
|
|
90
90
|
anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
|
|
91
91
|
delete anyOneSchema.allOf;
|
|
92
92
|
}
|
|
93
|
+
if (anyOneSchema.oneOf !== undefined) {
|
|
94
|
+
anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
|
|
95
|
+
delete anyOneSchema.oneOf;
|
|
96
|
+
}
|
|
93
97
|
if (anyOneSchema.items !== undefined) {
|
|
94
98
|
anyOneChildren.push(createItems(anyOneSchema));
|
|
95
99
|
delete anyOneSchema.items;
|
|
@@ -218,6 +218,54 @@ describe("createNodes", () => {
|
|
|
218
218
|
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
219
219
|
});
|
|
220
220
|
});
|
|
221
|
+
describe("anyOf", () => {
|
|
222
|
+
it("should render primitives within anyOf", async () => {
|
|
223
|
+
const schema = {
|
|
224
|
+
type: "object",
|
|
225
|
+
properties: {
|
|
226
|
+
oneOfProperty: {
|
|
227
|
+
anyOf: [
|
|
228
|
+
{
|
|
229
|
+
type: "integer",
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
type: "boolean",
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
title: "One of int or bool",
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
240
|
+
});
|
|
241
|
+
it("should render oneOf within anyOf", async () => {
|
|
242
|
+
const schema = {
|
|
243
|
+
type: "object",
|
|
244
|
+
properties: {
|
|
245
|
+
oneOfProperty: {
|
|
246
|
+
anyOf: [
|
|
247
|
+
{
|
|
248
|
+
oneOf: [
|
|
249
|
+
{
|
|
250
|
+
type: "integer",
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
type: "boolean",
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
title: "An int or a bool",
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
type: "string",
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
title: "One of int or bool, or a string",
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
267
|
+
});
|
|
268
|
+
});
|
|
221
269
|
describe("allOf", () => {
|
|
222
270
|
it("should render same-level properties with allOf", async () => {
|
|
223
271
|
const schema = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-openapi-docs",
|
|
3
3
|
"description": "OpenAPI plugin for Docusaurus.",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-780",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "43440ab62a83e241792cc9edbcee95cf14f2195d"
|
|
66
66
|
}
|
|
@@ -368,6 +368,93 @@ Array [
|
|
|
368
368
|
]
|
|
369
369
|
`;
|
|
370
370
|
|
|
371
|
+
exports[`createNodes anyOf should render oneOf within anyOf 1`] = `
|
|
372
|
+
Array [
|
|
373
|
+
"<SchemaItem collapsible={true} className={\\"schemaItem\\"}>
|
|
374
|
+
<details style={{}} className={\\"openapi-markdown__details\\"}>
|
|
375
|
+
<summary style={{}}>
|
|
376
|
+
<span className={\\"openapi-schema__container\\"}>
|
|
377
|
+
<strong className={\\"openapi-schema__property\\"}>oneOfProperty</strong>
|
|
378
|
+
<span className={\\"openapi-schema__name\\"}>object</span>
|
|
379
|
+
</span>
|
|
380
|
+
</summary>
|
|
381
|
+
<div style={{ marginLeft: \\"1rem\\" }}>
|
|
382
|
+
<div>
|
|
383
|
+
<span className={\\"badge badge--info\\"} style={{ marginBottom: \\"1rem\\" }}>
|
|
384
|
+
anyOf
|
|
385
|
+
</span>
|
|
386
|
+
<SchemaTabs>
|
|
387
|
+
<TabItem label={\\"An int or a bool\\"} value={\\"0-item-properties\\"}>
|
|
388
|
+
<div>
|
|
389
|
+
<span
|
|
390
|
+
className={\\"badge badge--info\\"}
|
|
391
|
+
style={{ marginBottom: \\"1rem\\" }}
|
|
392
|
+
>
|
|
393
|
+
oneOf
|
|
394
|
+
</span>
|
|
395
|
+
<SchemaTabs>
|
|
396
|
+
<TabItem label={\\"MOD1\\"} value={\\"0-item-properties\\"}>
|
|
397
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
398
|
+
integer
|
|
399
|
+
</div>
|
|
400
|
+
</TabItem>
|
|
401
|
+
<TabItem label={\\"MOD2\\"} value={\\"1-item-properties\\"}>
|
|
402
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
403
|
+
boolean
|
|
404
|
+
</div>
|
|
405
|
+
</TabItem>
|
|
406
|
+
</SchemaTabs>
|
|
407
|
+
</div>
|
|
408
|
+
</TabItem>
|
|
409
|
+
<TabItem label={\\"MOD2\\"} value={\\"1-item-properties\\"}>
|
|
410
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
411
|
+
string
|
|
412
|
+
</div>
|
|
413
|
+
</TabItem>
|
|
414
|
+
</SchemaTabs>
|
|
415
|
+
</div>
|
|
416
|
+
</div>
|
|
417
|
+
</details>
|
|
418
|
+
</SchemaItem>;
|
|
419
|
+
",
|
|
420
|
+
]
|
|
421
|
+
`;
|
|
422
|
+
|
|
423
|
+
exports[`createNodes anyOf should render primitives within anyOf 1`] = `
|
|
424
|
+
Array [
|
|
425
|
+
"<SchemaItem collapsible={true} className={\\"schemaItem\\"}>
|
|
426
|
+
<details style={{}} className={\\"openapi-markdown__details\\"}>
|
|
427
|
+
<summary style={{}}>
|
|
428
|
+
<span className={\\"openapi-schema__container\\"}>
|
|
429
|
+
<strong className={\\"openapi-schema__property\\"}>oneOfProperty</strong>
|
|
430
|
+
<span className={\\"openapi-schema__name\\"}>object</span>
|
|
431
|
+
</span>
|
|
432
|
+
</summary>
|
|
433
|
+
<div style={{ marginLeft: \\"1rem\\" }}>
|
|
434
|
+
<div>
|
|
435
|
+
<span className={\\"badge badge--info\\"} style={{ marginBottom: \\"1rem\\" }}>
|
|
436
|
+
anyOf
|
|
437
|
+
</span>
|
|
438
|
+
<SchemaTabs>
|
|
439
|
+
<TabItem label={\\"MOD1\\"} value={\\"0-item-properties\\"}>
|
|
440
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
441
|
+
integer
|
|
442
|
+
</div>
|
|
443
|
+
</TabItem>
|
|
444
|
+
<TabItem label={\\"MOD2\\"} value={\\"1-item-properties\\"}>
|
|
445
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
446
|
+
boolean
|
|
447
|
+
</div>
|
|
448
|
+
</TabItem>
|
|
449
|
+
</SchemaTabs>
|
|
450
|
+
</div>
|
|
451
|
+
</div>
|
|
452
|
+
</details>
|
|
453
|
+
</SchemaItem>;
|
|
454
|
+
",
|
|
455
|
+
]
|
|
456
|
+
`;
|
|
457
|
+
|
|
371
458
|
exports[`createNodes discriminator should handle basic discriminator with mapping 1`] = `
|
|
372
459
|
Array [
|
|
373
460
|
"<div>
|
|
@@ -246,6 +246,70 @@ describe("createNodes", () => {
|
|
|
246
246
|
});
|
|
247
247
|
});
|
|
248
248
|
|
|
249
|
+
describe("anyOf", () => {
|
|
250
|
+
it("should render primitives within anyOf", async () => {
|
|
251
|
+
const schema: SchemaObject = {
|
|
252
|
+
type: "object",
|
|
253
|
+
properties: {
|
|
254
|
+
oneOfProperty: {
|
|
255
|
+
anyOf: [
|
|
256
|
+
{
|
|
257
|
+
type: "integer",
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
type: "boolean",
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
title: "One of int or bool",
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
expect(
|
|
269
|
+
await Promise.all(
|
|
270
|
+
createNodes(schema, "response").map(
|
|
271
|
+
async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
272
|
+
)
|
|
273
|
+
)
|
|
274
|
+
).toMatchSnapshot();
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it("should render oneOf within anyOf", async () => {
|
|
278
|
+
const schema: SchemaObject = {
|
|
279
|
+
type: "object",
|
|
280
|
+
properties: {
|
|
281
|
+
oneOfProperty: {
|
|
282
|
+
anyOf: [
|
|
283
|
+
{
|
|
284
|
+
oneOf: [
|
|
285
|
+
{
|
|
286
|
+
type: "integer",
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
type: "boolean",
|
|
290
|
+
},
|
|
291
|
+
],
|
|
292
|
+
title: "An int or a bool",
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
type: "string",
|
|
296
|
+
},
|
|
297
|
+
],
|
|
298
|
+
title: "One of int or bool, or a string",
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
expect(
|
|
304
|
+
await Promise.all(
|
|
305
|
+
createNodes(schema, "response").map(
|
|
306
|
+
async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
307
|
+
)
|
|
308
|
+
)
|
|
309
|
+
).toMatchSnapshot();
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
|
|
249
313
|
describe("allOf", () => {
|
|
250
314
|
it("should render same-level properties with allOf", async () => {
|
|
251
315
|
const schema: SchemaObject = {
|
|
@@ -104,6 +104,11 @@ function createAnyOneOf(schema: SchemaObject): any {
|
|
|
104
104
|
delete anyOneSchema.allOf;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
if (anyOneSchema.oneOf !== undefined) {
|
|
108
|
+
anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
|
|
109
|
+
delete anyOneSchema.oneOf;
|
|
110
|
+
}
|
|
111
|
+
|
|
107
112
|
if (anyOneSchema.items !== undefined) {
|
|
108
113
|
anyOneChildren.push(createItems(anyOneSchema));
|
|
109
114
|
delete anyOneSchema.items;
|