@@ -58,6 +58,7 @@ public PutSynonymRequest(Elastic.Clients.Elasticsearch.Serverless.Id id) : base(
58
58
/// </para>
59
59
/// </summary>
60
60
[ JsonInclude , JsonPropertyName ( "synonyms_set" ) ]
61
+ [ SingleOrManyCollectionConverter ( typeof ( Elastic . Clients . Elasticsearch . Serverless . Synonyms . SynonymRule ) ) ]
61
62
public ICollection < Elastic . Clients . Elasticsearch . Serverless . Synonyms . SynonymRule > SynonymsSet { get ; set ; }
62
63
}
63
64
@@ -140,32 +141,30 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
140
141
if ( SynonymsSetDescriptor is not null )
141
142
{
142
143
writer . WritePropertyName ( "synonyms_set" ) ;
143
- writer . WriteStartArray ( ) ;
144
144
JsonSerializer . Serialize ( writer , SynonymsSetDescriptor , options ) ;
145
- writer . WriteEndArray ( ) ;
146
145
}
147
146
else if ( SynonymsSetDescriptorAction is not null )
148
147
{
149
148
writer . WritePropertyName ( "synonyms_set" ) ;
150
- writer . WriteStartArray ( ) ;
151
149
JsonSerializer . Serialize ( writer , new Elastic . Clients . Elasticsearch . Serverless . Synonyms . SynonymRuleDescriptor ( SynonymsSetDescriptorAction ) , options ) ;
152
- writer . WriteEndArray ( ) ;
153
150
}
154
151
else if ( SynonymsSetDescriptorActions is not null )
155
152
{
156
153
writer . WritePropertyName ( "synonyms_set" ) ;
157
- writer . WriteStartArray ( ) ;
154
+ if ( SynonymsSetDescriptorActions . Length != 1 )
155
+ writer . WriteStartArray ( ) ;
158
156
foreach ( var action in SynonymsSetDescriptorActions )
159
157
{
160
158
JsonSerializer . Serialize ( writer , new Elastic . Clients . Elasticsearch . Serverless . Synonyms . SynonymRuleDescriptor ( action ) , options ) ;
161
159
}
162
160
163
- writer . WriteEndArray ( ) ;
161
+ if ( SynonymsSetDescriptorActions . Length != 1 )
162
+ writer . WriteEndArray ( ) ;
164
163
}
165
164
else
166
165
{
167
166
writer . WritePropertyName ( "synonyms_set" ) ;
168
- JsonSerializer . Serialize ( writer , SynonymsSetValue , options ) ;
167
+ SingleOrManySerializationHelper . Serialize < Elastic . Clients . Elasticsearch . Serverless . Synonyms . SynonymRule > ( SynonymsSetValue , writer , options ) ;
169
168
}
170
169
171
170
writer . WriteEndObject ( ) ;
@@ -251,32 +250,30 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
251
250
if ( SynonymsSetDescriptor is not null )
252
251
{
253
252
writer . WritePropertyName ( "synonyms_set" ) ;
254
- writer . WriteStartArray ( ) ;
255
253
JsonSerializer . Serialize ( writer , SynonymsSetDescriptor , options ) ;
256
- writer . WriteEndArray ( ) ;
257
254
}
258
255
else if ( SynonymsSetDescriptorAction is not null )
259
256
{
260
257
writer . WritePropertyName ( "synonyms_set" ) ;
261
- writer . WriteStartArray ( ) ;
262
258
JsonSerializer . Serialize ( writer , new Elastic . Clients . Elasticsearch . Serverless . Synonyms . SynonymRuleDescriptor ( SynonymsSetDescriptorAction ) , options ) ;
263
- writer . WriteEndArray ( ) ;
264
259
}
265
260
else if ( SynonymsSetDescriptorActions is not null )
266
261
{
267
262
writer . WritePropertyName ( "synonyms_set" ) ;
268
- writer . WriteStartArray ( ) ;
263
+ if ( SynonymsSetDescriptorActions . Length != 1 )
264
+ writer . WriteStartArray ( ) ;
269
265
foreach ( var action in SynonymsSetDescriptorActions )
270
266
{
271
267
JsonSerializer . Serialize ( writer , new Elastic . Clients . Elasticsearch . Serverless . Synonyms . SynonymRuleDescriptor ( action ) , options ) ;
272
268
}
273
269
274
- writer . WriteEndArray ( ) ;
270
+ if ( SynonymsSetDescriptorActions . Length != 1 )
271
+ writer . WriteEndArray ( ) ;
275
272
}
276
273
else
277
274
{
278
275
writer . WritePropertyName ( "synonyms_set" ) ;
279
- JsonSerializer . Serialize ( writer , SynonymsSetValue , options ) ;
276
+ SingleOrManySerializationHelper . Serialize < Elastic . Clients . Elasticsearch . Serverless . Synonyms . SynonymRule > ( SynonymsSetValue , writer , options ) ;
280
277
}
281
278
282
279
writer . WriteEndObject ( ) ;
0 commit comments