Skip to content

Commit e087ff0

Browse files
Remove NoneProperty
1 parent 70085ff commit e087ff0

File tree

8 files changed

+140
-47
lines changed

8 files changed

+140
-47
lines changed

end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, Union
1+
from typing import Any, Dict, Optional, Union
22

33
import httpx
44

@@ -30,20 +30,28 @@ def _get_kwargs(
3030
}
3131

3232

33-
def _build_response(*, response: httpx.Response) -> Response[None]:
33+
def _parse_response(*, response: httpx.Response) -> Optional[Any]:
34+
if response.status_code == 200:
35+
response_200 = None
36+
37+
return response_200
38+
return None
39+
40+
41+
def _build_response(*, response: httpx.Response) -> Response[Any]:
3442
return Response(
3543
status_code=response.status_code,
3644
content=response.content,
3745
headers=response.headers,
38-
parsed=None,
46+
parsed=_parse_response(response=response),
3947
)
4048

4149

4250
def sync_detailed(
4351
*,
4452
client: Client,
4553
common: Union[Unset, str] = UNSET,
46-
) -> Response[None]:
54+
) -> Response[Any]:
4755
kwargs = _get_kwargs(
4856
client=client,
4957
common=common,
@@ -56,11 +64,24 @@ def sync_detailed(
5664
return _build_response(response=response)
5765

5866

67+
def sync(
68+
*,
69+
client: Client,
70+
common: Union[Unset, str] = UNSET,
71+
) -> Optional[Any]:
72+
""" """
73+
74+
return sync_detailed(
75+
client=client,
76+
common=common,
77+
).parsed
78+
79+
5980
async def asyncio_detailed(
6081
*,
6182
client: Client,
6283
common: Union[Unset, str] = UNSET,
63-
) -> Response[None]:
84+
) -> Response[Any]:
6485
kwargs = _get_kwargs(
6586
client=client,
6687
common=common,
@@ -70,3 +91,18 @@ async def asyncio_detailed(
7091
response = await _client.get(**kwargs)
7192

7293
return _build_response(response=response)
94+
95+
96+
async def asyncio(
97+
*,
98+
client: Client,
99+
common: Union[Unset, str] = UNSET,
100+
) -> Optional[Any]:
101+
""" """
102+
103+
return (
104+
await asyncio_detailed(
105+
client=client,
106+
common=common,
107+
)
108+
).parsed

end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, Union
1+
from typing import Any, Dict, Optional, Union
22

33
import httpx
44

@@ -30,20 +30,28 @@ def _get_kwargs(
3030
}
3131

3232

33-
def _build_response(*, response: httpx.Response) -> Response[None]:
33+
def _parse_response(*, response: httpx.Response) -> Optional[Any]:
34+
if response.status_code == 200:
35+
response_200 = None
36+
37+
return response_200
38+
return None
39+
40+
41+
def _build_response(*, response: httpx.Response) -> Response[Any]:
3442
return Response(
3543
status_code=response.status_code,
3644
content=response.content,
3745
headers=response.headers,
38-
parsed=None,
46+
parsed=_parse_response(response=response),
3947
)
4048

4149

4250
def sync_detailed(
4351
*,
4452
client: Client,
4553
common: Union[Unset, str] = UNSET,
46-
) -> Response[None]:
54+
) -> Response[Any]:
4755
kwargs = _get_kwargs(
4856
client=client,
4957
common=common,
@@ -56,11 +64,24 @@ def sync_detailed(
5664
return _build_response(response=response)
5765

5866

67+
def sync(
68+
*,
69+
client: Client,
70+
common: Union[Unset, str] = UNSET,
71+
) -> Optional[Any]:
72+
""" """
73+
74+
return sync_detailed(
75+
client=client,
76+
common=common,
77+
).parsed
78+
79+
5980
async def asyncio_detailed(
6081
*,
6182
client: Client,
6283
common: Union[Unset, str] = UNSET,
63-
) -> Response[None]:
84+
) -> Response[Any]:
6485
kwargs = _get_kwargs(
6586
client=client,
6687
common=common,
@@ -70,3 +91,18 @@ async def asyncio_detailed(
7091
response = await _client.post(**kwargs)
7192

7293
return _build_response(response=response)
94+
95+
96+
async def asyncio(
97+
*,
98+
client: Client,
99+
common: Union[Unset, str] = UNSET,
100+
) -> Optional[Any]:
101+
""" """
102+
103+
return (
104+
await asyncio_detailed(
105+
client=client,
106+
common=common,
107+
)
108+
).parsed

end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, Union
1+
from typing import Any, Dict, Optional, Union
22

33
import httpx
44

@@ -31,12 +31,20 @@ def _get_kwargs(
3131
}
3232

3333

34-
def _build_response(*, response: httpx.Response) -> Response[None]:
34+
def _parse_response(*, response: httpx.Response) -> Optional[Any]:
35+
if response.status_code == 200:
36+
response_200 = None
37+
38+
return response_200
39+
return None
40+
41+
42+
def _build_response(*, response: httpx.Response) -> Response[Any]:
3543
return Response(
3644
status_code=response.status_code,
3745
content=response.content,
3846
headers=response.headers,
39-
parsed=None,
47+
parsed=_parse_response(response=response),
4048
)
4149

4250

@@ -45,7 +53,7 @@ def sync_detailed(
4553
client: Client,
4654
param_path: Union[Unset, str] = UNSET,
4755
param_query: Union[Unset, str] = UNSET,
48-
) -> Response[None]:
56+
) -> Response[Any]:
4957
kwargs = _get_kwargs(
5058
client=client,
5159
param_path=param_path,
@@ -59,12 +67,27 @@ def sync_detailed(
5967
return _build_response(response=response)
6068

6169

70+
def sync(
71+
*,
72+
client: Client,
73+
param_path: Union[Unset, str] = UNSET,
74+
param_query: Union[Unset, str] = UNSET,
75+
) -> Optional[Any]:
76+
""" """
77+
78+
return sync_detailed(
79+
client=client,
80+
param_path=param_path,
81+
param_query=param_query,
82+
).parsed
83+
84+
6285
async def asyncio_detailed(
6386
*,
6487
client: Client,
6588
param_path: Union[Unset, str] = UNSET,
6689
param_query: Union[Unset, str] = UNSET,
67-
) -> Response[None]:
90+
) -> Response[Any]:
6891
kwargs = _get_kwargs(
6992
client=client,
7093
param_path=param_path,
@@ -75,3 +98,20 @@ async def asyncio_detailed(
7598
response = await _client.get(**kwargs)
7699

77100
return _build_response(response=response)
101+
102+
103+
async def asyncio(
104+
*,
105+
client: Client,
106+
param_path: Union[Unset, str] = UNSET,
107+
param_query: Union[Unset, str] = UNSET,
108+
) -> Optional[Any]:
109+
""" """
110+
111+
return (
112+
await asyncio_detailed(
113+
client=client,
114+
param_path=param_path,
115+
param_query=param_query,
116+
)
117+
).parsed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, Optional, Union
1+
from typing import Any, Dict, Optional
22

33
import httpx
44

@@ -26,7 +26,7 @@ def _get_kwargs(
2626
}
2727

2828

29-
def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, None]]:
29+
def _parse_response(*, response: httpx.Response) -> Optional[Any]:
3030
if response.status_code == 200:
3131
response_200 = None
3232

@@ -38,7 +38,7 @@ def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, None]]:
3838
return None
3939

4040

41-
def _build_response(*, response: httpx.Response) -> Response[Union[Any, None]]:
41+
def _build_response(*, response: httpx.Response) -> Response[Any]:
4242
return Response(
4343
status_code=response.status_code,
4444
content=response.content,
@@ -51,7 +51,7 @@ def sync_detailed(
5151
*,
5252
client: Client,
5353
my_token: str,
54-
) -> Response[Union[Any, None]]:
54+
) -> Response[Any]:
5555
kwargs = _get_kwargs(
5656
client=client,
5757
my_token=my_token,
@@ -68,7 +68,7 @@ def sync(
6868
*,
6969
client: Client,
7070
my_token: str,
71-
) -> Optional[Union[Any, None]]:
71+
) -> Optional[Any]:
7272
"""Test optional cookie parameters"""
7373

7474
return sync_detailed(
@@ -81,7 +81,7 @@ async def asyncio_detailed(
8181
*,
8282
client: Client,
8383
my_token: str,
84-
) -> Response[Union[Any, None]]:
84+
) -> Response[Any]:
8585
kwargs = _get_kwargs(
8686
client=client,
8787
my_token=my_token,
@@ -97,7 +97,7 @@ async def asyncio(
9797
*,
9898
client: Client,
9999
my_token: str,
100-
) -> Optional[Union[Any, None]]:
100+
) -> Optional[Any]:
101101
"""Test optional cookie parameters"""
102102

103103
return (

openapi_python_client/parser/properties/__init__.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"Class",
44
"EnumProperty",
55
"ModelProperty",
6-
"NoneProperty",
76
"Property",
87
"Schemas",
98
"build_schemas",
@@ -26,15 +25,6 @@
2625
from .schemas import Class, Schemas, parse_reference_path, update_schemas_with_data
2726

2827

29-
@attr.s(auto_attribs=True, frozen=True)
30-
class NoneProperty(Property):
31-
"""A property that is always None"""
32-
33-
_type_string: ClassVar[str] = "None"
34-
_json_type_string: ClassVar[str] = "None"
35-
template: ClassVar[Optional[str]] = "none_property.py.jinja"
36-
37-
3828
@attr.s(auto_attribs=True, frozen=True)
3929
class AnyProperty(Property):
4030
"""A property that can be any type (used for empty schemas)"""

openapi_python_client/parser/responses.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .. import Config
88
from .. import schema as oai
99
from .errors import ParseError, PropertyError
10-
from .properties import NoneProperty, Property, Schemas, property_from_data
10+
from .properties import AnyProperty, Property, Schemas, property_from_data
1111

1212

1313
@attr.s(auto_attribs=True, frozen=True)
@@ -28,10 +28,10 @@ class Response:
2828

2929

3030
def empty_response(status_code: int, response_name: str) -> Response:
31-
"""Return an empty response, for when no response type is defined"""
31+
"""Return an untyped response, for when no response type is defined"""
3232
return Response(
3333
status_code=status_code,
34-
prop=NoneProperty(
34+
prop=AnyProperty(
3535
name=response_name,
3636
default=None,
3737
nullable=False,

openapi_python_client/templates/property_templates/none_property.py.jinja

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/test_parser/test_responses.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import openapi_python_client.schema as oai
44
from openapi_python_client.parser.errors import ParseError, PropertyError
5-
from openapi_python_client.parser.properties import NoneProperty, Schemas, StringProperty
5+
from openapi_python_client.parser.properties import AnyProperty, Schemas, StringProperty
66

77
MODULE_NAME = "openapi_python_client.parser.responses"
88

@@ -20,7 +20,7 @@ def test_response_from_data_no_content():
2020

2121
assert response == Response(
2222
status_code=200,
23-
prop=NoneProperty(name="response_200", default=None, nullable=False, required=True),
23+
prop=AnyProperty(name="response_200", default=None, nullable=False, required=True),
2424
source="None",
2525
)
2626

@@ -46,7 +46,7 @@ def test_response_from_data_no_content_schema():
4646

4747
assert response == Response(
4848
status_code=200,
49-
prop=NoneProperty(name="response_200", default=None, nullable=False, required=True),
49+
prop=AnyProperty(name="response_200", default=None, nullable=False, required=True),
5050
source="None",
5151
)
5252

0 commit comments

Comments
 (0)