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