Skip to content

Commit 53cdd94

Browse files
authored
fix: Parameters from PathItem can now be overriden in Operation [#458 & #457]. Thanks @mtovts!
1 parent 52eb8d0 commit 53cdd94

File tree

15 files changed

+571
-102
lines changed

15 files changed

+571
-102
lines changed

Diff for: end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
from typing import Type
44

5-
from my_test_api_client.api.default import DefaultEndpoints
6-
from my_test_api_client.api.parameters import ParametersEndpoints
7-
from my_test_api_client.api.tag1 import Tag1Endpoints
8-
from my_test_api_client.api.tests import TestsEndpoints
5+
from .default import DefaultEndpoints
6+
from .parameters import ParametersEndpoints
7+
from .tag1 import Tag1Endpoints
8+
from .tests import TestsEndpoints
99

1010

1111
class MyTestApiClientApi:

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import types
44

5-
from my_test_api_client.api.default import get_common_parameters, post_common_parameters
5+
from . import get_common_parameters, post_common_parameters
66

77

88
class DefaultEndpoints:

Diff for: end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/parameters/__init__.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@
22

33
import types
44

5-
from my_test_api_client.api.parameters import get_same_name_multiple_locations_param
5+
from . import (
6+
delete_common_parameters_overriding_param,
7+
get_common_parameters_overriding_param,
8+
get_same_name_multiple_locations_param,
9+
)
610

711

812
class ParametersEndpoints:
13+
@classmethod
14+
def get_common_parameters_overriding_param(cls) -> types.ModuleType:
15+
return get_common_parameters_overriding_param
16+
17+
@classmethod
18+
def delete_common_parameters_overriding_param(cls) -> types.ModuleType:
19+
return delete_common_parameters_overriding_param
20+
921
@classmethod
1022
def get_same_name_multiple_locations_param(cls) -> types.ModuleType:
1123
return get_same_name_multiple_locations_param

Diff for: end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tag1/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import types
44

5-
from my_test_api_client.api.tag1 import get_tag_with_number
5+
from . import get_tag_with_number
66

77

88
class Tag1Endpoints:

Diff for: end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tests/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import types
44

5-
from my_test_api_client.api.tests import (
5+
from . import (
66
defaults_tests_defaults_post,
77
get_basic_list_of_booleans,
88
get_basic_list_of_floats,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
from typing import Any, Dict, Union
2+
3+
import httpx
4+
5+
from ...client import Client
6+
from ...types import UNSET, Response, Unset
7+
8+
9+
def _get_kwargs(
10+
*,
11+
client: Client,
12+
param_path: str,
13+
param_query: Union[Unset, str] = UNSET,
14+
) -> Dict[str, Any]:
15+
url = "{}/common_parameters_overriding/{param}".format(client.base_url, param=param_path)
16+
17+
headers: Dict[str, Any] = client.get_headers()
18+
cookies: Dict[str, Any] = client.get_cookies()
19+
20+
params: Dict[str, Any] = {
21+
"param": param_query,
22+
}
23+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
24+
25+
return {
26+
"url": url,
27+
"headers": headers,
28+
"cookies": cookies,
29+
"timeout": client.get_timeout(),
30+
"params": params,
31+
}
32+
33+
34+
def _build_response(*, response: httpx.Response) -> Response[Any]:
35+
return Response(
36+
status_code=response.status_code,
37+
content=response.content,
38+
headers=response.headers,
39+
parsed=None,
40+
)
41+
42+
43+
def sync_detailed(
44+
*,
45+
client: Client,
46+
param_path: str,
47+
param_query: Union[Unset, str] = UNSET,
48+
) -> Response[Any]:
49+
kwargs = _get_kwargs(
50+
client=client,
51+
param_path=param_path,
52+
param_query=param_query,
53+
)
54+
55+
response = httpx.delete(
56+
**kwargs,
57+
)
58+
59+
return _build_response(response=response)
60+
61+
62+
async def asyncio_detailed(
63+
*,
64+
client: Client,
65+
param_path: str,
66+
param_query: Union[Unset, str] = UNSET,
67+
) -> Response[Any]:
68+
kwargs = _get_kwargs(
69+
client=client,
70+
param_path=param_path,
71+
param_query=param_query,
72+
)
73+
74+
async with httpx.AsyncClient() as _client:
75+
response = await _client.delete(**kwargs)
76+
77+
return _build_response(response=response)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
from typing import Any, Dict
2+
3+
import httpx
4+
5+
from ...client import Client
6+
from ...types import UNSET, Response
7+
8+
9+
def _get_kwargs(
10+
*,
11+
client: Client,
12+
param_path: str,
13+
param_query: str = "overriden_in_GET",
14+
) -> Dict[str, Any]:
15+
url = "{}/common_parameters_overriding/{param}".format(client.base_url, param=param_path)
16+
17+
headers: Dict[str, Any] = client.get_headers()
18+
cookies: Dict[str, Any] = client.get_cookies()
19+
20+
params: Dict[str, Any] = {
21+
"param": param_query,
22+
}
23+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
24+
25+
return {
26+
"url": url,
27+
"headers": headers,
28+
"cookies": cookies,
29+
"timeout": client.get_timeout(),
30+
"params": params,
31+
}
32+
33+
34+
def _build_response(*, response: httpx.Response) -> Response[Any]:
35+
return Response(
36+
status_code=response.status_code,
37+
content=response.content,
38+
headers=response.headers,
39+
parsed=None,
40+
)
41+
42+
43+
def sync_detailed(
44+
*,
45+
client: Client,
46+
param_path: str,
47+
param_query: str = "overriden_in_GET",
48+
) -> Response[Any]:
49+
kwargs = _get_kwargs(
50+
client=client,
51+
param_path=param_path,
52+
param_query=param_query,
53+
)
54+
55+
response = httpx.get(
56+
**kwargs,
57+
)
58+
59+
return _build_response(response=response)
60+
61+
62+
async def asyncio_detailed(
63+
*,
64+
client: Client,
65+
param_path: str,
66+
param_query: str = "overriden_in_GET",
67+
) -> Response[Any]:
68+
kwargs = _get_kwargs(
69+
client=client,
70+
param_path=param_path,
71+
param_query=param_query,
72+
)
73+
74+
async with httpx.AsyncClient() as _client:
75+
response = await _client.get(**kwargs)
76+
77+
return _build_response(response=response)

Diff for: end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py

+19-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,22 @@
99
def _get_kwargs(
1010
*,
1111
client: Client,
12-
param_path: Union[Unset, str] = UNSET,
12+
param_path: str,
1313
param_query: Union[Unset, str] = UNSET,
14+
param_header: Union[Unset, str] = UNSET,
15+
param_cookie: Union[Unset, str] = UNSET,
1416
) -> Dict[str, Any]:
1517
url = "{}/same-name-multiple-locations/{param}".format(client.base_url, param=param_path)
1618

1719
headers: Dict[str, Any] = client.get_headers()
1820
cookies: Dict[str, Any] = client.get_cookies()
1921

22+
if param_header is not UNSET:
23+
headers["param"] = param_header
24+
25+
if param_cookie is not UNSET:
26+
cookies["param"] = param_cookie
27+
2028
params: Dict[str, Any] = {
2129
"param": param_query,
2230
}
@@ -43,13 +51,17 @@ def _build_response(*, response: httpx.Response) -> Response[Any]:
4351
def sync_detailed(
4452
*,
4553
client: Client,
46-
param_path: Union[Unset, str] = UNSET,
54+
param_path: str,
4755
param_query: Union[Unset, str] = UNSET,
56+
param_header: Union[Unset, str] = UNSET,
57+
param_cookie: Union[Unset, str] = UNSET,
4858
) -> Response[Any]:
4959
kwargs = _get_kwargs(
5060
client=client,
5161
param_path=param_path,
5262
param_query=param_query,
63+
param_header=param_header,
64+
param_cookie=param_cookie,
5365
)
5466

5567
response = httpx.get(
@@ -62,13 +74,17 @@ def sync_detailed(
6274
async def asyncio_detailed(
6375
*,
6476
client: Client,
65-
param_path: Union[Unset, str] = UNSET,
77+
param_path: str,
6678
param_query: Union[Unset, str] = UNSET,
79+
param_header: Union[Unset, str] = UNSET,
80+
param_cookie: Union[Unset, str] = UNSET,
6781
) -> Response[Any]:
6882
kwargs = _get_kwargs(
6983
client=client,
7084
param_path=param_path,
7185
param_query=param_query,
86+
param_header=param_header,
87+
param_cookie=param_cookie,
7288
)
7389

7490
async with httpx.AsyncClient() as _client:

0 commit comments

Comments
 (0)