OpenAPI: Always display collapsible for array items

This commit is contained in:
Fuma Nama
2025-07-04 21:46:24 +08:00
parent 80e0654394
commit 8f69e33b14
3 changed files with 21 additions and 23 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-openapi': patch
---
Always display collapsible for array items
+15 -19
View File
@@ -267,25 +267,23 @@ export function Schema({
if (schema.type === 'array') {
const items = schema.items;
if (!items || !isComplexType(items) || ctx.stack.has(items)) return;
if (!items || typeof items === 'boolean' || ctx.stack.has(items)) return;
return (
<>
{items.description && (
<Markdown text={'Item: ' + items.description} />
<renderer.ObjectCollapsible name="Array Item">
<div className="text-sm border-t p-3 border-x prose-no-margin bg-fd-card last:rounded-b-xl first:rounded-tr-xl last:border-b empty:hidden">
<Markdown text={items.description ?? 'No Description'} />
{propertyInfo(items)}
</div>
{propertyBody(
items,
(child, ctx) => primitiveBody(child, ctx, false, true),
{
...ctx,
stack: ctx.stack.next(schema),
},
)}
<renderer.ObjectCollapsible name="Array Item">
{propertyBody(
items,
(child, ctx) => primitiveBody(child, ctx, false, true),
{
...ctx,
stack: ctx.stack.next(schema),
},
)}
</renderer.ObjectCollapsible>
</>
</renderer.ObjectCollapsible>
);
}
}
@@ -388,9 +386,7 @@ function isComplexType(
return (
schema.type === 'object' ||
(schema.type === 'array' &&
schema.items != null &&
isComplexType(schema.items))
(schema.type === 'array' && schema.items != null)
);
}
@@ -9,10 +9,7 @@ export function Accordions(props: ComponentProps<typeof Primitive.Root>) {
return (
<Primitive.Root
{...props}
className={cn(
'divide-y divide-fd-border overflow-hidden',
props.className,
)}
className={cn('divide-y divide-fd-border', props.className)}
/>
);
}