Skip to content

Commit dc88650

Browse files
authored
fix: render property titles (#83)
1 parent a99efe3 commit dc88650

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

.changeset/chatty-bottles-allow.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'starlight-openapi': patch
3+
---
4+
5+
Ensures property titles are rendered when provided in a schema.

packages/starlight-openapi/components/schema/SchemaObject.astro

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const hasMany = schemaObjects !== undefined
3939
<Astro.self negated schemaObject={schemaObject.not} />
4040
) : (
4141
<>
42+
{schemaObject.title && <em>{schemaObject.title}</em>}
4243
<Md text={schemaObject.description} />
4344
<ExternalDocs docs={schemaObject.externalDocs} />
4445
{isSchemaObjectObject(schemaObject) ? (

packages/starlight-openapi/tests/requestBody.test.ts

+9
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,12 @@ test('overrides the global `consumes` property for a v2.0 schema', async ({ docP
211211
await requestBody.getByRole('combobox').selectOption('application/json')
212212
await requestBody.getByRole('combobox').selectOption('application/xml')
213213
})
214+
215+
test('displays property titles when provided', async ({ docPage }) => {
216+
await docPage.goto('/v3/animals/operations/addanimal/')
217+
218+
const requestBody = docPage.getRequestBody()
219+
220+
await expect(requestBody.getByText('Name of the animal')).toBeVisible()
221+
await expect(requestBody.getByText('A friendly name for the animal.')).toBeVisible()
222+
})

schemas/v3.0/animals.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ components:
490490
format: int64
491491
name:
492492
type: string
493+
title: Name of the animal
494+
description: A friendly name for the animal.
493495
tag:
494496
type: string
495497
example:

0 commit comments

Comments
 (0)