@@ -32,16 +32,6 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
3232 {
3333 throw new FormatException ( $ "The model { nameof ( ImageEditOptions ) } does not support writing '{ format } ' format.") ;
3434 }
35- if ( Optional . IsDefined ( Background ) && _additionalBinaryDataProperties ? . ContainsKey ( "background" ) != true )
36- {
37- writer . WritePropertyName ( "background"u8 ) ;
38- writer . WriteStringValue ( Background . Value . ToString ( ) ) ;
39- }
40- if ( Optional . IsDefined ( Quality ) && _additionalBinaryDataProperties ? . ContainsKey ( "quality" ) != true )
41- {
42- writer . WritePropertyName ( "quality"u8 ) ;
43- writer . WriteStringValue ( Quality . Value . ToString ( ) ) ;
44- }
4535 if ( Optional . IsDefined ( Model ) && _additionalBinaryDataProperties ? . ContainsKey ( "model" ) != true )
4636 {
4737 writer . WritePropertyName ( "model"u8 ) ;
@@ -74,6 +64,16 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
7464 writer . WritePropertyName ( "n"u8 ) ;
7565 writer . WriteNumberValue ( N . Value ) ;
7666 }
67+ if ( Optional . IsDefined ( Background ) && _additionalBinaryDataProperties ? . ContainsKey ( "background" ) != true )
68+ {
69+ writer . WritePropertyName ( "background"u8 ) ;
70+ writer . WriteStringValue ( Background . Value . ToString ( ) ) ;
71+ }
72+ if ( Optional . IsDefined ( Quality ) && _additionalBinaryDataProperties ? . ContainsKey ( "quality" ) != true )
73+ {
74+ writer . WritePropertyName ( "quality"u8 ) ;
75+ writer . WriteStringValue ( Quality . Value . ToString ( ) ) ;
76+ }
7777 if ( Optional . IsDefined ( Size ) && _additionalBinaryDataProperties ? . ContainsKey ( "size" ) != true )
7878 {
7979 writer . WritePropertyName ( "size"u8 ) ;
@@ -131,39 +131,19 @@ internal static ImageEditOptions DeserializeImageEditOptions(JsonElement element
131131 {
132132 return null ;
133133 }
134- InternalCreateImageEditRequestBackground ? background = default ;
135- InternalCreateImageEditRequestQuality ? quality = default ;
136134 InternalCreateImageEditRequestModel ? model = default ;
137135 BinaryData image = default ;
138136 string prompt = default ;
139137 BinaryData mask = default ;
140138 long ? n = default ;
139+ GeneratedImageBackground ? background = default ;
140+ GeneratedImageQuality ? quality = default ;
141141 GeneratedImageSize ? size = default ;
142142 GeneratedImageFormat ? responseFormat = default ;
143143 string endUserId = default ;
144144 IDictionary < string , BinaryData > additionalBinaryDataProperties = new ChangeTrackingDictionary < string , BinaryData > ( ) ;
145145 foreach ( var prop in element . EnumerateObject ( ) )
146146 {
147- if ( prop . NameEquals ( "background"u8 ) )
148- {
149- if ( prop . Value . ValueKind == JsonValueKind . Null )
150- {
151- background = null ;
152- continue ;
153- }
154- background = new InternalCreateImageEditRequestBackground ( prop . Value . GetString ( ) ) ;
155- continue ;
156- }
157- if ( prop . NameEquals ( "quality"u8 ) )
158- {
159- if ( prop . Value . ValueKind == JsonValueKind . Null )
160- {
161- quality = null ;
162- continue ;
163- }
164- quality = new InternalCreateImageEditRequestQuality ( prop . Value . GetString ( ) ) ;
165- continue ;
166- }
167147 if ( prop . NameEquals ( "model"u8 ) )
168148 {
169149 if ( prop . Value . ValueKind == JsonValueKind . Null )
@@ -203,6 +183,26 @@ internal static ImageEditOptions DeserializeImageEditOptions(JsonElement element
203183 n = prop . Value . GetInt64 ( ) ;
204184 continue ;
205185 }
186+ if ( prop . NameEquals ( "background"u8 ) )
187+ {
188+ if ( prop . Value . ValueKind == JsonValueKind . Null )
189+ {
190+ background = null ;
191+ continue ;
192+ }
193+ background = new GeneratedImageBackground ( prop . Value . GetString ( ) ) ;
194+ continue ;
195+ }
196+ if ( prop . NameEquals ( "quality"u8 ) )
197+ {
198+ if ( prop . Value . ValueKind == JsonValueKind . Null )
199+ {
200+ quality = null ;
201+ continue ;
202+ }
203+ quality = new GeneratedImageQuality ( prop . Value . GetString ( ) ) ;
204+ continue ;
205+ }
206206 if ( prop . NameEquals ( "size"u8 ) )
207207 {
208208 if ( prop . Value . ValueKind == JsonValueKind . Null )
@@ -232,13 +232,13 @@ internal static ImageEditOptions DeserializeImageEditOptions(JsonElement element
232232 additionalBinaryDataProperties . Add ( prop . Name , BinaryData . FromString ( prop . Value . GetRawText ( ) ) ) ;
233233 }
234234 return new ImageEditOptions (
235- background ,
236- quality ,
237235 model ,
238236 image ,
239237 prompt ,
240238 mask ,
241239 n ,
240+ background ,
241+ quality ,
242242 size ,
243243 responseFormat ,
244244 endUserId ,
0 commit comments