diff --git a/packages/starlight-openapi/components/schema/SchemaObject.astro b/packages/starlight-openapi/components/schema/SchemaObject.astro
index 5278429..bb401d0 100644
--- a/packages/starlight-openapi/components/schema/SchemaObject.astro
+++ b/packages/starlight-openapi/components/schema/SchemaObject.astro
@@ -43,7 +43,7 @@ const isNegated = schemaObject.not !== undefined
{isSchemaObjectObject(schemaObject) ? (
) : isSchemaObjectAllOf(schemaObject) ? (
-
+
) : (
)}
diff --git a/packages/starlight-openapi/components/schema/SchemaObjectAllOf.astro b/packages/starlight-openapi/components/schema/SchemaObjectAllOf.astro
index 0e393fa..dcd516a 100644
--- a/packages/starlight-openapi/components/schema/SchemaObjectAllOf.astro
+++ b/packages/starlight-openapi/components/schema/SchemaObjectAllOf.astro
@@ -2,6 +2,7 @@
import {
getNullable,
getProperties,
+ getSchemaObjects,
isSchemaObject,
isSchemaObjectObject,
type SchemaObject,
@@ -9,31 +10,47 @@ import {
import Items from '../Items.astro'
import SchemaObjectObjectProperties from './SchemaObjectObjectProperties.astro'
+import SchemaObjects from './SchemaObjects.astro'
interface Props {
+ nested: boolean
parents?: SchemaObject[]
schemaObject: SchemaObject
}
-const { schemaObject, parents = [] } = Astro.props
+const { nested, schemaObject, parents = [] } = Astro.props
---
{
schemaObject.allOf &&
- schemaObject.allOf.map((allOfSchemaObject) =>
- isSchemaObjectObject(schemaObject) && isSchemaObject(allOfSchemaObject) ? (
-
- ) : isSchemaObject(allOfSchemaObject) ? (
+ schemaObject.allOf.map((allOfSchemaObject) => {
+ if (!isSchemaObject(allOfSchemaObject)) return null
+ const schemaObjects = getSchemaObjects(allOfSchemaObject)
+ if (schemaObjects !== undefined) {
+ return (
+
+ )
+ } else if (isSchemaObjectObject(schemaObject)) {
+ return (
+
+ )
+ }
+ return (
- ) : null,
- )
+ )
+ })
}
diff --git a/packages/starlight-openapi/components/schema/SchemaObjectObject.astro b/packages/starlight-openapi/components/schema/SchemaObjectObject.astro
index 1fc7018..c3d922f 100644
--- a/packages/starlight-openapi/components/schema/SchemaObjectObject.astro
+++ b/packages/starlight-openapi/components/schema/SchemaObjectObject.astro
@@ -29,7 +29,7 @@ const properties = getProperties(schemaObject)
]}
/>
-
+
{
schemaObject.additionalProperties && (
diff --git a/packages/starlight-openapi/tests/requestBody.test.ts b/packages/starlight-openapi/tests/requestBody.test.ts
index 31d4655..29f10fa 100644
--- a/packages/starlight-openapi/tests/requestBody.test.ts
+++ b/packages/starlight-openapi/tests/requestBody.test.ts
@@ -82,6 +82,20 @@ test('supports schema object `allOf` property for non-objects', async ({ docPage
await expect(typeParameter.getByText('Allowed values: berkshire tamworth')).toBeVisible()
})
+test('supports schema object `allOf` property with nested schema objects like `anyOf`', async ({ docPage }) => {
+ await docPage.goto('/v3/animals/operations/okapi/')
+
+ const requestBody = docPage.getRequestBody()
+
+ await expect(requestBody.getByText('Any of:')).toBeVisible()
+
+ await expect(requestBody.getByRole('tab')).toContainText(['basic details', 'advanced details'])
+
+ await requestBody.getByRole('tab', { name: 'advanced details' }).click()
+
+ await expect(requestBody.getByText('age')).toBeVisible()
+})
+
test('supports schema object `oneOf` property', async ({ docPage }) => {
await docPage.goto('/v2/animals/operations/addbird/')
diff --git a/schemas/v3.0/animals.yaml b/schemas/v3.0/animals.yaml
index 4a0f136..986fd7a 100644
--- a/schemas/v3.0/animals.yaml
+++ b/schemas/v3.0/animals.yaml
@@ -336,6 +336,53 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
+ /okapi:
+ post:
+ summary: Creates a new okapi
+ tags:
+ - animals
+ requestBody:
+ description: Okapi to add
+ required: true
+ content:
+ application/json:
+ schema:
+ allOf:
+ - type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ - type: object
+ properties:
+ name:
+ type: string
+ - anyOf:
+ - type: object
+ title: 'basic details'
+ properties:
+ color:
+ type: string
+ - type: object
+ title: 'advanced details'
+ properties:
+ color:
+ type: string
+ age:
+ type: integer
+ responses:
+ '200':
+ description: animal response
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Animal'
+ default:
+ description: unexpected error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Error'
webhooks:
newAnimal:
post: