Add a Make target to expand generics in schema.json #1763
Merged
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.
This PR adds a new
make transform-expand-generics
target.This target transforms
schema.json
to expand all generic types to concrete types and remove all generic parameters. These concrete types can have two forms:MultiBucketAggregateBase<TBucket>
), a new type is generated for every instance of this type, with the value of generic parameters replaced with the concrete value defined by the instanciating type.SearchRequest<TDocument>
), the generic parameters are replaced byUserDefinedData
.Currently
make transform-expand-generics
creates a newoutput/schema/schema-no-generics.json
file, but ultimately we should be able to specify the input and output paths as arguments.This transformation is the first of its kind, and is meant to produce a schema that is easier to consume by some code generators without removing features from the specification that would be useful for some other languages. It's the result of a discussion with @Anaethelion about the Go client generator, where generics bring significant complexity, but should be kept in the spec for languages with generic support.
Other transformations may be of interest, such as removing inheritance by expanding fields from a super class into its child classes.