Describe the bug
When a request/response schema uses oneOf (with or without a discriminator), the description of each individual branch/variant schema is silently dropped by the Schema theme component (@theme/Schema). Only the branch's properties table is rendered — the branch's own description never appears, even though it is present in the OpenAPI document and correctly preserved all the way through to the generated schema JSON used by RequestSchema/ResponseSchema.
Expected behavior
For a schema like:
Cat:
type: object
description: A domesticated feline that likes to nap and knock things off tables.
properties:
petType:
type: string
enum: [cat]
huntingSkill:
type: string
referenced from a oneOf (directly, or via a discriminator.mapping), the rendered page should show the "A domesticated feline that likes to nap and knock things off tables." text for that branch/tab, in addition to its property list.
Current behavior
The branch's description is not rendered anywhere. Only the property list shows up under each oneOf/discriminator tab — the description text is missing entirely, with no error or warning.
Possible solution
Root cause is in docusaurus-theme-openapi-docs's theme/Schema/index.tsx:
- In
AnyOneOf (used for oneOf/anyOf without a discriminator), the branch with properties is rendered via <Properties schema={anyOneSchema} .../> directly — anyOneSchema.description is never read or rendered anywhere in that code path.
- In
PropertyDiscriminator (used for oneOf + discriminator), each discriminator.mapping[key] is rendered via <SchemaNode schema={discriminator.mapping[key]} .../> inside its TabItem — again, discriminator.mapping[key].description is never read.
Both are missing the same pattern already used elsewhere in the same file (e.g. SchemaNodeDetails, and PropertyDiscriminator's own top-level schema.description): wrap the branch's description in the existing MarkdownWrapper helper before rendering its properties/children.
Minimal fix (both in docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx):
// AnyOneOf — inside the "object with properties" branch:
{(anyOneSchema.type === "object" || !anyOneSchema.type) &&
anyOneSchema.properties && (
<>
{anyOneSchema.description && (
<div style={{ marginLeft: "1rem" }}>
<MarkdownWrapper text={anyOneSchema.description} />
</div>
)}
<Properties schema={anyOneSchema} schemaType={schemaType} schemaPath={childSchemaPath} />
</>
)}
// PropertyDiscriminator — inside the DiscriminatorTabs TabItem loop:
<TabItem key={index} label={key} value={`${index}-item-discriminator`}>
{discriminator.mapping[key].description && (
<div style={{ marginLeft: "1rem" }}>
<MarkdownWrapper text={discriminator.mapping[key].description} />
</div>
)}
<SchemaNode schema={discriminator.mapping[key]} schemaType={schemaType} />
</TabItem>
Steps to reproduce
- Define an OpenAPI schema with a
oneOf (with a discriminator) whose branches each have their own description, e.g.:
Pet:
oneOf:
- $ref: "#/components/schemas/Cat"
- $ref: "#/components/schemas/Dog"
discriminator:
propertyName: petType
mapping:
cat: "#/components/schemas/Cat"
dog: "#/components/schemas/Dog"
Cat:
type: object
description: A domesticated feline that likes to nap and knock things off tables.
properties:
petType:
type: string
enum: [cat]
huntingSkill:
type: string
Dog:
type: object
description: A domesticated canine known for loyalty and fetching things.
properties:
petType:
type: string
enum: [dog]
breed:
type: string
- Run
docusaurus gen-api-docs to generate the API docs for the endpoint using this schema.
- Open the generated page in the browser and expand the request body schema.
- Select the "cat" tab under the discriminator selector.
- Observe that only the property list is shown — the schema's own description ("A domesticated feline that likes to nap and knock things off tables.") never renders.
Screenshots
Context
We generate API reference docs from an OpenAPI spec with several polymorphic (oneOf + discriminator) request/response schemas. Each variant has its own human-written description explaining what that variant represents, which is important context for API consumers choosing between variants. Because the description was silently dropped, readers only saw a bare property list per variant with no explanation of what the variant represents — this went unnoticed for a while since there's no error, just missing content.
Your Environment
- Version used:
docusaurus-theme-openapi-docs and docusaurus-plugin-openapi-docs ^5.1.0
- Environment name and version: Node.js v22.16.0,
@docusaurus/core ^3.10.0, React ^19.2.7
- Operating System and version (desktop or mobile): macOS 15, desktop (Chrome)
- Link to your project: internal/private repository (not publicly linkable)
Describe the bug
When a request/response schema uses
oneOf(with or without adiscriminator), thedescriptionof each individual branch/variant schema is silently dropped by theSchematheme component (@theme/Schema). Only the branch'spropertiestable is rendered — the branch's owndescriptionnever appears, even though it is present in the OpenAPI document and correctly preserved all the way through to the generated schema JSON used byRequestSchema/ResponseSchema.Expected behavior
For a schema like:
referenced from a
oneOf(directly, or via adiscriminator.mapping), the rendered page should show the "A domesticated feline that likes to nap and knock things off tables." text for that branch/tab, in addition to its property list.Current behavior
The branch's
descriptionis not rendered anywhere. Only the property list shows up under eachoneOf/discriminator tab — the description text is missing entirely, with no error or warning.Possible solution
Root cause is in
docusaurus-theme-openapi-docs'stheme/Schema/index.tsx:AnyOneOf(used foroneOf/anyOfwithout a discriminator), the branch withpropertiesis rendered via<Properties schema={anyOneSchema} .../>directly —anyOneSchema.descriptionis never read or rendered anywhere in that code path.PropertyDiscriminator(used foroneOf+discriminator), eachdiscriminator.mapping[key]is rendered via<SchemaNode schema={discriminator.mapping[key]} .../>inside itsTabItem— again,discriminator.mapping[key].descriptionis never read.Both are missing the same pattern already used elsewhere in the same file (e.g.
SchemaNodeDetails, andPropertyDiscriminator's own top-levelschema.description): wrap the branch'sdescriptionin the existingMarkdownWrapperhelper before rendering its properties/children.Minimal fix (both in
docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx):Steps to reproduce
oneOf(with adiscriminator) whose branches each have their owndescription, e.g.:docusaurus gen-api-docsto generate the API docs for the endpoint using this schema.Screenshots
Context
We generate API reference docs from an OpenAPI spec with several polymorphic (
oneOf+discriminator) request/response schemas. Each variant has its own human-written description explaining what that variant represents, which is important context for API consumers choosing between variants. Because the description was silently dropped, readers only saw a bare property list per variant with no explanation of what the variant represents — this went unnoticed for a while since there's no error, just missing content.Your Environment
docusaurus-theme-openapi-docsanddocusaurus-plugin-openapi-docs^5.1.0@docusaurus/core^3.10.0, React^19.2.7