Skip to content

Commit 89b3ea2

Browse files
Initial support for additional properties behaviour (#6604) (#6605)
* Initial code gen for additional properties * Update code-generated converters for readonly types * Add jobs deserialisation test * Handle additional properties in custom converters * Descriptors support with additional properties * Refine serialization logic * Add serialization tests for suggest Co-authored-by: Steve Gordon <[email protected]>
1 parent 2ac0301 commit 89b3ea2

File tree

100 files changed

+5039
-644
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+5039
-644
lines changed

src/Elastic.Clients.Elasticsearch/Serialization/Stringified.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@ namespace Elastic.Clients.Elasticsearch;
1010

1111
internal sealed class StringifiedLongConverter : JsonConverter<long?>
1212
{
13-
public override long? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
13+
public override long? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ReadStringifiedLong(ref reader);
14+
15+
public override void Write(Utf8JsonWriter writer, long? value, JsonSerializerOptions options) => writer.WriteNumberValue(value.Value);
16+
17+
public static long ReadStringifiedLong(ref Utf8JsonReader reader)
1418
{
19+
if (reader.TokenType == JsonTokenType.PropertyName)
20+
reader.Read();
21+
1522
if (reader.TokenType == JsonTokenType.String)
1623
{
1724
var longString = reader.GetString();
@@ -25,8 +32,6 @@ internal sealed class StringifiedLongConverter : JsonConverter<long?>
2532
}
2633

2734
return reader.GetInt64();
28-
}
29-
3035

31-
public override void Write(Utf8JsonWriter writer, long? value, JsonSerializerOptions options) => writer.WriteNumberValue(value.Value);
36+
}
3237
}

src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregation.g.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public override AdjacencyMatrixAggregation Read(ref Utf8JsonReader reader, Type
8181
}
8282
}
8383

84-
reader.Read();
8584
return agg;
8685
}
8786

@@ -120,8 +119,6 @@ public AdjacencyMatrixAggregation(string name) : base(name)
120119
{
121120
}
122121

123-
[JsonInclude]
124-
[JsonPropertyName("filters")]
125122
public Dictionary<string, Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer>? Filters { get; set; }
126123
}
127124

src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregation.g.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ public override AutoDateHistogramAggregation Read(ref Utf8JsonReader reader, Typ
177177
}
178178
}
179179

180-
reader.Read();
181180
return agg;
182181
}
183182

@@ -264,40 +263,22 @@ public AutoDateHistogramAggregation(string name) : base(name)
264263
{
265264
}
266265

267-
[JsonInclude]
268-
[JsonPropertyName("buckets")]
269266
public int? Buckets { get; set; }
270267

271-
[JsonInclude]
272-
[JsonPropertyName("field")]
273268
public Elastic.Clients.Elasticsearch.Field? Field { get; set; }
274269

275-
[JsonInclude]
276-
[JsonPropertyName("format")]
277270
public string? Format { get; set; }
278271

279-
[JsonInclude]
280-
[JsonPropertyName("minimum_interval")]
281272
public Elastic.Clients.Elasticsearch.Aggregations.MinimumInterval? MinimumInterval { get; set; }
282273

283-
[JsonInclude]
284-
[JsonPropertyName("missing")]
285274
public DateTimeOffset? Missing { get; set; }
286275

287-
[JsonInclude]
288-
[JsonPropertyName("offset")]
289276
public string? Offset { get; set; }
290277

291-
[JsonInclude]
292-
[JsonPropertyName("params")]
293278
public Dictionary<string, object>? Params { get; set; }
294279

295-
[JsonInclude]
296-
[JsonPropertyName("script")]
297280
public ScriptBase? Script { get; set; }
298281

299-
[JsonInclude]
300-
[JsonPropertyName("time_zone")]
301282
public string? TimeZone { get; set; }
302283
}
303284

src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AverageAggregation.g.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ public override AverageAggregation Read(ref Utf8JsonReader reader, Type typeToCo
9494
}
9595
}
9696

97-
reader.Read();
9897
return agg;
9998
}
10099

src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxplotAggregation.g.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ public override BoxplotAggregation Read(ref Utf8JsonReader reader, Type typeToCo
9494
}
9595
}
9696

97-
reader.Read();
9897
return agg;
9998
}
10099

@@ -140,8 +139,6 @@ public BoxplotAggregation(string name) : base(name)
140139
{
141140
}
142141

143-
[JsonInclude]
144-
[JsonPropertyName("compression")]
145142
public double? Compression { get; set; }
146143
}
147144

src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregation.g.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ public override CardinalityAggregation Read(ref Utf8JsonReader reader, Type type
106106
}
107107
}
108108

109-
reader.Read();
110109
return agg;
111110
}
112111

@@ -158,12 +157,8 @@ public CardinalityAggregation(string name) : base(name)
158157
{
159158
}
160159

161-
[JsonInclude]
162-
[JsonPropertyName("precision_threshold")]
163160
public int? PrecisionThreshold { get; set; }
164161

165-
[JsonInclude]
166-
[JsonPropertyName("rehash")]
167162
public bool? Rehash { get; set; }
168163
}
169164

src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregation.g.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public override ChildrenAggregation Read(ref Utf8JsonReader reader, Type typeToC
8181
}
8282
}
8383

84-
reader.Read();
8584
return agg;
8685
}
8786

@@ -120,8 +119,6 @@ public ChildrenAggregation(string name) : base(name)
120119
{
121120
}
122121

123-
[JsonInclude]
124-
[JsonPropertyName("type")]
125122
public string? Type { get; set; }
126123
}
127124

src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregation.g.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ public override CompositeAggregation Read(ref Utf8JsonReader reader, Type typeTo
105105
}
106106
}
107107

108-
reader.Read();
109108
return agg;
110109
}
111110

@@ -156,16 +155,10 @@ public CompositeAggregation(string name) : base(name)
156155
{
157156
}
158157

159-
[JsonInclude]
160-
[JsonPropertyName("after")]
161158
public Dictionary<string, object>? After { get; set; }
162159

163-
[JsonInclude]
164-
[JsonPropertyName("size")]
165160
public int? Size { get; set; }
166161

167-
[JsonInclude]
168-
[JsonPropertyName("sources")]
169162
public IEnumerable<Dictionary<string, Elastic.Clients.Elasticsearch.Aggregations.CompositeAggregationSource>>? Sources { get; set; }
170163
}
171164

src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregation.g.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ public override CumulativeCardinalityAggregation Read(ref Utf8JsonReader reader,
9494
}
9595
}
9696

97-
reader.Read();
9897
return agg;
9998
}
10099

src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ public override DateHistogramAggregation Read(ref Utf8JsonReader reader, Type ty
201201
}
202202
}
203203

204-
reader.Read();
205204
return agg;
206205
}
207206

@@ -300,49 +299,27 @@ public DateHistogramAggregation(string name) : base(name)
300299
{
301300
}
302301

303-
[JsonInclude]
304-
[JsonPropertyName("calendar_interval")]
305302
public Elastic.Clients.Elasticsearch.Aggregations.CalendarInterval? CalendarInterval { get; set; }
306303

307-
[JsonInclude]
308-
[JsonPropertyName("field")]
309304
public Elastic.Clients.Elasticsearch.Field? Field { get; set; }
310305

311-
[JsonInclude]
312-
[JsonPropertyName("fixed_interval")]
313306
public Elastic.Clients.Elasticsearch.Duration? FixedInterval { get; set; }
314307

315-
[JsonInclude]
316-
[JsonPropertyName("format")]
317308
public string? Format { get; set; }
318309

319-
[JsonInclude]
320-
[JsonPropertyName("min_doc_count")]
321310
public int? MinDocCount { get; set; }
322311

323-
[JsonInclude]
324-
[JsonPropertyName("missing")]
325312
public DateTimeOffset? Missing { get; set; }
326313

327-
[JsonInclude]
328-
[JsonPropertyName("offset")]
329314
public Elastic.Clients.Elasticsearch.Duration? Offset { get; set; }
330315

331-
[JsonInclude]
332-
[JsonPropertyName("order")]
333316
[JsonConverter(typeof(AggregateOrderConverter))]
334317
public IEnumerable<KeyValuePair<Elastic.Clients.Elasticsearch.Field, Elastic.Clients.Elasticsearch.SortOrder>>? Order { get; set; }
335318

336-
[JsonInclude]
337-
[JsonPropertyName("params")]
338319
public Dictionary<string, object>? Params { get; set; }
339320

340-
[JsonInclude]
341-
[JsonPropertyName("script")]
342321
public ScriptBase? Script { get; set; }
343322

344-
[JsonInclude]
345-
[JsonPropertyName("time_zone")]
346323
public string? TimeZone { get; set; }
347324
}
348325

0 commit comments

Comments
 (0)