docusaurus-plugin-openapi-docs 0.0.0-beta.662 → 0.0.0-beta.664

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.
@@ -5,849 +5,18 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import clsx from "clsx";
9
-
10
- import { MediaTypeObject, SchemaObject } from "../openapi/types";
11
- import {
12
- createClosingArrayBracket,
13
- createOpeningArrayBracket,
14
- } from "./createArrayBracket";
8
+ import { MediaTypeObject } from "../openapi/types";
15
9
  import { createDescription } from "./createDescription";
16
10
  import { createDetails } from "./createDetails";
17
11
  import { createDetailsSummary } from "./createDetailsSummary";
12
+ import { createNodes } from "./createSchema";
18
13
  import {
19
14
  createExampleFromSchema,
20
15
  createResponseExample,
21
16
  createResponseExamples,
22
17
  } from "./createStatusCodes";
23
- import { getQualifierMessage, getSchemaName } from "./schema";
24
18
  import { create, guard } from "./utils";
25
19
 
26
- const jsonSchemaMergeAllOf = require("json-schema-merge-allof");
27
-
28
- /**
29
- * Returns a merged representation of allOf array of schemas.
30
- */
31
- export function mergeAllOf(allOf: SchemaObject[]) {
32
- const mergedSchemas = jsonSchemaMergeAllOf(allOf, {
33
- resolvers: {
34
- readOnly: function () {
35
- return true;
36
- },
37
- example: function () {
38
- return true;
39
- },
40
- "x-examples": function () {
41
- return true;
42
- },
43
- },
44
- ignoreAdditionalProperties: true,
45
- });
46
-
47
- const required = allOf.reduce((acc, cur) => {
48
- if (Array.isArray(cur.required)) {
49
- const next = [...acc, ...cur.required];
50
- return next;
51
- }
52
- return acc;
53
- }, [] as any);
54
-
55
- return { mergedSchemas, required };
56
- }
57
-
58
- /**
59
- * For handling nested anyOf/oneOf.
60
- */
61
- function createAnyOneOf(schema: SchemaObject): any {
62
- const type = schema.oneOf ? "oneOf" : "anyOf";
63
- return create("div", {
64
- children: [
65
- create("span", {
66
- className: "badge badge--info",
67
- children: type,
68
- }),
69
- create("SchemaTabs", {
70
- children: schema[type]!.map((anyOneSchema, index) => {
71
- const label = anyOneSchema.title
72
- ? anyOneSchema.title
73
- : `MOD${index + 1}`;
74
- const anyOneChildren = [];
75
-
76
- if (anyOneSchema.properties !== undefined) {
77
- anyOneChildren.push(createProperties(anyOneSchema));
78
- delete anyOneSchema.properties;
79
- }
80
-
81
- if (anyOneSchema.allOf !== undefined) {
82
- anyOneChildren.push(createNodes(anyOneSchema));
83
- delete anyOneSchema.allOf;
84
- }
85
-
86
- if (anyOneSchema.items !== undefined) {
87
- anyOneChildren.push(createItems(anyOneSchema));
88
- delete anyOneSchema.items;
89
- }
90
-
91
- if (
92
- anyOneSchema.type === "string" ||
93
- anyOneSchema.type === "number" ||
94
- anyOneSchema.type === "integer" ||
95
- anyOneSchema.type === "boolean"
96
- ) {
97
- anyOneChildren.push(createNodes(anyOneSchema));
98
- }
99
- if (anyOneChildren.length) {
100
- if (schema.type === "array") {
101
- return create("TabItem", {
102
- label: label,
103
- value: `${index}-item-properties`,
104
- children: [
105
- createOpeningArrayBracket(),
106
- anyOneChildren,
107
- createClosingArrayBracket(),
108
- ]
109
- .filter(Boolean)
110
- .flat(),
111
- });
112
- }
113
- return create("TabItem", {
114
- label: label,
115
- value: `${index}-item-properties`,
116
- children: anyOneChildren.filter(Boolean).flat(),
117
- });
118
- }
119
-
120
- return undefined;
121
- }),
122
- }),
123
- ],
124
- });
125
- }
126
-
127
- function createProperties(schema: SchemaObject) {
128
- const discriminator = schema.discriminator;
129
- return Object.entries(schema.properties!).map(([key, val]) => {
130
- return createEdges({
131
- name: key,
132
- schema: val,
133
- required: Array.isArray(schema.required)
134
- ? schema.required.includes(key)
135
- : false,
136
- discriminator,
137
- });
138
- });
139
- }
140
-
141
- function createAdditionalProperties(schema: SchemaObject) {
142
- // TODO?:
143
- // {
144
- // description: 'Integration configuration. See \n' +
145
- // '[Integration Configurations](https://prisma.pan.dev/api/cloud/api-integration-config/).\n',
146
- // example: { webhookUrl: 'https://hooks.slack.com/abcdef' },
147
- // externalDocs: { url: 'https://prisma.pan.dev/api/cloud/api-integration-config' },
148
- // type: 'object'
149
- // }
150
-
151
- // TODO?:
152
- // {
153
- // items: {
154
- // properties: {
155
- // aliasField: [Object],
156
- // displayName: [Object],
157
- // fieldName: [Object],
158
- // maxLength: [Object],
159
- // options: [Object],
160
- // redlockMapping: [Object],
161
- // required: [Object],
162
- // type: [Object],
163
- // typeaheadUri: [Object],
164
- // value: [Object]
165
- // },
166
- // type: 'object'
167
- // },
168
- // type: 'array'
169
- // }
170
- const additionalProperties = schema.additionalProperties;
171
- const type: string | unknown = additionalProperties?.type;
172
- // Handle free-form objects
173
- if (String(additionalProperties) === "true" && schema.type === "object") {
174
- return create("SchemaItem", {
175
- name: "property name*",
176
- required: false,
177
- schemaName: "any",
178
- qualifierMessage: getQualifierMessage(schema.additionalProperties),
179
- schema: schema,
180
- collapsible: false,
181
- discriminator: false,
182
- });
183
- }
184
- if (
185
- (type === "object" || type === "array") &&
186
- (additionalProperties?.properties ||
187
- additionalProperties?.items ||
188
- additionalProperties?.allOf ||
189
- additionalProperties?.additionalProperties ||
190
- additionalProperties?.oneOf ||
191
- additionalProperties?.anyOf)
192
- ) {
193
- const title = additionalProperties.title as string;
194
- const schemaName = getSchemaName(additionalProperties);
195
- const required = schema.required ?? false;
196
- return createDetailsNode(
197
- "property name*",
198
- title ?? schemaName,
199
- additionalProperties,
200
- required,
201
- schema.nullable
202
- );
203
- }
204
-
205
- if (
206
- (schema.additionalProperties?.type as string) === "string" ||
207
- (schema.additionalProperties?.type as string) === "object" ||
208
- (schema.additionalProperties?.type as string) === "boolean" ||
209
- (schema.additionalProperties?.type as string) === "integer" ||
210
- (schema.additionalProperties?.type as string) === "number"
211
- ) {
212
- const additionalProperties =
213
- schema.additionalProperties?.additionalProperties;
214
- if (additionalProperties !== undefined) {
215
- const type = schema.additionalProperties?.additionalProperties?.type;
216
- const schemaName = getSchemaName(
217
- schema.additionalProperties?.additionalProperties!
218
- );
219
- return create("SchemaItem", {
220
- name: "property name*",
221
- required: false,
222
- schemaName: schemaName ?? type,
223
- qualifierMessage:
224
- schema.additionalProperties ??
225
- getQualifierMessage(schema.additionalProperties),
226
- schema: schema,
227
- collapsible: false,
228
- discriminator: false,
229
- });
230
- }
231
- const schemaName = getSchemaName(schema.additionalProperties!);
232
- return create("SchemaItem", {
233
- name: "property name*",
234
- required: false,
235
- schemaName: schemaName,
236
- qualifierMessage: getQualifierMessage(schema),
237
- schema: schema.additionalProperties,
238
- collapsible: false,
239
- discriminator: false,
240
- });
241
- }
242
- return Object.entries(schema.additionalProperties!).map(([key, val]) =>
243
- createEdges({
244
- name: key,
245
- schema: val,
246
- required: Array.isArray(schema.required)
247
- ? schema.required.includes(key)
248
- : false,
249
- })
250
- );
251
- }
252
-
253
- // TODO: figure out how to handle array of objects
254
- function createItems(schema: SchemaObject) {
255
- if (schema.items?.properties !== undefined) {
256
- return [
257
- createOpeningArrayBracket(),
258
- createProperties(schema.items),
259
- createClosingArrayBracket(),
260
- ].flat();
261
- }
262
-
263
- if (schema.items?.additionalProperties !== undefined) {
264
- return [
265
- createOpeningArrayBracket(),
266
- createAdditionalProperties(schema.items),
267
- createClosingArrayBracket(),
268
- ].flat();
269
- }
270
-
271
- if (schema.items?.oneOf !== undefined || schema.items?.anyOf !== undefined) {
272
- return [
273
- createOpeningArrayBracket(),
274
- createAnyOneOf(schema.items!),
275
- createClosingArrayBracket(),
276
- ].flat();
277
- }
278
-
279
- if (schema.items?.allOf !== undefined) {
280
- // TODO: figure out if and how we should pass merged required array
281
- const {
282
- mergedSchemas,
283
- }: { mergedSchemas: SchemaObject; required: string[] } = mergeAllOf(
284
- schema.items?.allOf
285
- );
286
-
287
- // Handles combo anyOf/oneOf + properties
288
- if (
289
- (mergedSchemas.oneOf !== undefined ||
290
- mergedSchemas.anyOf !== undefined) &&
291
- mergedSchemas.properties
292
- ) {
293
- return [
294
- createOpeningArrayBracket(),
295
- createAnyOneOf(mergedSchemas),
296
- createProperties(mergedSchemas),
297
- createClosingArrayBracket(),
298
- ].flat();
299
- }
300
-
301
- // Handles only anyOf/oneOf
302
- if (
303
- mergedSchemas.oneOf !== undefined ||
304
- mergedSchemas.anyOf !== undefined
305
- ) {
306
- return [
307
- createOpeningArrayBracket(),
308
- createAnyOneOf(mergedSchemas),
309
- createClosingArrayBracket(),
310
- ].flat();
311
- }
312
-
313
- // Handles properties
314
- if (mergedSchemas.properties !== undefined) {
315
- return [
316
- createOpeningArrayBracket(),
317
- createProperties(mergedSchemas),
318
- createClosingArrayBracket(),
319
- ].flat();
320
- }
321
- }
322
-
323
- if (
324
- schema.items?.type === "string" ||
325
- schema.items?.type === "number" ||
326
- schema.items?.type === "integer" ||
327
- schema.items?.type === "boolean" ||
328
- schema.items?.type === "object"
329
- ) {
330
- return [
331
- createOpeningArrayBracket(),
332
- createNodes(schema.items),
333
- createClosingArrayBracket(),
334
- ].flat();
335
- }
336
-
337
- // TODO: clean this up or eliminate it?
338
- return [
339
- createOpeningArrayBracket(),
340
- Object.entries(schema.items!).map(([key, val]) =>
341
- createEdges({
342
- name: key,
343
- schema: val,
344
- required: Array.isArray(schema.required)
345
- ? schema.required.includes(key)
346
- : false,
347
- })
348
- ),
349
- createClosingArrayBracket(),
350
- ].flat();
351
- }
352
-
353
- /**
354
- * For handling discriminators that do not map to a same-level property
355
- */
356
- // function createDiscriminator(schema: SchemaObject) {
357
- // const discriminator = schema.discriminator;
358
- // const propertyName = discriminator?.propertyName;
359
- // const propertyType = "string"; // should always be string
360
- // const mapping: any = discriminator?.mapping;
361
-
362
- // // Explicit mapping is required since we can't support implicit
363
- // if (mapping === undefined) {
364
- // return undefined;
365
- // }
366
-
367
- // // Attempt to get the property description we want to display
368
- // // TODO: how to make it predictable when handling allOf
369
- // let propertyDescription;
370
- // const firstMappingSchema = mapping[Object.keys(mapping)[0]];
371
- // if (firstMappingSchema.properties !== undefined) {
372
- // propertyDescription =
373
- // firstMappingSchema.properties![propertyName!].description;
374
- // }
375
- // if (firstMappingSchema.allOf !== undefined) {
376
- // const { mergedSchemas }: { mergedSchemas: SchemaObject } = mergeAllOf(
377
- // firstMappingSchema.allOf
378
- // );
379
- // if (mergedSchemas.properties !== undefined) {
380
- // propertyDescription =
381
- // mergedSchemas.properties[propertyName!]?.description;
382
- // }
383
- // }
384
-
385
- // if (propertyDescription === undefined) {
386
- // if (
387
- // schema.properties !== undefined &&
388
- // schema.properties![propertyName!] !== undefined
389
- // ) {
390
- // propertyDescription = schema.properties![propertyName!].description;
391
- // }
392
- // }
393
-
394
- // return create("div", {
395
- // className: "openapi-discriminator__item",
396
- // children: create("div", {
397
- // children: [
398
- // create("strong", {
399
- // style: { paddingLeft: "1rem" },
400
- // children: propertyName,
401
- // }),
402
- // guard(propertyType, (name) =>
403
- // create("span", {
404
- // style: { opacity: "0.6" },
405
- // children: ` ${propertyType}`,
406
- // })
407
- // ),
408
- // guard(getQualifierMessage(schema.discriminator as any), (message) =>
409
- // create("div", {
410
- // style: {
411
- // paddingLeft: "1rem",
412
- // },
413
- // children: createDescription(message),
414
- // })
415
- // ),
416
- // guard(propertyDescription, (description) =>
417
- // create("div", {
418
- // style: {
419
- // paddingLeft: "1rem",
420
- // },
421
- // children: createDescription(description),
422
- // })
423
- // ),
424
- // create("DiscriminatorTabs", {
425
- // children: Object.keys(mapping!).map((key, index) => {
426
- // if (mapping[key].allOf !== undefined) {
427
- // const { mergedSchemas }: { mergedSchemas: SchemaObject } =
428
- // mergeAllOf(mapping[key].allOf);
429
- // // Cleanup duplicate property from mapping schema
430
- // delete mergedSchemas.properties![propertyName!];
431
- // mapping[key] = mergedSchemas;
432
- // }
433
-
434
- // if (mapping[key].properties !== undefined) {
435
- // // Cleanup duplicate property from mapping schema
436
- // delete mapping[key].properties![propertyName!];
437
- // }
438
-
439
- // const label = key;
440
- // return create("TabItem", {
441
- // label: label,
442
- // value: `${index}-item-discriminator`,
443
- // children: [
444
- // create("div", {
445
- // style: { marginLeft: "-4px" },
446
- // children: createNodes(mapping[key]),
447
- // }),
448
- // ],
449
- // });
450
- // }),
451
- // }),
452
- // ],
453
- // }),
454
- // });
455
- // }
456
-
457
- function createDetailsNode(
458
- name: string,
459
- schemaName: string,
460
- schema: SchemaObject,
461
- required: string[] | boolean,
462
- nullable: boolean | unknown
463
- ): any {
464
- return create("SchemaItem", {
465
- collapsible: true,
466
- className: "schemaItem",
467
- children: [
468
- createDetails({
469
- className: "openapi-markdown__details",
470
- children: [
471
- createDetailsSummary({
472
- children: [
473
- create("span", {
474
- className: "openapi-schema__container",
475
- children: [
476
- create("strong", {
477
- className: clsx("openapi-schema__property", {
478
- "openapi-schema__strikethrough": schema.deprecated,
479
- }),
480
- children: name,
481
- }),
482
- create("span", {
483
- className: "openapi-schema__name",
484
- children: ` ${schemaName}`,
485
- }),
486
- guard(
487
- (Array.isArray(required)
488
- ? required.includes(name)
489
- : required === true) ||
490
- schema.deprecated ||
491
- nullable,
492
- () => [
493
- create("span", {
494
- className: "openapi-schema__divider",
495
- }),
496
- ]
497
- ),
498
- guard(nullable, () => [
499
- create("span", {
500
- className: "openapi-schema__nullable",
501
- children: "nullable",
502
- }),
503
- ]),
504
- guard(
505
- Array.isArray(required)
506
- ? required.includes(name)
507
- : required === true,
508
- () => [
509
- create("span", {
510
- className: "openapi-schema__required",
511
- children: "required",
512
- }),
513
- ]
514
- ),
515
- guard(schema.deprecated, () => [
516
- create("span", {
517
- className: "openapi-schema__deprecated",
518
- children: "deprecated",
519
- }),
520
- ]),
521
- ],
522
- }),
523
- ],
524
- }),
525
- create("div", {
526
- style: { marginLeft: "1rem" },
527
- children: [
528
- guard(getQualifierMessage(schema), (message) =>
529
- create("div", {
530
- style: { marginTop: ".5rem", marginBottom: ".5rem" },
531
- children: createDescription(message),
532
- })
533
- ),
534
- guard(schema.description, (description) =>
535
- create("div", {
536
- style: { marginTop: ".5rem", marginBottom: ".5rem" },
537
- children: createDescription(description),
538
- })
539
- ),
540
- createNodes(schema),
541
- ],
542
- }),
543
- ],
544
- }),
545
- ],
546
- });
547
- }
548
-
549
- /**
550
- * For handling discriminators that map to a same-level property (like 'petType').
551
- * Note: These should only be encountered while iterating through properties.
552
- */
553
- function createPropertyDiscriminator(
554
- name: string,
555
- schemaName: string,
556
- schema: SchemaObject,
557
- discriminator: any,
558
- required: string[] | boolean
559
- ): any {
560
- if (schema === undefined) {
561
- return undefined;
562
- }
563
-
564
- if (discriminator.mapping === undefined) {
565
- return undefined;
566
- }
567
-
568
- return create("div", {
569
- className: "openapi-discriminator__item openapi-schema__list-item",
570
- children: create("div", {
571
- children: [
572
- create("span", {
573
- className: "openapi-schema__container",
574
- children: [
575
- create("strong", {
576
- className: "openapi-discriminator__name openapi-schema__property",
577
- children: name,
578
- }),
579
- guard(schemaName, (name) =>
580
- create("span", {
581
- className: "openapi-schema__name",
582
- children: ` ${schemaName}`,
583
- })
584
- ),
585
- guard(required, () => [
586
- create("span", {
587
- className: "openapi-schema__required",
588
- children: "required",
589
- }),
590
- ]),
591
- ],
592
- }),
593
- guard(getQualifierMessage(discriminator), (message) =>
594
- create("div", {
595
- style: {
596
- paddingLeft: "1rem",
597
- },
598
- children: createDescription(message),
599
- })
600
- ),
601
- guard(schema.description, (description) =>
602
- create("div", {
603
- style: {
604
- paddingLeft: "1rem",
605
- },
606
- children: createDescription(description),
607
- })
608
- ),
609
- create("DiscriminatorTabs", {
610
- className: "openapi-tabs__discriminator",
611
- children: Object.keys(discriminator?.mapping!).map((key, index) => {
612
- const label = key;
613
- return create("TabItem", {
614
- // className: "openapi-tabs__discriminator-item",
615
- label: label,
616
- value: `${index}-item-discriminator`,
617
- children: [createNodes(discriminator?.mapping[key])],
618
- });
619
- }),
620
- }),
621
- ],
622
- }),
623
- });
624
- }
625
-
626
- interface EdgeProps {
627
- name: string;
628
- schema: SchemaObject;
629
- required: string[] | boolean;
630
- discriminator?: any | unknown;
631
- }
632
-
633
- /**
634
- * Creates the edges or "leaves" of a schema tree. Edges can branch into sub-nodes with createDetails().
635
- */
636
- function createEdges({
637
- name,
638
- schema,
639
- required,
640
- discriminator,
641
- }: EdgeProps): any {
642
- const schemaName = getSchemaName(schema);
643
-
644
- if (discriminator !== undefined && discriminator.propertyName === name) {
645
- return createPropertyDiscriminator(
646
- name,
647
- "string",
648
- schema,
649
- discriminator,
650
- required
651
- );
652
- }
653
-
654
- if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
655
- return createDetailsNode(
656
- name,
657
- schemaName,
658
- schema,
659
- required,
660
- schema.nullable
661
- );
662
- }
663
-
664
- if (schema.allOf !== undefined) {
665
- const {
666
- mergedSchemas,
667
- required,
668
- }: { mergedSchemas: SchemaObject; required: string[] | boolean } =
669
- mergeAllOf(schema.allOf);
670
- const mergedSchemaName = getSchemaName(mergedSchemas);
671
-
672
- if (
673
- mergedSchemas.oneOf !== undefined ||
674
- mergedSchemas.anyOf !== undefined
675
- ) {
676
- return createDetailsNode(
677
- name,
678
- mergedSchemaName,
679
- mergedSchemas,
680
- required,
681
- schema.nullable
682
- );
683
- }
684
-
685
- if (mergedSchemas.properties !== undefined) {
686
- return createDetailsNode(
687
- name,
688
- mergedSchemaName,
689
- mergedSchemas,
690
- required,
691
- schema.nullable
692
- );
693
- }
694
-
695
- if (mergedSchemas.additionalProperties !== undefined) {
696
- return createDetailsNode(
697
- name,
698
- mergedSchemaName,
699
- mergedSchemas,
700
- required,
701
- schema.nullable
702
- );
703
- }
704
-
705
- // array of objects
706
- if (mergedSchemas.items?.properties !== undefined) {
707
- return createDetailsNode(
708
- name,
709
- mergedSchemaName,
710
- mergedSchemas,
711
- required,
712
- schema.nullable
713
- );
714
- }
715
-
716
- if (mergedSchemas.writeOnly && mergedSchemas.writeOnly === true) {
717
- return undefined;
718
- }
719
-
720
- return create("SchemaItem", {
721
- collapsible: false,
722
- name,
723
- required: Array.isArray(required) ? required.includes(name) : required,
724
- schemaName: schemaName,
725
- qualifierMessage: getQualifierMessage(schema),
726
- schema: mergedSchemas,
727
- });
728
- }
729
-
730
- if (schema.properties !== undefined) {
731
- return createDetailsNode(
732
- name,
733
- schemaName,
734
- schema,
735
- required,
736
- schema.nullable
737
- );
738
- }
739
-
740
- if (schema.additionalProperties !== undefined) {
741
- return createDetailsNode(
742
- name,
743
- schemaName,
744
- schema,
745
- required,
746
- schema.nullable
747
- );
748
- }
749
-
750
- // array of objects
751
- if (schema.items?.properties !== undefined) {
752
- return createDetailsNode(
753
- name,
754
- schemaName,
755
- schema,
756
- required,
757
- schema.nullable
758
- );
759
- }
760
-
761
- if (schema.items?.anyOf !== undefined || schema.items?.oneOf !== undefined) {
762
- return createDetailsNode(
763
- name,
764
- schemaName,
765
- schema,
766
- required,
767
- schema.nullable
768
- );
769
- }
770
-
771
- if (schema.writeOnly && schema.writeOnly === true) {
772
- return undefined;
773
- }
774
-
775
- // primitives and array of non-objects
776
- return create("SchemaItem", {
777
- collapsible: false,
778
- name,
779
- required: Array.isArray(required) ? required.includes(name) : required,
780
- schemaName: schemaName,
781
- qualifierMessage: getQualifierMessage(schema),
782
- schema: schema,
783
- });
784
- }
785
-
786
- /**
787
- * Creates a hierarchical level of a schema tree. Nodes produce edges that can branch into sub-nodes with edges, recursively.
788
- */
789
- function createNodes(schema: SchemaObject): any {
790
- const nodes = [];
791
- // if (schema.discriminator !== undefined) {
792
- // return createDiscriminator(schema);
793
- // }
794
-
795
- if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
796
- nodes.push(createAnyOneOf(schema));
797
- }
798
-
799
- if (schema.allOf !== undefined) {
800
- const { mergedSchemas } = mergeAllOf(schema.allOf);
801
- if (mergedSchemas.properties !== undefined) {
802
- nodes.push(createProperties(mergedSchemas));
803
- }
804
-
805
- if (mergedSchemas.items !== undefined) {
806
- nodes.push(createItems(mergedSchemas));
807
- }
808
- }
809
-
810
- if (schema.properties !== undefined) {
811
- nodes.push(createProperties(schema));
812
- }
813
-
814
- if (schema.additionalProperties !== undefined) {
815
- nodes.push(createAdditionalProperties(schema));
816
- }
817
-
818
- // TODO: figure out how to handle array of objects
819
- if (schema.items !== undefined) {
820
- nodes.push(createItems(schema));
821
- }
822
-
823
- if (nodes.length && nodes.length > 0) {
824
- return nodes.filter(Boolean).flat();
825
- }
826
-
827
- // primitive
828
- if (schema.type !== undefined) {
829
- return create("SchemaItem", {
830
- collapsible: false,
831
- name: schema.type,
832
- required: false,
833
- schemaName: schema.format,
834
- qualifierMessage: getQualifierMessage(schema),
835
- schema: schema,
836
- });
837
- }
838
-
839
- // Unknown node/schema type should return undefined
840
- // So far, haven't seen this hit in testing
841
- return create("SchemaItem", {
842
- collapsible: false,
843
- name: "any",
844
- required: false,
845
- schemaName: schema.format,
846
- qualifierMessage: getQualifierMessage(schema),
847
- schema: schema,
848
- });
849
- }
850
-
851
20
  interface Props {
852
21
  style?: any;
853
22
  title: string;