Skip to content

fix: render discriminator selector when variants omit the discriminator property#2802

Open
tabilzad wants to merge 1 commit into
Redocly:mainfrom
tabilzad:fix/discriminator-selector-without-property
Open

fix: render discriminator selector when variants omit the discriminator property#2802
tabilzad wants to merge 1 commit into
Redocly:mainfrom
tabilzad:fix/discriminator-selector-without-property

Conversation

@tabilzad

Copy link
Copy Markdown

What/Why/How?

When a schema uses oneOf + discriminator and the variant schemas don't declare the discriminator property themselves (i.e. no allOf inheritance from a parent that declares it), the variant selector silently disappears and only the first variant is rendered.

The dropdown was only mounted as a side effect of a field row whose name matched discriminator.propertyName. When no such field exists on the active variant, nothing rendered the selector. ObjectSchema now renders the DiscriminatorDropdown standalone in that case, so the variants stay switchable. Specs that declare the discriminator property keep the existing inline behaviour, so the common render path is unchanged.

Reference

Closes #2571. Related: #2562.

Tests

Added a fixture and unit tests for the no-property case, plus a regression guard for the allOf-inheritance case. Full unit suite passes (npm run unit).

Check yourself

  • Code is linted
  • Tested
  • All new/updated code is covered with tests

…or property

When a schema uses oneOf + discriminator but the variant schemas don't declare the discriminator property themselves (no allOf inheritance from a parent that does), the selector was mounted only as a side effect of a field row whose name matched the discriminator property. With no such field, nothing rendered the selector, so only the first variant was shown. ObjectSchema now renders the DiscriminatorDropdown standalone when no matching field exists. Specs that declare the property keep the existing inline behaviour, so the common path is unchanged.
@tabilzad tabilzad requested a review from a team as a code owner June 18, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation Failing to Render oneOf Request Schema

1 participant