Feat/add support for non exhaustive union types - #2083
Draft
acote-coveo wants to merge 2 commits into
Draft
Conversation
The lambda-based deserializer ignored the three-argument overload, causing it to re-read from the parser after the event was already consumed. Replace with an explicit JsonpDeserializerBase that delegates to parser.getValue() when the event is provided.
Tagged unions annotated with x-non-exhaustive in the OpenAPI spec now emit a Kind._Custom enum member so that unknown discriminator values (e.g. plugin-provided aggregation types) deserialize into a lossless JsonData wrapper instead of throwing. Affected unions: Aggregate, Query, SpanQuery, Property, Processor, Analyzer, CharFilterDefinition, TokenFilterDefinition, TokenizerDefinition.
This was referenced Aug 3, 2026
Open
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.
Add
_Customvariant kind to non-exhaustive tagged unionsDescription
OpenSearch plugins can introduce aggregation types, query types, processors, analyzers, and mapping properties that aren't modeled in the Java client's generated code. Today, encountering one of these at deserialization time throws a
JsonException, making the client unusable against clusters with such plugins installed.This PR introduces a
Kind._Customenum member on tagged unions markedx-non-exhaustive: truein the OpenAPI spec. When the deserializer encounters an unknown discriminator value it captures the raw JSON asJsonDataunder the_Customkind instead of failing. The original type name is preserved via_customKind()and the data round-trips through serialization.Changes
Bug-fix (independent, first commit):
JsonData._DESERIALIZER— the lambda-based deserializer silently ignored the pre-consumedeventargument in the three-argdeserializeoverload. Replaced with an explicitJsonpDeserializerBasethat delegates toparser.getValue()when the event is already consumed.Feature:
x-non-exhaustive: trueto 10 union schemas (Aggregate, Query, SpanQuery, Property, Processor, Analyzer, CharFilterDefinition, TokenFilterDefinition, TokenizerDefinition, FieldSuggester)OpenApiSchemaparses the extension;SpecTransformerpropagates it;TaggedUnionShapegains anonExhaustiveflag and a_customKindfieldTaggedUnionShape.mustacheemitsKind._Custom,_customKind(),_isCustom(),_custom(),Builder._custom(type, data), and an innerCustomVariantwrapper class. Deserialize/Serialize templates handle the fallback pathTaggedUnioninterface adds a default_customKind()method;ExternallyTaggedUnionuses it for typed-key serializationUsage
Related changes
opensearch-project/opensearch-api-specification#1182
Checklist
CHANGELOG.mdupdatedguides/json.md)