fumadocs-openapi 5.3.0 → 5.3.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/dist/server/index.js +51 -45
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -468,6 +468,38 @@ function heading(depth, child, ctx) {
|
|
|
468
468
|
}, id);
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
+
/**
|
|
472
|
+
* Combine multiple object schemas into one
|
|
473
|
+
*/ function combineSchema(schema) {
|
|
474
|
+
const result = {
|
|
475
|
+
type: 'object'
|
|
476
|
+
};
|
|
477
|
+
function add(s) {
|
|
478
|
+
if (s.properties) {
|
|
479
|
+
var _result;
|
|
480
|
+
(_result = result).properties ?? (_result.properties = {});
|
|
481
|
+
Object.assign(result.properties, s.properties);
|
|
482
|
+
}
|
|
483
|
+
if (s.additionalProperties === true) {
|
|
484
|
+
result.additionalProperties = true;
|
|
485
|
+
} else if (s.additionalProperties && typeof result.additionalProperties !== 'boolean') {
|
|
486
|
+
var _result1;
|
|
487
|
+
(_result1 = result).additionalProperties ?? (_result1.additionalProperties = {});
|
|
488
|
+
Object.assign(result.additionalProperties, s.additionalProperties);
|
|
489
|
+
}
|
|
490
|
+
if (s.required) {
|
|
491
|
+
var _result2;
|
|
492
|
+
(_result2 = result).required ?? (_result2.required = []);
|
|
493
|
+
result.required.push(...s.required);
|
|
494
|
+
}
|
|
495
|
+
if (s.allOf) {
|
|
496
|
+
noRef(s.allOf).forEach(add);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
schema.forEach(add);
|
|
500
|
+
return result;
|
|
501
|
+
}
|
|
502
|
+
|
|
471
503
|
const keys = {
|
|
472
504
|
default: 'Default',
|
|
473
505
|
minimum: 'Minimum',
|
|
@@ -521,6 +553,13 @@ function Schema({ name, schema, ctx }) {
|
|
|
521
553
|
}
|
|
522
554
|
return child;
|
|
523
555
|
}
|
|
556
|
+
if (schema.allOf && parseObject) {
|
|
557
|
+
return /*#__PURE__*/ jsx(Schema, {
|
|
558
|
+
name: name,
|
|
559
|
+
schema: combineSchema(noRef(schema.allOf)),
|
|
560
|
+
ctx: ctx
|
|
561
|
+
});
|
|
562
|
+
}
|
|
524
563
|
if (schema.description) child.push(/*#__PURE__*/ jsx(Markdown, {
|
|
525
564
|
text: schema.description
|
|
526
565
|
}, "description"));
|
|
@@ -540,17 +579,22 @@ function Schema({ name, schema, ctx }) {
|
|
|
540
579
|
});
|
|
541
580
|
}
|
|
542
581
|
if (fields.length > 0) child.push(/*#__PURE__*/ jsx("p", {
|
|
543
|
-
children: fields.map((field)=>/*#__PURE__*/ jsxs(
|
|
582
|
+
children: fields.map((field, i)=>/*#__PURE__*/ jsxs(Fragment, {
|
|
544
583
|
children: [
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
584
|
+
/*#__PURE__*/ jsxs("span", {
|
|
585
|
+
children: [
|
|
586
|
+
field.key,
|
|
587
|
+
": ",
|
|
588
|
+
/*#__PURE__*/ jsx("code", {
|
|
589
|
+
children: field.value
|
|
590
|
+
})
|
|
591
|
+
]
|
|
592
|
+
}),
|
|
593
|
+
i !== fields.length - 1 ? /*#__PURE__*/ jsx("br", {}) : null
|
|
550
594
|
]
|
|
551
595
|
}, field.key))
|
|
552
596
|
}, "fields"));
|
|
553
|
-
if (isObject(schema) && !parseObject) {
|
|
597
|
+
if ((isObject(schema) || schema.allOf) && !parseObject) {
|
|
554
598
|
child.push(/*#__PURE__*/ jsx(renderer.ObjectCollapsible, {
|
|
555
599
|
name: "Attributes",
|
|
556
600
|
children: /*#__PURE__*/ jsx(Schema, {
|
|
@@ -563,19 +607,6 @@ function Schema({ name, schema, ctx }) {
|
|
|
563
607
|
}
|
|
564
608
|
})
|
|
565
609
|
}, "attributes"));
|
|
566
|
-
} else if (schema.allOf) {
|
|
567
|
-
child.push(/*#__PURE__*/ jsx(renderer.ObjectCollapsible, {
|
|
568
|
-
name: name,
|
|
569
|
-
children: /*#__PURE__*/ jsx(Schema, {
|
|
570
|
-
name: name,
|
|
571
|
-
schema: combineSchema(noRef(schema.allOf)),
|
|
572
|
-
ctx: {
|
|
573
|
-
...ctx,
|
|
574
|
-
parseObject: true,
|
|
575
|
-
required: false
|
|
576
|
-
}
|
|
577
|
-
})
|
|
578
|
-
}, "attributes"));
|
|
579
610
|
} else {
|
|
580
611
|
const mentionedObjectTypes = [
|
|
581
612
|
...schema.anyOf ?? schema.oneOf ?? [],
|
|
@@ -614,31 +645,6 @@ function Schema({ name, schema, ctx }) {
|
|
|
614
645
|
children: child
|
|
615
646
|
});
|
|
616
647
|
}
|
|
617
|
-
/**
|
|
618
|
-
* Combine multiple object schemas into one
|
|
619
|
-
*/ function combineSchema(schema) {
|
|
620
|
-
const result = {
|
|
621
|
-
type: 'object'
|
|
622
|
-
};
|
|
623
|
-
function add(s) {
|
|
624
|
-
var _result, _result1;
|
|
625
|
-
(_result = result).properties ?? (_result.properties = {});
|
|
626
|
-
if (s.properties) {
|
|
627
|
-
Object.assign(result.properties, s.properties);
|
|
628
|
-
}
|
|
629
|
-
(_result1 = result).additionalProperties ?? (_result1.additionalProperties = {});
|
|
630
|
-
if (s.additionalProperties === true) {
|
|
631
|
-
result.additionalProperties = true;
|
|
632
|
-
} else if (s.additionalProperties && typeof result.additionalProperties !== 'boolean') {
|
|
633
|
-
Object.assign(result.additionalProperties, s.additionalProperties);
|
|
634
|
-
}
|
|
635
|
-
if (s.allOf) {
|
|
636
|
-
add(combineSchema(noRef(s.allOf)));
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
schema.forEach(add);
|
|
640
|
-
return result;
|
|
641
|
-
}
|
|
642
648
|
/**
|
|
643
649
|
* Check if the schema needs another collapsible to explain
|
|
644
650
|
*/ function isComplexType(schema) {
|