Skip to content

Commit 15f1284

Browse files
committed
Regen w/ custom template
1 parent 25f758c commit 15f1284

File tree

4 files changed

+65
-4
lines changed

4 files changed

+65
-4
lines changed

end_to_end_tests/golden-record-custom/custom_e2e/api/tests/defaults_tests_defaults_post.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def httpx_request(
7777

7878
json_enum_prop: Union[Unset, AnEnum] = UNSET
7979
if not isinstance(enum_prop, Unset):
80-
json_enum_prop = enum_prop.value
80+
json_enum_prop = enum_prop
8181

8282
params: Dict[str, Any] = {}
8383
if string_prop is not UNSET:

end_to_end_tests/golden-record-custom/custom_e2e/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost
77
from .different_enum import DifferentEnum
88
from .http_validation_error import HTTPValidationError
9+
from .model_with_union_property import ModelWithUnionProperty
910
from .test_inline_objectsjson_body import TestInlineObjectsjsonBody
1011
from .test_inline_objectsresponse_200 import TestInlineObjectsresponse_200
1112
from .validation_error import ValidationError

end_to_end_tests/golden-record-custom/custom_e2e/models/a_model.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,16 @@ def to_dict(self) -> Dict[str, Any]:
7474
def from_dict(d: Dict[str, Any]) -> "AModel":
7575
an_enum_value = AnEnum(d["an_enum_value"])
7676

77-
def _parse_a_camel_date_time(data: Dict[str, Any]) -> Union[datetime.datetime, datetime.date]:
77+
def _parse_a_camel_date_time(data: Any) -> Union[datetime.datetime, datetime.date]:
78+
data = None if isinstance(data, Unset) else data
7879
a_camel_date_time: Union[datetime.datetime, datetime.date]
7980
try:
80-
a_camel_date_time = isoparse(d["aCamelDateTime"])
81+
a_camel_date_time = isoparse(data)
8182

8283
return a_camel_date_time
8384
except: # noqa: E722
8485
pass
85-
a_camel_date_time = isoparse(d["aCamelDateTime"]).date()
86+
a_camel_date_time = isoparse(data).date()
8687

8788
return a_camel_date_time
8889

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
from typing import Any, Dict, Union
2+
3+
import attr
4+
5+
from ..models.an_enum import AnEnum
6+
from ..models.an_int_enum import AnIntEnum
7+
from ..types import UNSET, Unset
8+
9+
10+
@attr.s(auto_attribs=True)
11+
class ModelWithUnionProperty:
12+
""" """
13+
14+
a_property: Union[Unset, AnEnum, AnIntEnum] = UNSET
15+
16+
def to_dict(self) -> Dict[str, Any]:
17+
a_property: Union[Unset, AnEnum, AnIntEnum]
18+
if isinstance(self.a_property, Unset):
19+
a_property = UNSET
20+
elif isinstance(self.a_property, AnEnum):
21+
a_property = UNSET
22+
if not isinstance(self.a_property, Unset):
23+
a_property = self.a_property
24+
25+
else:
26+
a_property = UNSET
27+
if not isinstance(self.a_property, Unset):
28+
a_property = self.a_property
29+
30+
field_dict = {}
31+
if a_property is not UNSET:
32+
field_dict["a_property"] = a_property
33+
34+
return field_dict
35+
36+
@staticmethod
37+
def from_dict(d: Dict[str, Any]) -> "ModelWithUnionProperty":
38+
def _parse_a_property(data: Any) -> Union[Unset, AnEnum, AnIntEnum]:
39+
data = None if isinstance(data, Unset) else data
40+
a_property: Union[Unset, AnEnum, AnIntEnum]
41+
try:
42+
a_property = UNSET
43+
if data is not None:
44+
a_property = AnEnum(data)
45+
46+
return a_property
47+
except: # noqa: E722
48+
pass
49+
a_property = UNSET
50+
if data is not None:
51+
a_property = AnIntEnum(data)
52+
53+
return a_property
54+
55+
a_property = _parse_a_property(d.get("a_property", UNSET))
56+
57+
return ModelWithUnionProperty(
58+
a_property=a_property,
59+
)

0 commit comments

Comments
 (0)