@@ -182,16 +182,22 @@ def _parse_a_camel_date_time(data: Union[str]) -> Union[datetime.datetime, datet
182182
183183 required_not_nullable = d .pop ("required_not_nullable" )
184184
185+ if not isinstance (d .pop ("model" ), dict ):
186+ raise ValueError ("Cannot construct model from value " + str (d .pop ("model" )))
185187 model = AModelModel .from_dict (d .pop ("model" ))
186188
187189 def _parse_one_of_models (data : Union [Dict [str , Any ]]) -> Union [FreeFormModel , ModelWithUnionProperty ]:
188190 one_of_models : Union [FreeFormModel , ModelWithUnionProperty ]
189191 try :
192+ if not isinstance (data , dict ):
193+ raise ValueError ("Cannot construct model from value " + str (data ))
190194 one_of_models = FreeFormModel .from_dict (data )
191195
192196 return one_of_models
193197 except : # noqa: E722
194198 pass
199+ if not isinstance (data , dict ):
200+ raise ValueError ("Cannot construct model from value " + str (data ))
195201 one_of_models = ModelWithUnionProperty .from_dict (data )
196202
197203 return one_of_models
@@ -224,19 +230,28 @@ def _parse_one_of_models(data: Union[Dict[str, Any]]) -> Union[FreeFormModel, Mo
224230 not_required_not_nullable = d .pop ("not_required_not_nullable" , UNSET )
225231
226232 nullable_model = None
227- _nullable_model = d .pop ("nullable_model" )
228- if _nullable_model is not None and not isinstance (_nullable_model , Unset ):
229- nullable_model = AModelNullableModel .from_dict (_nullable_model )
233+ if d .pop ("nullable_model" ) is not None and not isinstance (d .pop ("nullable_model" ), Unset ):
234+ if not isinstance (d .pop ("nullable_model" ), dict ):
235+ raise ValueError ("Cannot construct model from value " + str (d .pop ("nullable_model" )))
236+ nullable_model = AModelNullableModel .from_dict (d .pop ("nullable_model" ))
230237
231238 not_required_model : Union [Unset , AModelNotRequiredModel ] = UNSET
232- _not_required_model = d .pop ("not_required_model" , UNSET )
233- if _not_required_model is not None and not isinstance (_not_required_model , Unset ):
234- not_required_model = AModelNotRequiredModel .from_dict (_not_required_model )
239+ if d .pop ("not_required_model" , UNSET ) is not None and not isinstance (d .pop ("not_required_model" , UNSET ), Unset ):
240+ if not isinstance (d .pop ("not_required_model" , UNSET ), dict ):
241+ raise ValueError ("Cannot construct model from value " + str (d .pop ("not_required_model" , UNSET )))
242+ not_required_model = AModelNotRequiredModel .from_dict (d .pop ("not_required_model" , UNSET ))
235243
236244 not_required_nullable_model = None
237- _not_required_nullable_model = d .pop ("not_required_nullable_model" , UNSET )
238- if _not_required_nullable_model is not None and not isinstance (_not_required_nullable_model , Unset ):
239- not_required_nullable_model = AModelNotRequiredNullableModel .from_dict (_not_required_nullable_model )
245+ if d .pop ("not_required_nullable_model" , UNSET ) is not None and not isinstance (
246+ d .pop ("not_required_nullable_model" , UNSET ), Unset
247+ ):
248+ if not isinstance (d .pop ("not_required_nullable_model" , UNSET ), dict ):
249+ raise ValueError (
250+ "Cannot construct model from value " + str (d .pop ("not_required_nullable_model" , UNSET ))
251+ )
252+ not_required_nullable_model = AModelNotRequiredNullableModel .from_dict (
253+ d .pop ("not_required_nullable_model" , UNSET )
254+ )
240255
241256 def _parse_nullable_one_of_models (
242257 data : Union [None , Dict [str , Any ]]
@@ -245,11 +260,15 @@ def _parse_nullable_one_of_models(
245260 if data is None :
246261 return data
247262 try :
263+ if not isinstance (data , dict ):
264+ raise ValueError ("Cannot construct model from value " + str (data ))
248265 nullable_one_of_models = FreeFormModel .from_dict (data )
249266
250267 return nullable_one_of_models
251268 except : # noqa: E722
252269 pass
270+ if not isinstance (data , dict ):
271+ raise ValueError ("Cannot construct model from value " + str (data ))
253272 nullable_one_of_models = ModelWithUnionProperty .from_dict (data )
254273
255274 return nullable_one_of_models
@@ -264,17 +283,19 @@ def _parse_not_required_one_of_models(
264283 return data
265284 try :
266285 not_required_one_of_models = UNSET
267- _not_required_one_of_models = data
268- if _not_required_one_of_models is not None and not isinstance (_not_required_one_of_models , Unset ):
269- not_required_one_of_models = FreeFormModel .from_dict (_not_required_one_of_models )
286+ if data is not None and not isinstance (data , Unset ):
287+ if not isinstance (data , dict ):
288+ raise ValueError ("Cannot construct model from value " + str (data ))
289+ not_required_one_of_models = FreeFormModel .from_dict (data )
270290
271291 return not_required_one_of_models
272292 except : # noqa: E722
273293 pass
274294 not_required_one_of_models = UNSET
275- _not_required_one_of_models = data
276- if _not_required_one_of_models is not None and not isinstance (_not_required_one_of_models , Unset ):
277- not_required_one_of_models = ModelWithUnionProperty .from_dict (_not_required_one_of_models )
295+ if data is not None and not isinstance (data , Unset ):
296+ if not isinstance (data , dict ):
297+ raise ValueError ("Cannot construct model from value " + str (data ))
298+ not_required_one_of_models = ModelWithUnionProperty .from_dict (data )
278299
279300 return not_required_one_of_models
280301
@@ -290,23 +311,19 @@ def _parse_not_required_nullable_one_of_models(
290311 return data
291312 try :
292313 not_required_nullable_one_of_models = UNSET
293- _not_required_nullable_one_of_models = data
294- if _not_required_nullable_one_of_models is not None and not isinstance (
295- _not_required_nullable_one_of_models , Unset
296- ):
297- not_required_nullable_one_of_models = FreeFormModel .from_dict (_not_required_nullable_one_of_models )
314+ if data is not None and not isinstance (data , Unset ):
315+ if not isinstance (data , dict ):
316+ raise ValueError ("Cannot construct model from value " + str (data ))
317+ not_required_nullable_one_of_models = FreeFormModel .from_dict (data )
298318
299319 return not_required_nullable_one_of_models
300320 except : # noqa: E722
301321 pass
302322 not_required_nullable_one_of_models = UNSET
303- _not_required_nullable_one_of_models = data
304- if _not_required_nullable_one_of_models is not None and not isinstance (
305- _not_required_nullable_one_of_models , Unset
306- ):
307- not_required_nullable_one_of_models = ModelWithUnionProperty .from_dict (
308- _not_required_nullable_one_of_models
309- )
323+ if data is not None and not isinstance (data , Unset ):
324+ if not isinstance (data , dict ):
325+ raise ValueError ("Cannot construct model from value " + str (data ))
326+ not_required_nullable_one_of_models = ModelWithUnionProperty .from_dict (data )
310327
311328 return not_required_nullable_one_of_models
312329
0 commit comments