|
7 | 7 | Client = httpx.Client |
8 | 8 |
|
9 | 9 | import datetime |
10 | | -from typing import Dict, List, Union |
| 10 | +from typing import Dict, List, Optional, Union |
11 | 11 |
|
12 | 12 | from dateutil.parser import isoparse |
13 | 13 |
|
14 | 14 | from ...models.an_enum import AnEnum |
15 | 15 | from ...models.http_validation_error import HTTPValidationError |
16 | | -from ...models.model_with_union_property import ModelWithUnionProperty |
17 | 16 | from ...types import UNSET, Unset |
18 | 17 |
|
19 | 18 |
|
@@ -41,83 +40,106 @@ def _build_response(*, response: httpx.Response) -> Response[Union[None, HTTPVal |
41 | 40 | def httpx_request( |
42 | 41 | *, |
43 | 42 | client: Client, |
44 | | - string_prop: Union[Unset, str] = "the default string", |
45 | | - datetime_prop: Union[Unset, datetime.datetime] = isoparse("1010-10-10T00:00:00"), |
46 | | - date_prop: Union[Unset, datetime.date] = isoparse("1010-10-10").date(), |
47 | | - float_prop: Union[Unset, float] = 3.14, |
48 | | - int_prop: Union[Unset, int] = 7, |
49 | | - boolean_prop: Union[Unset, bool] = False, |
50 | | - list_prop: Union[Unset, List[AnEnum]] = UNSET, |
51 | | - union_prop: Union[Unset, float, str] = "not a float", |
52 | | - union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6, |
53 | | - enum_prop: Union[Unset, AnEnum] = UNSET, |
54 | | - model_prop: Union[ModelWithUnionProperty, Unset] = UNSET, |
| 43 | + string_prop: Union[Unset, None, str] = "the default string", |
| 44 | + not_required_not_nullable_datetime_prop: Union[Unset, None, datetime.datetime] = isoparse("1010-10-10T00:00:00"), |
| 45 | + not_required_nullable_datetime_prop: Union[Unset, None, datetime.datetime] = isoparse("1010-10-10T00:00:00"), |
| 46 | + required_not_nullable_datetime_prop: datetime.datetime = isoparse("1010-10-10T00:00:00"), |
| 47 | + required_nullable_datetime_prop: Optional[datetime.datetime] = isoparse("1010-10-10T00:00:00"), |
| 48 | + date_prop: Union[Unset, None, datetime.date] = isoparse("1010-10-10").date(), |
| 49 | + float_prop: Union[Unset, None, float] = 3.14, |
| 50 | + int_prop: Union[Unset, None, int] = 7, |
| 51 | + boolean_prop: Union[Unset, None, bool] = False, |
| 52 | + list_prop: Union[Unset, None, List[AnEnum]] = UNSET, |
| 53 | + union_prop: Union[Unset, None, float, str] = "not a float", |
| 54 | + union_prop_with_ref: Union[Unset, None, float, AnEnum] = 0.6, |
| 55 | + enum_prop: Union[Unset, None, AnEnum] = UNSET, |
55 | 56 | ) -> Response[Union[None, HTTPValidationError]]: |
56 | 57 |
|
57 | | - json_datetime_prop: Union[Unset, str] = UNSET |
58 | | - if not isinstance(datetime_prop, Unset): |
59 | | - json_datetime_prop = datetime_prop.isoformat() |
| 58 | + json_not_required_not_nullable_datetime_prop: Union[Unset, None, str] = UNSET |
| 59 | + if not isinstance(not_required_not_nullable_datetime_prop, Unset): |
| 60 | + json_not_required_not_nullable_datetime_prop = ( |
| 61 | + not_required_not_nullable_datetime_prop.isoformat() if not_required_not_nullable_datetime_prop else None |
| 62 | + ) |
60 | 63 |
|
61 | | - json_date_prop: Union[Unset, str] = UNSET |
| 64 | + json_not_required_nullable_datetime_prop: Union[Unset, None, str] = UNSET |
| 65 | + if not isinstance(not_required_nullable_datetime_prop, Unset): |
| 66 | + json_not_required_nullable_datetime_prop = ( |
| 67 | + not_required_nullable_datetime_prop.isoformat() if not_required_nullable_datetime_prop else None |
| 68 | + ) |
| 69 | + |
| 70 | + json_required_not_nullable_datetime_prop = required_not_nullable_datetime_prop.isoformat() |
| 71 | + |
| 72 | + json_required_nullable_datetime_prop = ( |
| 73 | + required_nullable_datetime_prop.isoformat() if required_nullable_datetime_prop else None |
| 74 | + ) |
| 75 | + |
| 76 | + json_date_prop: Union[Unset, None, str] = UNSET |
62 | 77 | if not isinstance(date_prop, Unset): |
63 | | - json_date_prop = date_prop.isoformat() |
| 78 | + json_date_prop = date_prop.isoformat() if date_prop else None |
64 | 79 |
|
65 | | - json_list_prop: Union[Unset, List[Any]] = UNSET |
| 80 | + json_list_prop: Union[Unset, None, List[Any]] = UNSET |
66 | 81 | if not isinstance(list_prop, Unset): |
67 | | - json_list_prop = [] |
68 | | - for list_prop_item_data in list_prop: |
69 | | - list_prop_item = list_prop_item_data.value |
| 82 | + if list_prop is None: |
| 83 | + json_list_prop = None |
| 84 | + else: |
| 85 | + json_list_prop = [] |
| 86 | + for list_prop_item_data in list_prop: |
| 87 | + list_prop_item = list_prop_item_data.value |
70 | 88 |
|
71 | | - json_list_prop.append(list_prop_item) |
| 89 | + json_list_prop.append(list_prop_item) |
72 | 90 |
|
73 | | - json_union_prop: Union[Unset, float, str] |
| 91 | + json_union_prop: Union[Unset, None, float, str] |
74 | 92 | if isinstance(union_prop, Unset): |
75 | 93 | json_union_prop = UNSET |
| 94 | + elif union_prop is None: |
| 95 | + json_union_prop = None |
76 | 96 | else: |
77 | 97 | json_union_prop = union_prop |
78 | 98 |
|
79 | | - json_union_prop_with_ref: Union[Unset, float, AnEnum] |
| 99 | + json_union_prop_with_ref: Union[Unset, None, float, int] |
80 | 100 | if isinstance(union_prop_with_ref, Unset): |
81 | 101 | json_union_prop_with_ref = UNSET |
| 102 | + elif union_prop_with_ref is None: |
| 103 | + json_union_prop_with_ref = None |
82 | 104 | elif isinstance(union_prop_with_ref, AnEnum): |
83 | 105 | json_union_prop_with_ref = UNSET |
84 | 106 | if not isinstance(union_prop_with_ref, Unset): |
85 | | - json_union_prop_with_ref = union_prop_with_ref |
| 107 | + json_union_prop_with_ref = union_prop_with_ref.value |
86 | 108 |
|
87 | 109 | else: |
88 | 110 | json_union_prop_with_ref = union_prop_with_ref |
89 | 111 |
|
90 | | - json_enum_prop: Union[Unset, AnEnum] = UNSET |
| 112 | + json_enum_prop: Union[Unset, None, int] = UNSET |
91 | 113 | if not isinstance(enum_prop, Unset): |
92 | | - json_enum_prop = enum_prop |
93 | | - |
94 | | - json_model_prop: Union[Unset, Dict[str, Any]] = UNSET |
95 | | - if not isinstance(model_prop, Unset): |
96 | | - json_model_prop = model_prop.to_dict() |
| 114 | + json_enum_prop = enum_prop.value if enum_prop else None |
97 | 115 |
|
98 | | - params: Dict[str, Any] = {} |
99 | | - if not isinstance(string_prop, Unset) and string_prop is not None: |
| 116 | + params: Dict[str, Any] = { |
| 117 | + "required_not_nullable_datetime_prop": json_required_not_nullable_datetime_prop, |
| 118 | + } |
| 119 | + if string_prop is not UNSET and string_prop is not None: |
100 | 120 | params["string_prop"] = string_prop |
101 | | - if not isinstance(json_datetime_prop, Unset) and json_datetime_prop is not None: |
102 | | - params["datetime_prop"] = json_datetime_prop |
103 | | - if not isinstance(json_date_prop, Unset) and json_date_prop is not None: |
| 121 | + if not_required_not_nullable_datetime_prop is not UNSET and not_required_not_nullable_datetime_prop is not None: |
| 122 | + params["not_required_not_nullable_datetime_prop"] = json_not_required_not_nullable_datetime_prop |
| 123 | + if not_required_nullable_datetime_prop is not UNSET and not_required_nullable_datetime_prop is not None: |
| 124 | + params["not_required_nullable_datetime_prop"] = json_not_required_nullable_datetime_prop |
| 125 | + if required_nullable_datetime_prop is not None: |
| 126 | + params["required_nullable_datetime_prop"] = json_required_nullable_datetime_prop |
| 127 | + if date_prop is not UNSET and date_prop is not None: |
104 | 128 | params["date_prop"] = json_date_prop |
105 | | - if not isinstance(float_prop, Unset) and float_prop is not None: |
| 129 | + if float_prop is not UNSET and float_prop is not None: |
106 | 130 | params["float_prop"] = float_prop |
107 | | - if not isinstance(int_prop, Unset) and int_prop is not None: |
| 131 | + if int_prop is not UNSET and int_prop is not None: |
108 | 132 | params["int_prop"] = int_prop |
109 | | - if not isinstance(boolean_prop, Unset) and boolean_prop is not None: |
| 133 | + if boolean_prop is not UNSET and boolean_prop is not None: |
110 | 134 | params["boolean_prop"] = boolean_prop |
111 | | - if not isinstance(json_list_prop, Unset) and json_list_prop is not None: |
| 135 | + if list_prop is not UNSET and list_prop is not None: |
112 | 136 | params["list_prop"] = json_list_prop |
113 | | - if not isinstance(json_union_prop, Unset) and json_union_prop is not None: |
| 137 | + if union_prop is not UNSET and union_prop is not None: |
114 | 138 | params["union_prop"] = json_union_prop |
115 | | - if not isinstance(json_union_prop_with_ref, Unset) and json_union_prop_with_ref is not None: |
| 139 | + if union_prop_with_ref is not UNSET and union_prop_with_ref is not None: |
116 | 140 | params["union_prop_with_ref"] = json_union_prop_with_ref |
117 | | - if not isinstance(json_enum_prop, Unset) and json_enum_prop is not None: |
| 141 | + if enum_prop is not UNSET and enum_prop is not None: |
118 | 142 | params["enum_prop"] = json_enum_prop |
119 | | - if not isinstance(json_model_prop, Unset) and json_model_prop is not None: |
120 | | - params.update(json_model_prop) |
121 | 143 |
|
122 | 144 | response = client.request( |
123 | 145 | "post", |
|
0 commit comments