Skip to content

List the discriminator property first in API union variants - #4490

Merged
akira28 merged 2 commits into
mainfrom
api-explorer-discriminator-first
Oct 16, 2026
Merged

akira28 merged 2 commits into
mainfrom
api-explorer-discriminator-first

Conversation

@akira28

@akira28 akira28 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Each oneOf/anyOf variant in the API reference now lists the property that selects it first, so the choice is the first thing its fields say.

Affects: API reference

Prompt summary: Fix elastic/docs-eng-team#1073. The discriminator parameter of a oneOf/anyOf variant should be detected and listed first, because it is the quickest way to tell variants apart.

Why

A variant lists its fields in schema order. The property that carries the choice, often type, can sit last among ten fields. A reader has to scan the whole list to find what distinguishes the variant.

What

Discriminator first in each variant

A variant moves its selecting property to the top of its field list. The property comes from the OpenAPI discriminator.propertyName when the schema declares one. Otherwise it is the property that every variant fixes to its own single enum value, the same rule the variant labels already use.

Order of other fields

All other fields keep their schema order. A union with no declared discriminator and no property fixed per variant lists fields as before.

Verify

dotnet test tests/Elastic.ApiExplorer.Tests/
# BuildPropertyList_VariantSelectedByProperty_ListsThatPropertyFirst: declared and enum-detected cases

Check on the preview

A variant's fields now start with the property that selects it, declared by `discriminator` or fixed to a single enum value in every variant. Before, a `type` property could sit last among ten fields.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@akira28
akira28 requested a review from a team as a code owner October 16, 2026 11:23
@akira28
akira28 requested a review from technige October 16, 2026 11:23
A scalar variant no longer blocks the selector, and an array of objects counts through its items, matching how `LabelObjects` counts shapes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview (local build)

Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4490/

@akira28
akira28 merged commit 283d269 into main Oct 16, 2026
32 checks passed
@akira28
akira28 deleted the api-explorer-discriminator-first branch October 16, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant