Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render property titles #83

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chatty-bottles-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'starlight-openapi': patch
---

Ensures property titles are rendered when provided in a schema.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const hasMany = schemaObjects !== undefined
<Astro.self negated schemaObject={schemaObject.not} />
) : (
<>
{schemaObject.title && <em>{schemaObject.title}</em>}
<Md text={schemaObject.description} />
<ExternalDocs docs={schemaObject.externalDocs} />
{isSchemaObjectObject(schemaObject) ? (
Expand Down
9 changes: 9 additions & 0 deletions packages/starlight-openapi/tests/requestBody.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,12 @@ test('overrides the global `consumes` property for a v2.0 schema', async ({ docP
await requestBody.getByRole('combobox').selectOption('application/json')
await requestBody.getByRole('combobox').selectOption('application/xml')
})

test('displays property titles when provided', async ({ docPage }) => {
await docPage.goto('/v3/animals/operations/addanimal/')

const requestBody = docPage.getRequestBody()

await expect(requestBody.getByText('Name of the animal')).toBeVisible()
await expect(requestBody.getByText('A friendly name for the animal.')).toBeVisible()
})
2 changes: 2 additions & 0 deletions schemas/v3.0/animals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ components:
format: int64
name:
type: string
title: Name of the animal
description: A friendly name for the animal.
tag:
type: string
example:
Expand Down