Repository navigation
List the discriminator property first in API union variants - #4490
Merged
Merged
Conversation
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>
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>
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4490/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each
oneOf/anyOfvariant in the API reference now lists the property that selects it first, so the choice is the first thing its fields say.Affects:
API referencePrompt summary: Fix elastic/docs-eng-team#1073. The discriminator parameter of a
oneOf/anyOfvariant 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.propertyNamewhen 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
Check on the preview
typefield of each variant was 10 to 35 rows down; it now opens each variant.typefourth; it now comes first.typethird and fifth; it now comes first.