Skip to content

Commit 98d5f9c

Browse files
committed
Fix render of one of when alternatives are primitives
1 parent 68dc2de commit 98d5f9c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/react-openapi/src/OpenAPISchema.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ export function OpenAPIRootSchema(props: {
182182

183183
/**
184184
* Render a tab for an alternative schema.
185+
* It renders directly the properties if relevant;
186+
* for primitives, it renders the schema itself.
185187
*/
186188
function OpenAPISchemaAlternative(props: {
187189
schema: OpenAPIV3.SchemaObject;
@@ -190,12 +192,13 @@ function OpenAPISchemaAlternative(props: {
190192
}) {
191193
const { schema, circularRefs, context } = props;
192194
const id = useId();
195+
const subProperties = getSchemaProperties(schema);
193196

194197
return (
195198
<OpenAPISchemaProperties
196199
id={id}
197-
properties={getSchemaProperties(schema) ?? []}
198-
circularRefs={new Map(circularRefs).set(schema, id)}
200+
properties={subProperties ?? [{ schema }]}
201+
circularRefs={subProperties ? new Map(circularRefs).set(schema, id) : circularRefs}
199202
context={context}
200203
/>
201204
);

0 commit comments

Comments
 (0)