Skip to content

Commit

Permalink
Fix render of one of when alternatives are primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyPesse committed Jul 14, 2024
1 parent 68dc2de commit 98d5f9c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/react-openapi/src/OpenAPISchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ export function OpenAPIRootSchema(props: {

/**
* Render a tab for an alternative schema.
* It renders directly the properties if relevant;
* for primitives, it renders the schema itself.
*/
function OpenAPISchemaAlternative(props: {
schema: OpenAPIV3.SchemaObject;
Expand All @@ -190,12 +192,13 @@ function OpenAPISchemaAlternative(props: {
}) {
const { schema, circularRefs, context } = props;
const id = useId();
const subProperties = getSchemaProperties(schema);

return (
<OpenAPISchemaProperties
id={id}
properties={getSchemaProperties(schema) ?? []}
circularRefs={new Map(circularRefs).set(schema, id)}
properties={subProperties ?? [{ schema }]}
circularRefs={subProperties ? new Map(circularRefs).set(schema, id) : circularRefs}
context={context}
/>
);
Expand Down

0 comments on commit 98d5f9c

Please sign in to comment.