docusaurus-plugin-openapi-docs 3.0.1 → 3.0.2
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/README.md +2 -2
- package/lib/index.js +9 -0
- package/lib/markdown/createSchema.js +112 -82
- package/lib/markdown/createSchema.test.js +247 -29
- package/lib/markdown/createStatusCodes.js +12 -8
- package/lib/markdown/index.js +0 -1
- package/lib/openapi/createRequestExample.js +2 -2
- package/lib/openapi/createResponseExample.js +2 -2
- package/package.json +2 -2
- package/src/index.ts +12 -0
- package/src/markdown/__snapshots__/createSchema.test.ts.snap +220 -56
- package/src/markdown/createSchema.test.ts +290 -34
- package/src/markdown/createSchema.ts +149 -128
- package/src/markdown/createStatusCodes.ts +12 -8
- package/src/markdown/index.ts +0 -1
- package/src/openapi/createRequestExample.ts +2 -2
- package/src/openapi/createResponseExample.ts +2 -2
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": "3.0.
|
|
4
|
+
"version": "3.0.2",
|
|
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": "071a66e28184054dde1df825509c731bf819a3ed"
|
|
66
66
|
}
|
package/src/index.ts
CHANGED
|
@@ -535,6 +535,18 @@ custom_edit_url: null
|
|
|
535
535
|
});
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
+
if (!fs.existsSync(outputDir)) {
|
|
539
|
+
try {
|
|
540
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
541
|
+
console.log(chalk.green(`Successfully created "${outputDir}"`));
|
|
542
|
+
} catch (err) {
|
|
543
|
+
console.error(
|
|
544
|
+
chalk.red(`Failed to create "${outputDir}"`),
|
|
545
|
+
chalk.yellow(err)
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
538
550
|
const versionsJson = JSON.stringify(versionsArray, null, 2);
|
|
539
551
|
try {
|
|
540
552
|
fs.writeFileSync(
|
|
@@ -12,7 +12,9 @@ Array [
|
|
|
12
12
|
</summary>
|
|
13
13
|
<div style={{ marginLeft: \\"1rem\\" }}>
|
|
14
14
|
<div>
|
|
15
|
-
<span className={\\"badge badge--info\\"}>
|
|
15
|
+
<span className={\\"badge badge--info\\"} style={{ marginBottom: \\"1rem\\" }}>
|
|
16
|
+
oneOf
|
|
17
|
+
</span>
|
|
16
18
|
<SchemaTabs>
|
|
17
19
|
<TabItem label={\\"MOD1\\"} value={\\"0-item-properties\\"}>
|
|
18
20
|
<SchemaItem
|
|
@@ -221,72 +223,234 @@ Array [
|
|
|
221
223
|
]
|
|
222
224
|
`;
|
|
223
225
|
|
|
224
|
-
exports[`createNodes should
|
|
226
|
+
exports[`createNodes allOf should correctly deep merge properties in allOf schemas 1`] = `
|
|
225
227
|
Array [
|
|
226
228
|
"<SchemaItem collapsible={true} className={\\"schemaItem\\"}>
|
|
227
229
|
<details style={{}} className={\\"openapi-markdown__details\\"}>
|
|
228
230
|
<summary style={{}}>
|
|
229
|
-
<
|
|
230
|
-
|
|
231
|
+
<span className={\\"openapi-schema__container\\"}>
|
|
232
|
+
<strong className={\\"openapi-schema__property\\"}>deepProp</strong>
|
|
233
|
+
<span className={\\"openapi-schema__name\\"}>object</span>
|
|
234
|
+
</span>
|
|
231
235
|
</summary>
|
|
232
|
-
<div style={{ marginLeft: \\"1rem\\" }}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
236
|
+
<div style={{ marginLeft: \\"1rem\\" }}>
|
|
237
|
+
<SchemaItem
|
|
238
|
+
collapsible={false}
|
|
239
|
+
name={\\"innerProp1\\"}
|
|
240
|
+
required={false}
|
|
241
|
+
schemaName={\\"string\\"}
|
|
242
|
+
qualifierMessage={undefined}
|
|
243
|
+
schema={{ type: \\"string\\" }}
|
|
244
|
+
></SchemaItem>
|
|
245
|
+
<SchemaItem
|
|
246
|
+
collapsible={false}
|
|
247
|
+
name={\\"innerProp2\\"}
|
|
248
|
+
required={false}
|
|
249
|
+
schemaName={\\"number\\"}
|
|
250
|
+
qualifierMessage={undefined}
|
|
251
|
+
schema={{ type: \\"number\\" }}
|
|
252
|
+
></SchemaItem>
|
|
253
|
+
</div>
|
|
254
|
+
</details>
|
|
255
|
+
</SchemaItem>;
|
|
256
|
+
",
|
|
257
|
+
]
|
|
258
|
+
`;
|
|
259
|
+
|
|
260
|
+
exports[`createNodes allOf should correctly handle shared required properties across allOf schemas 1`] = `
|
|
261
|
+
Array [
|
|
262
|
+
"<SchemaItem
|
|
263
|
+
collapsible={false}
|
|
264
|
+
name={\\"sharedProp\\"}
|
|
265
|
+
required={true}
|
|
266
|
+
schemaName={\\"string\\"}
|
|
267
|
+
qualifierMessage={undefined}
|
|
268
|
+
schema={{ type: \\"string\\" }}
|
|
269
|
+
></SchemaItem>;
|
|
270
|
+
",
|
|
271
|
+
"<SchemaItem
|
|
272
|
+
collapsible={false}
|
|
273
|
+
name={\\"anotherProp\\"}
|
|
274
|
+
required={true}
|
|
275
|
+
schemaName={\\"number\\"}
|
|
276
|
+
qualifierMessage={undefined}
|
|
277
|
+
schema={{ type: \\"number\\" }}
|
|
278
|
+
></SchemaItem>;
|
|
279
|
+
",
|
|
280
|
+
]
|
|
281
|
+
`;
|
|
282
|
+
|
|
283
|
+
exports[`createNodes allOf should correctly merge nested properties from multiple allOf schemas 1`] = `
|
|
284
|
+
Array [
|
|
285
|
+
"<SchemaItem collapsible={true} className={\\"schemaItem\\"}>
|
|
286
|
+
<details style={{}} className={\\"openapi-markdown__details\\"}>
|
|
287
|
+
<summary style={{}}>
|
|
288
|
+
<span className={\\"openapi-schema__container\\"}>
|
|
289
|
+
<strong className={\\"openapi-schema__property\\"}>outerProp1</strong>
|
|
290
|
+
<span className={\\"openapi-schema__name\\"}>object</span>
|
|
291
|
+
</span>
|
|
292
|
+
</summary>
|
|
293
|
+
<div style={{ marginLeft: \\"1rem\\" }}>
|
|
294
|
+
<SchemaItem
|
|
295
|
+
collapsible={false}
|
|
296
|
+
name={\\"innerProp1\\"}
|
|
297
|
+
required={false}
|
|
298
|
+
schemaName={\\"string\\"}
|
|
299
|
+
qualifierMessage={undefined}
|
|
300
|
+
schema={{ type: \\"string\\" }}
|
|
301
|
+
></SchemaItem>
|
|
302
|
+
</div>
|
|
303
|
+
</details>
|
|
304
|
+
</SchemaItem>;
|
|
305
|
+
",
|
|
306
|
+
"<SchemaItem collapsible={true} className={\\"schemaItem\\"}>
|
|
307
|
+
<details style={{}} className={\\"openapi-markdown__details\\"}>
|
|
308
|
+
<summary style={{}}>
|
|
309
|
+
<span className={\\"openapi-schema__container\\"}>
|
|
310
|
+
<strong className={\\"openapi-schema__property\\"}>outerProp2</strong>
|
|
311
|
+
<span className={\\"openapi-schema__name\\"}>object</span>
|
|
312
|
+
</span>
|
|
313
|
+
</summary>
|
|
314
|
+
<div style={{ marginLeft: \\"1rem\\" }}>
|
|
315
|
+
<SchemaItem
|
|
316
|
+
collapsible={false}
|
|
317
|
+
name={\\"innerProp2\\"}
|
|
318
|
+
required={false}
|
|
319
|
+
schemaName={\\"number\\"}
|
|
320
|
+
qualifierMessage={undefined}
|
|
321
|
+
schema={{ type: \\"number\\" }}
|
|
322
|
+
></SchemaItem>
|
|
323
|
+
</div>
|
|
324
|
+
</details>
|
|
325
|
+
</SchemaItem>;
|
|
326
|
+
",
|
|
327
|
+
]
|
|
328
|
+
`;
|
|
329
|
+
|
|
330
|
+
exports[`createNodes allOf should render same-level properties with allOf 1`] = `
|
|
331
|
+
Array [
|
|
332
|
+
"<SchemaItem
|
|
333
|
+
collapsible={false}
|
|
334
|
+
name={\\"parentProp1\\"}
|
|
335
|
+
required={false}
|
|
336
|
+
schemaName={\\"string\\"}
|
|
337
|
+
qualifierMessage={undefined}
|
|
338
|
+
schema={{ type: \\"string\\" }}
|
|
339
|
+
></SchemaItem>;
|
|
340
|
+
",
|
|
341
|
+
"<SchemaItem
|
|
342
|
+
collapsible={false}
|
|
343
|
+
name={\\"parentProp2\\"}
|
|
344
|
+
required={false}
|
|
345
|
+
schemaName={\\"string\\"}
|
|
346
|
+
qualifierMessage={undefined}
|
|
347
|
+
schema={{ type: \\"string\\" }}
|
|
348
|
+
></SchemaItem>;
|
|
349
|
+
",
|
|
350
|
+
"<SchemaItem
|
|
351
|
+
collapsible={false}
|
|
352
|
+
name={\\"allOfProp1\\"}
|
|
353
|
+
required={false}
|
|
354
|
+
schemaName={\\"string\\"}
|
|
355
|
+
qualifierMessage={undefined}
|
|
356
|
+
schema={{ type: \\"string\\" }}
|
|
357
|
+
></SchemaItem>;
|
|
358
|
+
",
|
|
359
|
+
"<SchemaItem
|
|
360
|
+
collapsible={false}
|
|
361
|
+
name={\\"allOfProp2\\"}
|
|
362
|
+
required={false}
|
|
363
|
+
schemaName={\\"string\\"}
|
|
364
|
+
qualifierMessage={undefined}
|
|
365
|
+
schema={{ type: \\"string\\" }}
|
|
366
|
+
></SchemaItem>;
|
|
367
|
+
",
|
|
368
|
+
]
|
|
369
|
+
`;
|
|
370
|
+
|
|
371
|
+
exports[`createNodes oneOf should create readable MODs for oneOf primitive properties 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
|
+
oneOf
|
|
385
|
+
</span>
|
|
386
|
+
<SchemaTabs>
|
|
387
|
+
<TabItem label={\\"MOD1\\"} value={\\"0-item-properties\\"}>
|
|
248
388
|
<div
|
|
249
|
-
style={{
|
|
250
|
-
|
|
251
|
-
opacity: \\"0.6\\",
|
|
252
|
-
marginLeft: \\"-.5rem\\",
|
|
253
|
-
paddingBottom: \\".5rem\\",
|
|
254
|
-
}}
|
|
389
|
+
style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}
|
|
390
|
+
className={\\"openapi-schema__summary\\"}
|
|
255
391
|
>
|
|
256
|
-
|
|
392
|
+
Clown's nose length
|
|
257
393
|
</div>
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
394
|
+
<SchemaItem
|
|
395
|
+
collapsible={false}
|
|
396
|
+
name={\\"noseLength\\"}
|
|
397
|
+
required={true}
|
|
398
|
+
schemaName={\\"number\\"}
|
|
399
|
+
qualifierMessage={undefined}
|
|
400
|
+
schema={{ type: \\"number\\" }}
|
|
401
|
+
></SchemaItem>
|
|
402
|
+
</TabItem>
|
|
403
|
+
<TabItem label={\\"MOD2\\"} value={\\"1-item-properties\\"}>
|
|
263
404
|
<div
|
|
264
|
-
style={{
|
|
265
|
-
|
|
266
|
-
opacity: \\"0.6\\",
|
|
267
|
-
marginLeft: \\"-.5rem\\",
|
|
268
|
-
}}
|
|
405
|
+
style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}
|
|
406
|
+
className={\\"openapi-schema__summary\\"}
|
|
269
407
|
>
|
|
270
|
-
|
|
408
|
+
Array of strings
|
|
409
|
+
</div>
|
|
410
|
+
<li>
|
|
411
|
+
<div
|
|
412
|
+
style={{
|
|
413
|
+
fontSize: \\"var(--ifm-code-font-size)\\",
|
|
414
|
+
opacity: \\"0.6\\",
|
|
415
|
+
marginLeft: \\"-.5rem\\",
|
|
416
|
+
paddingBottom: \\".5rem\\",
|
|
417
|
+
}}
|
|
418
|
+
>
|
|
419
|
+
Array [
|
|
420
|
+
</div>
|
|
421
|
+
</li>
|
|
422
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
423
|
+
string
|
|
424
|
+
</div>
|
|
425
|
+
<li>
|
|
426
|
+
<div
|
|
427
|
+
style={{
|
|
428
|
+
fontSize: \\"var(--ifm-code-font-size)\\",
|
|
429
|
+
opacity: \\"0.6\\",
|
|
430
|
+
marginLeft: \\"-.5rem\\",
|
|
431
|
+
}}
|
|
432
|
+
>
|
|
433
|
+
]
|
|
434
|
+
</div>
|
|
435
|
+
</li>
|
|
436
|
+
</TabItem>
|
|
437
|
+
<TabItem label={\\"MOD3\\"} value={\\"2-item-properties\\"}>
|
|
438
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
439
|
+
boolean
|
|
271
440
|
</div>
|
|
272
|
-
</
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
</
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
</
|
|
283
|
-
</
|
|
284
|
-
|
|
285
|
-
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
286
|
-
string
|
|
287
|
-
</div>
|
|
288
|
-
</TabItem>
|
|
289
|
-
</SchemaTabs>
|
|
441
|
+
</TabItem>
|
|
442
|
+
<TabItem label={\\"MOD4\\"} value={\\"3-item-properties\\"}>
|
|
443
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
444
|
+
number
|
|
445
|
+
</div>
|
|
446
|
+
</TabItem>
|
|
447
|
+
<TabItem label={\\"MOD5\\"} value={\\"4-item-properties\\"}>
|
|
448
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
449
|
+
string
|
|
450
|
+
</div>
|
|
451
|
+
</TabItem>
|
|
452
|
+
</SchemaTabs>
|
|
453
|
+
</div>
|
|
290
454
|
</div>
|
|
291
455
|
</details>
|
|
292
456
|
</SchemaItem>;
|
|
@@ -11,50 +11,306 @@ import { createNodes } from "./createSchema";
|
|
|
11
11
|
import { SchemaObject } from "../openapi/types";
|
|
12
12
|
|
|
13
13
|
describe("createNodes", () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
describe("oneOf", () => {
|
|
15
|
+
it("should create readable MODs for oneOf primitive properties", async () => {
|
|
16
|
+
const schema: SchemaObject = {
|
|
17
|
+
"x-tags": ["clown"],
|
|
18
|
+
type: "object",
|
|
19
|
+
properties: {
|
|
20
|
+
oneOfProperty: {
|
|
21
|
+
oneOf: [
|
|
22
|
+
{
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: {
|
|
25
|
+
noseLength: {
|
|
26
|
+
type: "number",
|
|
27
|
+
},
|
|
26
28
|
},
|
|
29
|
+
required: ["noseLength"],
|
|
30
|
+
description: "Clown's nose length",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: "array",
|
|
34
|
+
items: {
|
|
35
|
+
type: "string",
|
|
36
|
+
},
|
|
37
|
+
description: "Array of strings",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: "boolean",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: "number",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: "string",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
expect(
|
|
53
|
+
await Promise.all(
|
|
54
|
+
createNodes(schema, "request").map(
|
|
55
|
+
async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
).toMatchSnapshot();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe("allOf", () => {
|
|
63
|
+
it("should render same-level properties with allOf", async () => {
|
|
64
|
+
const schema: SchemaObject = {
|
|
65
|
+
allOf: [
|
|
66
|
+
{
|
|
67
|
+
type: "object",
|
|
68
|
+
properties: {
|
|
69
|
+
allOfProp1: {
|
|
70
|
+
type: "string",
|
|
71
|
+
},
|
|
72
|
+
allOfProp2: {
|
|
73
|
+
type: "string",
|
|
27
74
|
},
|
|
28
|
-
required: ["noseLength"],
|
|
29
|
-
description: "Clown's nose length",
|
|
30
75
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
properties: {
|
|
79
|
+
parentProp1: {
|
|
80
|
+
type: "string",
|
|
81
|
+
},
|
|
82
|
+
parentProp2: {
|
|
83
|
+
type: "string",
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
expect(
|
|
89
|
+
await Promise.all(
|
|
90
|
+
createNodes(schema, "response").map(
|
|
91
|
+
async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
92
|
+
)
|
|
93
|
+
)
|
|
94
|
+
).toMatchSnapshot();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("should correctly merge nested properties from multiple allOf schemas", async () => {
|
|
98
|
+
const schema: SchemaObject = {
|
|
99
|
+
allOf: [
|
|
100
|
+
{
|
|
101
|
+
type: "object",
|
|
102
|
+
properties: {
|
|
103
|
+
outerProp1: {
|
|
104
|
+
type: "object",
|
|
105
|
+
properties: {
|
|
106
|
+
innerProp1: {
|
|
107
|
+
type: "string",
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
type: "object",
|
|
115
|
+
properties: {
|
|
116
|
+
outerProp2: {
|
|
117
|
+
type: "object",
|
|
118
|
+
properties: {
|
|
119
|
+
innerProp2: {
|
|
120
|
+
type: "number",
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
expect(
|
|
130
|
+
await Promise.all(
|
|
131
|
+
createNodes(schema, "response").map(
|
|
132
|
+
async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
).toMatchSnapshot();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("should correctly handle shared required properties across allOf schemas", async () => {
|
|
139
|
+
const schema: SchemaObject = {
|
|
140
|
+
allOf: [
|
|
141
|
+
{
|
|
142
|
+
type: "object",
|
|
143
|
+
properties: {
|
|
144
|
+
sharedProp: {
|
|
34
145
|
type: "string",
|
|
35
146
|
},
|
|
36
|
-
description: "Array of strings",
|
|
37
147
|
},
|
|
38
|
-
|
|
39
|
-
|
|
148
|
+
required: ["sharedProp"],
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
type: "object",
|
|
152
|
+
properties: {
|
|
153
|
+
anotherProp: {
|
|
154
|
+
type: "number",
|
|
155
|
+
},
|
|
40
156
|
},
|
|
41
|
-
|
|
42
|
-
|
|
157
|
+
required: ["anotherProp"],
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
expect(
|
|
163
|
+
await Promise.all(
|
|
164
|
+
createNodes(schema, "response").map(
|
|
165
|
+
async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
166
|
+
)
|
|
167
|
+
)
|
|
168
|
+
).toMatchSnapshot();
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Could not resolve values for path:"properties.conflictingProp.type". They are probably incompatible. Values:
|
|
172
|
+
// "string"
|
|
173
|
+
// "number"
|
|
174
|
+
// eslint-disable-next-line jest/no-commented-out-tests
|
|
175
|
+
// it("should handle conflicting properties in allOf schemas", async () => {
|
|
176
|
+
// const schema: SchemaObject = {
|
|
177
|
+
// allOf: [
|
|
178
|
+
// {
|
|
179
|
+
// type: "object",
|
|
180
|
+
// properties: {
|
|
181
|
+
// conflictingProp: {
|
|
182
|
+
// type: "string",
|
|
183
|
+
// },
|
|
184
|
+
// },
|
|
185
|
+
// },
|
|
186
|
+
// {
|
|
187
|
+
// type: "object",
|
|
188
|
+
// properties: {
|
|
189
|
+
// conflictingProp: {
|
|
190
|
+
// type: "number",
|
|
191
|
+
// },
|
|
192
|
+
// },
|
|
193
|
+
// },
|
|
194
|
+
// ],
|
|
195
|
+
// };
|
|
196
|
+
|
|
197
|
+
// expect(
|
|
198
|
+
// await Promise.all(
|
|
199
|
+
// createNodes(schema, "response").map(
|
|
200
|
+
// async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
201
|
+
// )
|
|
202
|
+
// )
|
|
203
|
+
// ).toMatchSnapshot();
|
|
204
|
+
// });
|
|
205
|
+
|
|
206
|
+
// Could not resolve values for path:"type". They are probably incompatible. Values:
|
|
207
|
+
// "object"
|
|
208
|
+
// "array"
|
|
209
|
+
// eslint-disable-next-line jest/no-commented-out-tests
|
|
210
|
+
// it("should handle mixed data types in allOf schemas", async () => {
|
|
211
|
+
// const schema: SchemaObject = {
|
|
212
|
+
// allOf: [
|
|
213
|
+
// {
|
|
214
|
+
// type: "object",
|
|
215
|
+
// properties: {
|
|
216
|
+
// mixedTypeProp1: {
|
|
217
|
+
// type: "string",
|
|
218
|
+
// },
|
|
219
|
+
// },
|
|
220
|
+
// },
|
|
221
|
+
// {
|
|
222
|
+
// type: "array",
|
|
223
|
+
// items: {
|
|
224
|
+
// type: "number",
|
|
225
|
+
// },
|
|
226
|
+
// },
|
|
227
|
+
// ],
|
|
228
|
+
// };
|
|
229
|
+
|
|
230
|
+
// expect(
|
|
231
|
+
// await Promise.all(
|
|
232
|
+
// createNodes(schema, "response").map(
|
|
233
|
+
// async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
234
|
+
// )
|
|
235
|
+
// )
|
|
236
|
+
// ).toMatchSnapshot();
|
|
237
|
+
// });
|
|
238
|
+
|
|
239
|
+
it("should correctly deep merge properties in allOf schemas", async () => {
|
|
240
|
+
const schema: SchemaObject = {
|
|
241
|
+
allOf: [
|
|
242
|
+
{
|
|
243
|
+
type: "object",
|
|
244
|
+
properties: {
|
|
245
|
+
deepProp: {
|
|
246
|
+
type: "object",
|
|
247
|
+
properties: {
|
|
248
|
+
innerProp1: {
|
|
249
|
+
type: "string",
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
},
|
|
43
253
|
},
|
|
44
|
-
|
|
45
|
-
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
type: "object",
|
|
257
|
+
properties: {
|
|
258
|
+
deepProp: {
|
|
259
|
+
type: "object",
|
|
260
|
+
properties: {
|
|
261
|
+
innerProp2: {
|
|
262
|
+
type: "number",
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
},
|
|
46
266
|
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
expect(
|
|
272
|
+
await Promise.all(
|
|
273
|
+
createNodes(schema, "response").map(
|
|
274
|
+
async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
275
|
+
)
|
|
55
276
|
)
|
|
56
|
-
)
|
|
57
|
-
)
|
|
277
|
+
).toMatchSnapshot();
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
// eslint-disable-next-line jest/no-commented-out-tests
|
|
281
|
+
// it("should handle discriminator with allOf schemas", async () => {
|
|
282
|
+
// const schema: SchemaObject = {
|
|
283
|
+
// allOf: [
|
|
284
|
+
// {
|
|
285
|
+
// type: "object",
|
|
286
|
+
// discriminator: {
|
|
287
|
+
// propertyName: "type",
|
|
288
|
+
// },
|
|
289
|
+
// properties: {
|
|
290
|
+
// type: {
|
|
291
|
+
// type: "string",
|
|
292
|
+
// },
|
|
293
|
+
// },
|
|
294
|
+
// },
|
|
295
|
+
// {
|
|
296
|
+
// type: "object",
|
|
297
|
+
// properties: {
|
|
298
|
+
// specificProp: {
|
|
299
|
+
// type: "string",
|
|
300
|
+
// },
|
|
301
|
+
// },
|
|
302
|
+
// },
|
|
303
|
+
// ],
|
|
304
|
+
// };
|
|
305
|
+
|
|
306
|
+
// expect(
|
|
307
|
+
// await Promise.all(
|
|
308
|
+
// createNodes(schema, "response").map(
|
|
309
|
+
// async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
310
|
+
// )
|
|
311
|
+
// )
|
|
312
|
+
// ).toMatchSnapshot();
|
|
313
|
+
// });
|
|
58
314
|
});
|
|
59
315
|
|
|
60
316
|
describe("additionalProperties", () => {
|