Skip to content

Commit

Permalink
Default collapse first level
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-lee committed Aug 26, 2024
1 parent b0e2858 commit 5c9c6c0
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions packages/zudoku/src/lib/plugins/openapi/schema/SchemaView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const SchemaView = ({
}

const renderSchema = (schema: SchemaObject, level: number) => {
if (schema.oneOf || schema.allOf || schema.anyOf) {
if (hasLogicalGroupings(schema)) {
return <SchemaLogicalGroup schema={schema} level={level} />;
}

Expand Down Expand Up @@ -55,10 +55,7 @@ export const SchemaView = ({
)}
</Card>
);
} else if (
itemsSchema.type === "object" ||
hasLogicalGroupings(itemsSchema)
) {
} else if (itemsSchema.type === "object") {
return (
<Card className="flex flex-col gap-2 bg-border/30 p-4">
<span className="text-sm text-muted-foreground">object[]</span>
Expand Down Expand Up @@ -100,9 +97,6 @@ export const SchemaView = ({
},
);

const isTopLevelSingleItem =
level === 0 && Object.keys(groupedProperties).length === 1;

const groupNames = ["required", "optional", "deprecated"] as const;

return (
Expand All @@ -118,8 +112,7 @@ export const SchemaView = ({
schema={schema}
group={group}
level={level}
defaultOpen={isTopLevelSingleItem || defaultOpen}
showCollapseButton={!isTopLevelSingleItem}
defaultOpen={defaultOpen}
/>
))}
</ul>
Expand Down

0 comments on commit 5c9c6c0

Please sign in to comment.