Skip to content

Commit 69301df

Browse files
committed
feat!: Prefer title attributes when naming Python parameters/properties.
Closes #602
1 parent ea9c304 commit 69301df

19 files changed

+385
-141
lines changed

end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/default/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import types
44

5-
from . import get_common_parameters, post_common_parameters
5+
from . import get_common_parameters, get_naming_properties, post_common_parameters
66

77

88
class DefaultEndpoints:
@@ -13,3 +13,7 @@ def get_common_parameters(cls) -> types.ModuleType:
1313
@classmethod
1414
def post_common_parameters(cls) -> types.ModuleType:
1515
return post_common_parameters
16+
17+
@classmethod
18+
def get_naming_properties(cls) -> types.ModuleType:
19+
return get_naming_properties
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
from typing import Any, Dict, Optional
2+
3+
import httpx
4+
5+
from ...client import Client
6+
from ...models.get_naming_properties_response_200 import GetNamingPropertiesResponse200
7+
from ...types import Response
8+
9+
10+
def _get_kwargs(
11+
*,
12+
client: Client,
13+
) -> Dict[str, Any]:
14+
url = "{}/naming/properties".format(client.base_url)
15+
16+
headers: Dict[str, str] = client.get_headers()
17+
cookies: Dict[str, Any] = client.get_cookies()
18+
19+
return {
20+
"method": "get",
21+
"url": url,
22+
"headers": headers,
23+
"cookies": cookies,
24+
"timeout": client.get_timeout(),
25+
}
26+
27+
28+
def _parse_response(*, response: httpx.Response) -> Optional[GetNamingPropertiesResponse200]:
29+
if response.status_code == 200:
30+
response_200 = GetNamingPropertiesResponse200.from_dict(response.json())
31+
32+
return response_200
33+
return None
34+
35+
36+
def _build_response(*, response: httpx.Response) -> Response[GetNamingPropertiesResponse200]:
37+
return Response(
38+
status_code=response.status_code,
39+
content=response.content,
40+
headers=response.headers,
41+
parsed=_parse_response(response=response),
42+
)
43+
44+
45+
def sync_detailed(
46+
*,
47+
client: Client,
48+
) -> Response[GetNamingPropertiesResponse200]:
49+
"""
50+
Returns:
51+
Response[GetNamingPropertiesResponse200]
52+
"""
53+
54+
kwargs = _get_kwargs(
55+
client=client,
56+
)
57+
58+
response = httpx.request(
59+
verify=client.verify_ssl,
60+
**kwargs,
61+
)
62+
63+
return _build_response(response=response)
64+
65+
66+
def sync(
67+
*,
68+
client: Client,
69+
) -> Optional[GetNamingPropertiesResponse200]:
70+
"""
71+
Returns:
72+
Response[GetNamingPropertiesResponse200]
73+
"""
74+
75+
return sync_detailed(
76+
client=client,
77+
).parsed
78+
79+
80+
async def asyncio_detailed(
81+
*,
82+
client: Client,
83+
) -> Response[GetNamingPropertiesResponse200]:
84+
"""
85+
Returns:
86+
Response[GetNamingPropertiesResponse200]
87+
"""
88+
89+
kwargs = _get_kwargs(
90+
client=client,
91+
)
92+
93+
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
94+
response = await _client.request(**kwargs)
95+
96+
return _build_response(response=response)
97+
98+
99+
async def asyncio(
100+
*,
101+
client: Client,
102+
) -> Optional[GetNamingPropertiesResponse200]:
103+
"""
104+
Returns:
105+
Response[GetNamingPropertiesResponse200]
106+
"""
107+
108+
return (
109+
await asyncio_detailed(
110+
client=client,
111+
)
112+
).parsed

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def _get_kwargs(
2626

2727
def _parse_response(*, response: httpx.Response) -> Optional[List[bool]]:
2828
if response.status_code == 200:
29-
response_200 = cast(List[bool], response.json())
29+
response_get_basic_list_of_booleans_tests_basic_lists_booleans_get = cast(List[bool], response.json())
3030

31-
return response_200
31+
return response_get_basic_list_of_booleans_tests_basic_lists_booleans_get
3232
return None
3333

3434

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def _get_kwargs(
2626

2727
def _parse_response(*, response: httpx.Response) -> Optional[List[float]]:
2828
if response.status_code == 200:
29-
response_200 = cast(List[float], response.json())
29+
response_get_basic_list_of_floats_tests_basic_lists_floats_get = cast(List[float], response.json())
3030

31-
return response_200
31+
return response_get_basic_list_of_floats_tests_basic_lists_floats_get
3232
return None
3333

3434

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def _get_kwargs(
2626

2727
def _parse_response(*, response: httpx.Response) -> Optional[List[int]]:
2828
if response.status_code == 200:
29-
response_200 = cast(List[int], response.json())
29+
response_get_basic_list_of_integers_tests_basic_lists_integers_get = cast(List[int], response.json())
3030

31-
return response_200
31+
return response_get_basic_list_of_integers_tests_basic_lists_integers_get
3232
return None
3333

3434

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def _get_kwargs(
2626

2727
def _parse_response(*, response: httpx.Response) -> Optional[List[str]]:
2828
if response.status_code == 200:
29-
response_200 = cast(List[str], response.json())
29+
response_get_basic_list_of_strings_tests_basic_lists_strings_get = cast(List[str], response.json())
3030

31-
return response_200
31+
return response_get_basic_list_of_strings_tests_basic_lists_strings_get
3232
return None
3333

3434

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def _get_kwargs(
1515
*,
1616
client: Client,
1717
an_enum_value: List[AnEnum],
18-
an_enum_value_with_null: List[Optional[AnEnumWithNull]],
19-
an_enum_value_with_only_null: List[None],
18+
an_enum_value_with_null_and_string_values: List[Optional[AnEnumWithNull]],
19+
an_enum_value_with_only_null_values: List[None],
2020
some_date: Union[datetime.date, datetime.datetime],
2121
) -> Dict[str, Any]:
2222
url = "{}/tests/".format(client.base_url)
@@ -33,19 +33,19 @@ def _get_kwargs(
3333

3434
params["an_enum_value"] = json_an_enum_value
3535

36-
json_an_enum_value_with_null = []
37-
for an_enum_value_with_null_item_data in an_enum_value_with_null:
36+
json_an_enum_value_with_null_and_string_values = []
37+
for an_enum_value_with_null_item_data in an_enum_value_with_null_and_string_values:
3838
an_enum_value_with_null_item = (
3939
an_enum_value_with_null_item_data.value if an_enum_value_with_null_item_data else None
4040
)
4141

42-
json_an_enum_value_with_null.append(an_enum_value_with_null_item)
42+
json_an_enum_value_with_null_and_string_values.append(an_enum_value_with_null_item)
4343

44-
params["an_enum_value_with_null"] = json_an_enum_value_with_null
44+
params["an_enum_value_with_null"] = json_an_enum_value_with_null_and_string_values
4545

46-
json_an_enum_value_with_only_null = an_enum_value_with_only_null
46+
json_an_enum_value_with_only_null_values = an_enum_value_with_only_null_values
4747

48-
params["an_enum_value_with_only_null"] = json_an_enum_value_with_only_null
48+
params["an_enum_value_with_only_null"] = json_an_enum_value_with_only_null_values
4949

5050
if isinstance(some_date, datetime.date):
5151
json_some_date = some_date.isoformat()
@@ -68,14 +68,14 @@ def _get_kwargs(
6868

6969
def _parse_response(*, response: httpx.Response) -> Optional[Union[HTTPValidationError, List[AModel]]]:
7070
if response.status_code == 200:
71-
response_200 = []
72-
_response_200 = response.json()
73-
for response_200_item_data in _response_200:
71+
response_get_list_tests_get = []
72+
_response_get_list_tests_get = response.json()
73+
for response_200_item_data in _response_get_list_tests_get:
7474
response_200_item = AModel.from_dict(response_200_item_data)
7575

76-
response_200.append(response_200_item)
76+
response_get_list_tests_get.append(response_200_item)
7777

78-
return response_200
78+
return response_get_list_tests_get
7979
if response.status_code == 422:
8080
response_422 = HTTPValidationError.from_dict(response.json())
8181

@@ -100,8 +100,8 @@ def sync_detailed(
100100
*,
101101
client: Client,
102102
an_enum_value: List[AnEnum],
103-
an_enum_value_with_null: List[Optional[AnEnumWithNull]],
104-
an_enum_value_with_only_null: List[None],
103+
an_enum_value_with_null_and_string_values: List[Optional[AnEnumWithNull]],
104+
an_enum_value_with_only_null_values: List[None],
105105
some_date: Union[datetime.date, datetime.datetime],
106106
) -> Response[Union[HTTPValidationError, List[AModel]]]:
107107
"""Get List
@@ -110,8 +110,8 @@ def sync_detailed(
110110
111111
Args:
112112
an_enum_value (List[AnEnum]):
113-
an_enum_value_with_null (List[Optional[AnEnumWithNull]]):
114-
an_enum_value_with_only_null (List[None]):
113+
an_enum_value_with_null_and_string_values (List[Optional[AnEnumWithNull]]):
114+
an_enum_value_with_only_null_values (List[None]):
115115
some_date (Union[datetime.date, datetime.datetime]):
116116
117117
Returns:
@@ -121,8 +121,8 @@ def sync_detailed(
121121
kwargs = _get_kwargs(
122122
client=client,
123123
an_enum_value=an_enum_value,
124-
an_enum_value_with_null=an_enum_value_with_null,
125-
an_enum_value_with_only_null=an_enum_value_with_only_null,
124+
an_enum_value_with_null_and_string_values=an_enum_value_with_null_and_string_values,
125+
an_enum_value_with_only_null_values=an_enum_value_with_only_null_values,
126126
some_date=some_date,
127127
)
128128

@@ -138,8 +138,8 @@ def sync(
138138
*,
139139
client: Client,
140140
an_enum_value: List[AnEnum],
141-
an_enum_value_with_null: List[Optional[AnEnumWithNull]],
142-
an_enum_value_with_only_null: List[None],
141+
an_enum_value_with_null_and_string_values: List[Optional[AnEnumWithNull]],
142+
an_enum_value_with_only_null_values: List[None],
143143
some_date: Union[datetime.date, datetime.datetime],
144144
) -> Optional[Union[HTTPValidationError, List[AModel]]]:
145145
"""Get List
@@ -148,8 +148,8 @@ def sync(
148148
149149
Args:
150150
an_enum_value (List[AnEnum]):
151-
an_enum_value_with_null (List[Optional[AnEnumWithNull]]):
152-
an_enum_value_with_only_null (List[None]):
151+
an_enum_value_with_null_and_string_values (List[Optional[AnEnumWithNull]]):
152+
an_enum_value_with_only_null_values (List[None]):
153153
some_date (Union[datetime.date, datetime.datetime]):
154154
155155
Returns:
@@ -159,8 +159,8 @@ def sync(
159159
return sync_detailed(
160160
client=client,
161161
an_enum_value=an_enum_value,
162-
an_enum_value_with_null=an_enum_value_with_null,
163-
an_enum_value_with_only_null=an_enum_value_with_only_null,
162+
an_enum_value_with_null_and_string_values=an_enum_value_with_null_and_string_values,
163+
an_enum_value_with_only_null_values=an_enum_value_with_only_null_values,
164164
some_date=some_date,
165165
).parsed
166166

@@ -169,8 +169,8 @@ async def asyncio_detailed(
169169
*,
170170
client: Client,
171171
an_enum_value: List[AnEnum],
172-
an_enum_value_with_null: List[Optional[AnEnumWithNull]],
173-
an_enum_value_with_only_null: List[None],
172+
an_enum_value_with_null_and_string_values: List[Optional[AnEnumWithNull]],
173+
an_enum_value_with_only_null_values: List[None],
174174
some_date: Union[datetime.date, datetime.datetime],
175175
) -> Response[Union[HTTPValidationError, List[AModel]]]:
176176
"""Get List
@@ -179,8 +179,8 @@ async def asyncio_detailed(
179179
180180
Args:
181181
an_enum_value (List[AnEnum]):
182-
an_enum_value_with_null (List[Optional[AnEnumWithNull]]):
183-
an_enum_value_with_only_null (List[None]):
182+
an_enum_value_with_null_and_string_values (List[Optional[AnEnumWithNull]]):
183+
an_enum_value_with_only_null_values (List[None]):
184184
some_date (Union[datetime.date, datetime.datetime]):
185185
186186
Returns:
@@ -190,8 +190,8 @@ async def asyncio_detailed(
190190
kwargs = _get_kwargs(
191191
client=client,
192192
an_enum_value=an_enum_value,
193-
an_enum_value_with_null=an_enum_value_with_null,
194-
an_enum_value_with_only_null=an_enum_value_with_only_null,
193+
an_enum_value_with_null_and_string_values=an_enum_value_with_null_and_string_values,
194+
an_enum_value_with_only_null_values=an_enum_value_with_only_null_values,
195195
some_date=some_date,
196196
)
197197

@@ -205,8 +205,8 @@ async def asyncio(
205205
*,
206206
client: Client,
207207
an_enum_value: List[AnEnum],
208-
an_enum_value_with_null: List[Optional[AnEnumWithNull]],
209-
an_enum_value_with_only_null: List[None],
208+
an_enum_value_with_null_and_string_values: List[Optional[AnEnumWithNull]],
209+
an_enum_value_with_only_null_values: List[None],
210210
some_date: Union[datetime.date, datetime.datetime],
211211
) -> Optional[Union[HTTPValidationError, List[AModel]]]:
212212
"""Get List
@@ -215,8 +215,8 @@ async def asyncio(
215215
216216
Args:
217217
an_enum_value (List[AnEnum]):
218-
an_enum_value_with_null (List[Optional[AnEnumWithNull]]):
219-
an_enum_value_with_only_null (List[None]):
218+
an_enum_value_with_null_and_string_values (List[Optional[AnEnumWithNull]]):
219+
an_enum_value_with_only_null_values (List[None]):
220220
some_date (Union[datetime.date, datetime.datetime]):
221221
222222
Returns:
@@ -227,8 +227,8 @@ async def asyncio(
227227
await asyncio_detailed(
228228
client=client,
229229
an_enum_value=an_enum_value,
230-
an_enum_value_with_null=an_enum_value_with_null,
231-
an_enum_value_with_only_null=an_enum_value_with_only_null,
230+
an_enum_value_with_null_and_string_values=an_enum_value_with_null_and_string_values,
231+
an_enum_value_with_only_null_values=an_enum_value_with_only_null_values,
232232
some_date=some_date,
233233
)
234234
).parsed

0 commit comments

Comments
 (0)