Skip to content

Commit

Permalink
Merge pull request #138 from mittwald/bugfix/schema-array-items
Browse files Browse the repository at this point in the history
Fix display of array items in Schema component
  • Loading branch information
martin-helmich authored Jul 2, 2024
2 parents d706cb6 + 69c5ce2 commit 2e6b7d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/openapi/OperationInputValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function ArrayValue({ schema }: { schema: OpenAPIV3.SchemaObject }) {
<span className={styles.parameterAlternative}>Array[</span>
</div>
<div className={styles.parameterListBody}>{body}</div>
<Schema schema={schema} />
<PropertyValue name="*" schema={schema} required={false} />
<div className={styles.parameterListHeader}>
<span className={styles.parameterAlternative}>]</span>
</div>
Expand All @@ -58,6 +58,8 @@ export function PropertyValue({
body = <Markdown>{schema.description}</Markdown>;
}

const hasSubSchema = schema.properties || schema.additionalProperties || schema.items;

return (
<li key={name}>
<div className={styles.parameterListHeader}>
Expand All @@ -67,7 +69,7 @@ export function PropertyValue({
{requiredOrOptional}
</div>
<div className={styles.parameterListBody}>{body}</div>
<Schema schema={schema} />
{hasSubSchema && <Schema schema={schema} />}
</li>
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/openapi/Schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,6 @@ export default function Schema({ schema }: Props) {
if (schema.type === "array") {
return <ArraySchema schema={schema} />;
}

return <PropertyValue name="*" schema={schema} required={false} />;
}

0 comments on commit 2e6b7d3

Please sign in to comment.