Skip to content

fix: Allow to tag non-exhaustive union types - #1182

Open
acote-coveo wants to merge 1 commit into
opensearch-project:mainfrom
acote-coveo:fix/document-non-ehaustive-union
Open

fix: Allow to tag non-exhaustive union types#1182
acote-coveo wants to merge 1 commit into
opensearch-project:mainfrom
acote-coveo:fix/document-non-ehaustive-union

Conversation

@acote-coveo

@acote-coveo acote-coveo commented Aug 3, 2026

Copy link
Copy Markdown

Description

Add a new x-non-exhaustive OpenAPI vendor extension that marks discriminated union (tagged) types as non-exhaustive. Union types are considered "non-exhaustive" when they can be extended through plugins at runtime — code generators should treat these unions as open/extensible rather than sealed.

Changes

  • New vendor extension: Introduced x-non-exhaustive: true annotation on the following plugin-extensible union schemas:

    • Property (_common.mapping.yaml)
    • Analyzer, TokenizerDefinition, TokenFilterDefinition, CharFilterDefinition (_common.analysis.yaml)
    • QueryContainer, SpanQuery (_common.query_dsl.yaml)
    • AggregationContainer (_common.aggregations.yaml)
    • ProcessorContainer (ingest._common.yaml)
    • FieldSuggester (_core.search.yaml)
  • Linter/Tester updates: Registered x-non-exhaustive as a recognized additional keyword in both SchemasValidator.ts and SchemaValidator.ts to prevent unknown-keyword lint errors.

  • Documentation: Added x-non-exhaustive to the vendor extensions section of DEVELOPER_GUIDE.md.

  • Changelog: Documented the addition under the "Added" section.

Motivation

Generators (e.g. opensearch-java) need a way to know which union types are open to extension so they can emit appropriate code — such as an "custom" variant or a custom deserialization fallback — rather than failing on unrecognized discriminator values introduced by plugins.

Related Issues


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check [here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

Add a new OpenAPI annotation that allows to tag union types that are non-exhaustive. Union types are considered "non-exhaustive" when they can be extended through plugins.

Generators can later leverage this annotation to support extension.
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.

1 participant