@@ -87,14 +87,45 @@ public sealed partial class CreateRequestParameters : RequestParameters
8787 public Elastic . Clients . Elasticsearch . WaitForActiveShards ? WaitForActiveShards { get => Q < Elastic . Clients . Elasticsearch . WaitForActiveShards ? > ( "wait_for_active_shards" ) ; set => Q ( "wait_for_active_shards" , value ) ; }
8888}
8989
90+ internal sealed partial class CreateRequestConverter < TDocument > : System . Text . Json . Serialization . JsonConverter < CreateRequest < TDocument > >
91+ {
92+ public override CreateRequest < TDocument > Read ( ref System . Text . Json . Utf8JsonReader reader , System . Type typeToConvert , System . Text . Json . JsonSerializerOptions options )
93+ {
94+ return new CreateRequest < TDocument > { Document = reader . ReadValue < TDocument > ( options , typeof ( SourceMarker < TDocument > ) ) } ;
95+ }
96+
97+ public override void Write ( System . Text . Json . Utf8JsonWriter writer , CreateRequest < TDocument > value , System . Text . Json . JsonSerializerOptions options )
98+ {
99+ writer . WriteValue ( options , value . Document , typeof ( SourceMarker < TDocument > ) ) ;
100+ }
101+ }
102+
103+ internal sealed partial class CreateRequestConverterFactory : System . Text . Json . Serialization . JsonConverterFactory
104+ {
105+ public override bool CanConvert ( System . Type typeToConvert )
106+ {
107+ return typeToConvert . IsGenericType && typeToConvert . GetGenericTypeDefinition ( ) == typeof ( CreateRequest < > ) ;
108+ }
109+
110+ public override System . Text . Json . Serialization . JsonConverter CreateConverter ( System . Type typeToConvert , System . Text . Json . JsonSerializerOptions options )
111+ {
112+ var args = typeToConvert . GetGenericArguments ( ) ;
113+ #pragma warning disable IL3050
114+ var converter = ( System . Text . Json . Serialization . JsonConverter ) System . Activator . CreateInstance ( typeof ( CreateRequestConverter < > ) . MakeGenericType ( args [ 0 ] ) , System . Reflection . BindingFlags . Instance | System . Reflection . BindingFlags . Public , binder : null , args : null , culture : null ) ! ;
115+ #pragma warning restore IL3050
116+ return converter ;
117+ }
118+ }
119+
90120/// <summary>
91121/// <para>
92122/// Index a document.
93123/// Adds a JSON document to the specified data stream or index and makes it searchable.
94124/// If the target is an index and the document already exists, the request updates the document and increments its version.
95125/// </para>
96126/// </summary>
97- public sealed partial class CreateRequest < TDocument > : PlainRequest < CreateRequestParameters > , ISelfTwoWaySerializable
127+ [ JsonConverter ( typeof ( CreateRequestConverterFactory ) ) ]
128+ public sealed partial class CreateRequest < TDocument > : PlainRequest < CreateRequestParameters >
98129{
99130 public CreateRequest ( Elastic . Clients . Elasticsearch . IndexName index , Elastic . Clients . Elasticsearch . Id id ) : base ( r => r . Required ( "index" , index ) . Required ( "id" , id ) )
100131 {
@@ -118,7 +149,6 @@ internal CreateRequest()
118149 /// Unique identifier for the document.
119150 /// </para>
120151 /// </summary>
121- [ JsonIgnore ]
122152 public Elastic . Clients . Elasticsearch . Id Id { get => P < Elastic . Clients . Elasticsearch . Id > ( "id" ) ; set => PR ( "id" , value ) ; }
123153
124154 /// <summary>
@@ -128,7 +158,6 @@ internal CreateRequest()
128158 /// If the target doesn’t exist and doesn’t match a data stream template, this request creates the index.
129159 /// </para>
130160 /// </summary>
131- [ JsonIgnore ]
132161 public Elastic . Clients . Elasticsearch . IndexName Index { get => P < Elastic . Clients . Elasticsearch . IndexName > ( "index" ) ; set => PR ( "index" , value ) ; }
133162
134163 /// <summary>
@@ -138,7 +167,6 @@ internal CreateRequest()
138167 /// If a final pipeline is configured it will always run, regardless of the value of this parameter.
139168 /// </para>
140169 /// </summary>
141- [ JsonIgnore ]
142170 public string ? Pipeline { get => Q < string ? > ( "pipeline" ) ; set => Q ( "pipeline" , value ) ; }
143171
144172 /// <summary>
@@ -147,23 +175,20 @@ internal CreateRequest()
147175 /// Valid values: <c>true</c>, <c>false</c>, <c>wait_for</c>.
148176 /// </para>
149177 /// </summary>
150- [ JsonIgnore ]
151178 public Elastic . Clients . Elasticsearch . Refresh ? Refresh { get => Q < Elastic . Clients . Elasticsearch . Refresh ? > ( "refresh" ) ; set => Q ( "refresh" , value ) ; }
152179
153180 /// <summary>
154181 /// <para>
155182 /// Custom value used to route operations to a specific shard.
156183 /// </para>
157184 /// </summary>
158- [ JsonIgnore ]
159185 public Elastic . Clients . Elasticsearch . Routing ? Routing { get => Q < Elastic . Clients . Elasticsearch . Routing ? > ( "routing" ) ; set => Q ( "routing" , value ) ; }
160186
161187 /// <summary>
162188 /// <para>
163189 /// Period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards.
164190 /// </para>
165191 /// </summary>
166- [ JsonIgnore ]
167192 public Elastic . Clients . Elasticsearch . Duration ? Timeout { get => Q < Elastic . Clients . Elasticsearch . Duration ? > ( "timeout" ) ; set => Q ( "timeout" , value ) ; }
168193
169194 /// <summary>
@@ -172,15 +197,13 @@ internal CreateRequest()
172197 /// The specified version must match the current version of the document for the request to succeed.
173198 /// </para>
174199 /// </summary>
175- [ JsonIgnore ]
176200 public long ? Version { get => Q < long ? > ( "version" ) ; set => Q ( "version" , value ) ; }
177201
178202 /// <summary>
179203 /// <para>
180204 /// Specific version type: <c>external</c>, <c>external_gte</c>.
181205 /// </para>
182206 /// </summary>
183- [ JsonIgnore ]
184207 public Elastic . Clients . Elasticsearch . VersionType ? VersionType { get => Q < Elastic . Clients . Elasticsearch . VersionType ? > ( "version_type" ) ; set => Q ( "version_type" , value ) ; }
185208
186209 /// <summary>
@@ -189,19 +212,8 @@ internal CreateRequest()
189212 /// Set to <c>all</c> or any positive integer up to the total number of shards in the index (<c>number_of_replicas+1</c>).
190213 /// </para>
191214 /// </summary>
192- [ JsonIgnore ]
193215 public Elastic . Clients . Elasticsearch . WaitForActiveShards ? WaitForActiveShards { get => Q < Elastic . Clients . Elasticsearch . WaitForActiveShards ? > ( "wait_for_active_shards" ) ; set => Q ( "wait_for_active_shards" , value ) ; }
194216 public TDocument Document { get ; set ; }
195-
196- void ISelfTwoWaySerializable . Serialize ( Utf8JsonWriter writer , JsonSerializerOptions options , IElasticsearchClientSettings settings )
197- {
198- settings . SourceSerializer . Serialize ( Document , writer ) ;
199- }
200-
201- void ISelfTwoWaySerializable . Deserialize ( ref Utf8JsonReader reader , JsonSerializerOptions options , IElasticsearchClientSettings settings )
202- {
203- Document = settings . SourceSerializer . Deserialize < TDocument > ( ref reader ) ;
204- }
205217}
206218
207219/// <summary>
0 commit comments