Closed
Description
Generated code for open internally-tagged unions produces incorrect JSON when serialized. An example is when defining token filters on IndexSettings.
var createResponse = await client.Indices.CreateAsync("my-new-index", i => i
.Settings(s => s
.Analysis(a => a
.Filter(f => f
.Add("synonym", new TokenFilter(new TokenFilterDefinitions
{
{ "synonym", new SynonymTokenFilter() { SynonymsPath = "analysis/synonym.txt" } }
})))
.Analyzer(a => a
.Custom("my-custom-analyzer", c => c
.Filter(new[] { "stop", "synonym" })
.Tokenizer("standard"))))));
The above produces:
{
"settings": {
"analysis": {
"analyzer": {
"my-custom-analyzer": {
"filter": ["stop", "synonym"],
"tokenizer": "standard",
"type": "custom"
}
},
"filter": {
"synonym": {
"synonym": {
"synonyms_path": "analysis/synonym.txt",
"type": "synonym"
}
}
}
}
}
}
We expect:
{
"settings": {
"analysis": {
"analyzer": {
"my-custom-analyzer": {
"filter": ["stop", "synonym"],
"tokenizer": "standard",
"type": "custom"
}
},
"filter": {
"synonym": {
"synonyms_path": "analysis/synonym.txt",
"type": "synonym"
}
}
}
}
}
This is due to the generation of TokenFilterDefinitions
as IsADictionary
required for this polymorphic type's open nature. This will affect other similarly specified types.