1
1
import datetime
2
2
from typing import TYPE_CHECKING , Any , Dict , List , Type , TypeVar , Union , cast
3
+ from uuid import UUID
3
4
4
5
from attrs import define as _attrs_define
5
6
from dateutil .parser import isoparse
@@ -27,6 +28,8 @@ class AModel:
27
28
a_camel_date_time (Union[datetime.date, datetime.datetime]):
28
29
a_date (datetime.date):
29
30
a_nullable_date (Union[None, datetime.date]):
31
+ a_uuid (UUID):
32
+ a_nullable_uuid (Union[None, UUID]): Default: UUID('07EF8B4D-AA09-4FFA-898D-C710796AFF41').
30
33
required_nullable (Union[None, str]):
31
34
required_not_nullable (str):
32
35
one_of_models (Union['FreeFormModel', 'ModelWithUnionProperty', Any]):
@@ -37,6 +40,7 @@ class AModel:
37
40
an_optional_allof_enum (Union[Unset, AnAllOfEnum]):
38
41
nested_list_of_enums (Union[Unset, List[List[DifferentEnum]]]):
39
42
a_not_required_date (Union[Unset, datetime.date]):
43
+ a_not_required_uuid (Union[Unset, UUID]):
40
44
attr_1_leading_digit (Union[Unset, str]):
41
45
attr_leading_underscore (Union[Unset, str]):
42
46
not_required_nullable (Union[None, Unset, str]):
@@ -51,17 +55,20 @@ class AModel:
51
55
a_camel_date_time : Union [datetime .date , datetime .datetime ]
52
56
a_date : datetime .date
53
57
a_nullable_date : Union [None , datetime .date ]
58
+ a_uuid : UUID
54
59
required_nullable : Union [None , str ]
55
60
required_not_nullable : str
56
61
one_of_models : Union ["FreeFormModel" , "ModelWithUnionProperty" , Any ]
57
62
nullable_one_of_models : Union ["FreeFormModel" , "ModelWithUnionProperty" , None ]
58
63
model : "ModelWithUnionProperty"
59
64
nullable_model : Union ["ModelWithUnionProperty" , None ]
60
65
an_allof_enum_with_overridden_default : AnAllOfEnum = AnAllOfEnum .OVERRIDDEN_DEFAULT
66
+ a_nullable_uuid : Union [None , UUID ] = UUID ("07EF8B4D-AA09-4FFA-898D-C710796AFF41" )
61
67
any_value : Union [Unset , Any ] = "default"
62
68
an_optional_allof_enum : Union [Unset , AnAllOfEnum ] = UNSET
63
69
nested_list_of_enums : Union [Unset , List [List [DifferentEnum ]]] = UNSET
64
70
a_not_required_date : Union [Unset , datetime .date ] = UNSET
71
+ a_not_required_uuid : Union [Unset , UUID ] = UNSET
65
72
attr_1_leading_digit : Union [Unset , str ] = UNSET
66
73
attr_leading_underscore : Union [Unset , str ] = UNSET
67
74
not_required_nullable : Union [None , Unset , str ] = UNSET
@@ -93,6 +100,14 @@ def to_dict(self) -> Dict[str, Any]:
93
100
else :
94
101
a_nullable_date = self .a_nullable_date
95
102
103
+ a_uuid = str (self .a_uuid )
104
+
105
+ a_nullable_uuid : Union [None , str ]
106
+ if isinstance (self .a_nullable_uuid , UUID ):
107
+ a_nullable_uuid = str (self .a_nullable_uuid )
108
+ else :
109
+ a_nullable_uuid = self .a_nullable_uuid
110
+
96
111
required_nullable : Union [None , str ]
97
112
required_nullable = self .required_nullable
98
113
@@ -143,6 +158,10 @@ def to_dict(self) -> Dict[str, Any]:
143
158
if not isinstance (self .a_not_required_date , Unset ):
144
159
a_not_required_date = self .a_not_required_date .isoformat ()
145
160
161
+ a_not_required_uuid : Union [Unset , str ] = UNSET
162
+ if not isinstance (self .a_not_required_uuid , Unset ):
163
+ a_not_required_uuid = str (self .a_not_required_uuid )
164
+
146
165
attr_1_leading_digit = self .attr_1_leading_digit
147
166
148
167
attr_leading_underscore = self .attr_leading_underscore
@@ -194,6 +213,8 @@ def to_dict(self) -> Dict[str, Any]:
194
213
"aCamelDateTime" : a_camel_date_time ,
195
214
"a_date" : a_date ,
196
215
"a_nullable_date" : a_nullable_date ,
216
+ "a_uuid" : a_uuid ,
217
+ "a_nullable_uuid" : a_nullable_uuid ,
197
218
"required_nullable" : required_nullable ,
198
219
"required_not_nullable" : required_not_nullable ,
199
220
"one_of_models" : one_of_models ,
@@ -210,6 +231,8 @@ def to_dict(self) -> Dict[str, Any]:
210
231
field_dict ["nested_list_of_enums" ] = nested_list_of_enums
211
232
if a_not_required_date is not UNSET :
212
233
field_dict ["a_not_required_date" ] = a_not_required_date
234
+ if a_not_required_uuid is not UNSET :
235
+ field_dict ["a_not_required_uuid" ] = a_not_required_uuid
213
236
if attr_1_leading_digit is not UNSET :
214
237
field_dict ["1_leading_digit" ] = attr_1_leading_digit
215
238
if attr_leading_underscore is not UNSET :
@@ -273,6 +296,23 @@ def _parse_a_nullable_date(data: object) -> Union[None, datetime.date]:
273
296
274
297
a_nullable_date = _parse_a_nullable_date (d .pop ("a_nullable_date" ))
275
298
299
+ a_uuid = UUID (d .pop ("a_uuid" ))
300
+
301
+ def _parse_a_nullable_uuid (data : object ) -> Union [None , UUID ]:
302
+ if data is None :
303
+ return data
304
+ try :
305
+ if not isinstance (data , str ):
306
+ raise TypeError ()
307
+ a_nullable_uuid_type_0 = UUID (data )
308
+
309
+ return a_nullable_uuid_type_0
310
+ except : # noqa: E722
311
+ pass
312
+ return cast (Union [None , UUID ], data )
313
+
314
+ a_nullable_uuid = _parse_a_nullable_uuid (d .pop ("a_nullable_uuid" ))
315
+
276
316
def _parse_required_nullable (data : object ) -> Union [None , str ]:
277
317
if data is None :
278
318
return data
@@ -371,6 +411,13 @@ def _parse_nullable_model(data: object) -> Union["ModelWithUnionProperty", None]
371
411
else :
372
412
a_not_required_date = isoparse (_a_not_required_date ).date ()
373
413
414
+ _a_not_required_uuid = d .pop ("a_not_required_uuid" , UNSET )
415
+ a_not_required_uuid : Union [Unset , UUID ]
416
+ if isinstance (_a_not_required_uuid , Unset ):
417
+ a_not_required_uuid = UNSET
418
+ else :
419
+ a_not_required_uuid = UUID (_a_not_required_uuid )
420
+
374
421
attr_1_leading_digit = d .pop ("1_leading_digit" , UNSET )
375
422
376
423
attr_leading_underscore = d .pop ("_leading_underscore" , UNSET )
@@ -464,6 +511,8 @@ def _parse_not_required_nullable_model(data: object) -> Union["ModelWithUnionPro
464
511
a_camel_date_time = a_camel_date_time ,
465
512
a_date = a_date ,
466
513
a_nullable_date = a_nullable_date ,
514
+ a_uuid = a_uuid ,
515
+ a_nullable_uuid = a_nullable_uuid ,
467
516
required_nullable = required_nullable ,
468
517
required_not_nullable = required_not_nullable ,
469
518
one_of_models = one_of_models ,
@@ -474,6 +523,7 @@ def _parse_not_required_nullable_model(data: object) -> Union["ModelWithUnionPro
474
523
an_optional_allof_enum = an_optional_allof_enum ,
475
524
nested_list_of_enums = nested_list_of_enums ,
476
525
a_not_required_date = a_not_required_date ,
526
+ a_not_required_uuid = a_not_required_uuid ,
477
527
attr_1_leading_digit = attr_1_leading_digit ,
478
528
attr_leading_underscore = attr_leading_underscore ,
479
529
not_required_nullable = not_required_nullable ,
0 commit comments