mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
OpenAPI: Always display collapsible for array items
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-openapi': patch
|
||||
---
|
||||
|
||||
Always display collapsible for array items
|
||||
@@ -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)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user