diff --git a/.changeset/silly-gorillas-teach.md b/.changeset/silly-gorillas-teach.md
new file mode 100644
index 000000000..b5691ce68
--- /dev/null
+++ b/.changeset/silly-gorillas-teach.md
@@ -0,0 +1,5 @@
+---
+'@gitbook/react-openapi': patch
+---
+
+Handle OpenAPI alternatives from schema.items
diff --git a/packages/react-openapi/src/OpenAPISchema.tsx b/packages/react-openapi/src/OpenAPISchema.tsx
index 7841b1c0f..e9f8c6707 100644
--- a/packages/react-openapi/src/OpenAPISchema.tsx
+++ b/packages/react-openapi/src/OpenAPISchema.tsx
@@ -80,11 +80,10 @@ function OpenAPISchemaProperty(
context={context}
/>
{index < alternatives.length - 1 ? (
-
- {(schema.anyOf || schema.oneOf) &&
- tString(context.translation, 'or')}
- {schema.allOf && tString(context.translation, 'and')}
-
+
) : null}
))}
@@ -256,6 +255,28 @@ function OpenAPISchemaAlternative(props: {
);
}
+function OpenAPISchemaAlternativeSeparator(props: {
+ schema: OpenAPIV3.SchemaObject;
+ context: OpenAPIClientContext;
+}) {
+ const { schema, context } = props;
+
+ const anyOf = schema.anyOf || schema.items?.anyOf;
+ const oneOf = schema.oneOf || schema.items?.oneOf;
+ const allOf = schema.allOf || schema.items?.allOf;
+
+ if (!anyOf && !oneOf && !allOf) {
+ return null;
+ }
+
+ return (
+
+ {(anyOf || oneOf) && tString(context.translation, 'or')}
+ {allOf && tString(context.translation, 'and')}
+
+ );
+}
+
/**
* Render a circular reference to a schema.
*/
@@ -457,6 +478,14 @@ export function getSchemaAlternatives(
schema: OpenAPIV3.SchemaObject,
ancestors: Set = new Set()
): OpenAPIV3.SchemaObject[] | null {
+ // Search for alternatives in the items property if it exists
+ if (
+ schema.items &&
+ ('oneOf' in schema.items || 'allOf' in schema.items || 'anyOf' in schema.items)
+ ) {
+ return getSchemaAlternatives(schema.items, ancestors);
+ }
+
const alternatives:
| [AlternativeType, (OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject)[]]
| null = (() => {