Skip to content

fix: #457 Parameters from PathItem can now be overriden in Operation #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 60 commits into from
Aug 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
8994ec3
Fix: `PathItem` parameters overriding in `Operation`
mtovts Jul 22, 2021
dfc9e5a
Update `templates\endpoint_*` to correct work with parameters
mtovts Jul 22, 2021
1776c89
Update template to correct work with `json_body`
mtovts Jul 22, 2021
abe5144
Update template\endpoint_macros.jinja` to correct work with headers
mtovts Jul 22, 2021
7468e4c
Refactor: Parameters update
mtovts Jul 23, 2021
b1e87e5
Add duplicates parameters check
mtovts Jul 23, 2021
2139e38
code style
mtovts Jul 25, 2021
60cb64f
Refactor: use `str` instead `PythonIdentifier` in parameters dictiona…
mtovts Jul 25, 2021
cc55220
Fix: update unit-tests related with `Endpoint._add_parameters()`
mtovts Jul 25, 2021
2247a9a
Add: `common_parameters_overriding` endpoint to e2e tests
mtovts Jul 25, 2021
86a9f53
Add parameters locations: `header`, `cookie` in `same-name-multiple-l…
mtovts Jul 25, 2021
7e34088
Add generated `common_parameters_overriding` edpoints to e2e tests
mtovts Jul 25, 2021
32e94a1
Update `same_name_multiple_locations_param` generated endpoint in e2e…
mtovts Jul 25, 2021
a4f6458
Update generated endpoints in `common_parameters`: add location postfix
mtovts Jul 25, 2021
38f341b
Update `end_to_end_tests\golden-record\*`
mtovts Jul 26, 2021
3292a38
Update `\test_custom_templates\*_init.py.jinja`
mtovts Jul 26, 2021
84a440a
Update `test__add_parameters_happy`
mtovts Jul 27, 2021
c6bfea2
naming
mtovts Jul 27, 2021
6378616
Delete .PR_note.md
mtovts Jul 27, 2021
4080f89
return: Set parameter identifier `{param.name} _ {param.param_in}` on…
mtovts Jul 30, 2021
237ebb3
Update test related with python identifiers for parameters
mtovts Jul 30, 2021
bbb4928
Revert "Update generated endpoints in `common_parameters`: add locati…
mtovts Jul 30, 2021
d59c555
Revert "Update `end_to_end_tests\golden-record\*`"
mtovts Jul 30, 2021
5f171b3
Return relative imports in e2e tests
mtovts Jul 30, 2021
7990d9a
Return: `"json_" + endpoint.json_body.python_name`
mtovts Jul 30, 2021
2b089a4
fix property `python_name` in parameter overriding
mtovts Jul 31, 2021
8d2344c
remove unused
mtovts Jul 31, 2021
ffdacfd
Merge branch 'main' into fix/overriding-parameters
mtovts Aug 5, 2021
cf9566c
Merge branch 'main' into fix/overriding-parameters
mtovts Aug 7, 2021
cea8189
Update openapi_python_client/templates/endpoint_macros.py.jinja
mtovts Aug 7, 2021
a0db741
Update openapi_python_client/templates/endpoint_macros.py.jinja
mtovts Aug 7, 2021
c465bf3
Update openapi_python_client/templates/endpoint_macros.py.jinja
mtovts Aug 7, 2021
94998d1
Update openapi_python_client/templates/endpoint_macros.py.jinja
mtovts Aug 7, 2021
7b82b4f
Update openapi_python_client/templates/endpoint_module.py.jinja
mtovts Aug 7, 2021
db34f5f
Fix `test_validation_error_when_location_not_supported`
mtovts Aug 7, 2021
4e4ebba
Update openapi_python_client/templates/endpoint_macros.py.jinja
mtovts Aug 7, 2021
55ab74f
Update openapi_python_client/templates/endpoint_macros.py.jinja
mtovts Aug 7, 2021
6029c93
Update openapi_python_client/templates/endpoint_macros.py.jinja
mtovts Aug 7, 2021
9dacd14
Update openapi_python_client/templates/endpoint_macros.py.jinja
mtovts Aug 7, 2021
bc51af2
Update openapi_python_client/templates/endpoint_macros.py.jinja
mtovts Aug 7, 2021
fb4fcf2
Update openapi_python_client/templates/endpoint_macros.py.jinja
mtovts Aug 7, 2021
200bd84
Update openapi_python_client/templates/endpoint_macros.py.jinja
mtovts Aug 7, 2021
035c491
Update openapi_python_client/templates/endpoint_macros.py.jinja
mtovts Aug 7, 2021
d8c7cb3
Update openapi_python_client/templates/endpoint_macros.py.jinja
mtovts Aug 7, 2021
3e7fe11
Fix `end_to_end_tests\openapi.json`
mtovts Aug 9, 2021
b4cfa2e
Add `/same_identifier_conflict/{param}/{param_path}` to `end_to_end_t…
mtovts Aug 9, 2021
08b5491
Lint `tests\test_parser\test_openapi.py`
mtovts Aug 9, 2021
578ddf2
Add `test__add_parameters_with_location_postfix_conflict`
mtovts Aug 9, 2021
0c82680
Add `used_python_identifiers` usage
mtovts Aug 9, 2021
43774dd
Lint the code
mtovts Aug 9, 2021
d4a5cfd
Error message
mtovts Aug 14, 2021
87debe1
Refactor: skip `PathItem` parameter if `Operation` parameter exists
mtovts Aug 14, 2021
95b4fa4
Refactor: simplify logic
mtovts Aug 14, 2021
39ab056
Fix spaces
mtovts Aug 14, 2021
28b824b
Fix tests
mtovts Aug 14, 2021
d78d4b0
make line-length < 120
mtovts Aug 14, 2021
a973637
add test for existing parameter has a conflicting PythonIdentifier af…
mtovts Aug 15, 2021
a471025
Refactor test for PythonIdentifier of new parameter already used
mtovts Aug 15, 2021
294ceb1
Merge branch 'main' into fix/overriding-parameters
mtovts Aug 15, 2021
ca7c30f
refactor: Remove unneeded check
dbanty Aug 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from typing import Type

from my_test_api_client.api.default import DefaultEndpoints
from my_test_api_client.api.parameters import ParametersEndpoints
from my_test_api_client.api.tag1 import Tag1Endpoints
from my_test_api_client.api.tests import TestsEndpoints
from .default import DefaultEndpoints
from .parameters import ParametersEndpoints
from .tag1 import Tag1Endpoints
from .tests import TestsEndpoints


class MyTestApiClientApi:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import types

from my_test_api_client.api.default import get_common_parameters, post_common_parameters
from . import get_common_parameters, post_common_parameters


class DefaultEndpoints:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@

import types

from my_test_api_client.api.parameters import get_same_name_multiple_locations_param
from . import (
delete_common_parameters_overriding_param,
get_common_parameters_overriding_param,
get_same_name_multiple_locations_param,
)


class ParametersEndpoints:
@classmethod
def get_common_parameters_overriding_param(cls) -> types.ModuleType:
return get_common_parameters_overriding_param

@classmethod
def delete_common_parameters_overriding_param(cls) -> types.ModuleType:
return delete_common_parameters_overriding_param

@classmethod
def get_same_name_multiple_locations_param(cls) -> types.ModuleType:
return get_same_name_multiple_locations_param
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import types

from my_test_api_client.api.tag1 import get_tag_with_number
from . import get_tag_with_number


class Tag1Endpoints:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import types

from my_test_api_client.api.tests import (
from . import (
defaults_tests_defaults_post,
get_basic_list_of_booleans,
get_basic_list_of_floats,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
from typing import Any, Dict, Union

import httpx

from ...client import Client
from ...types import UNSET, Response, Unset


def _get_kwargs(
*,
client: Client,
param_path: str,
param_query: Union[Unset, str] = UNSET,
) -> Dict[str, Any]:
url = "{}/common_parameters_overriding/{param}".format(client.base_url, param=param_path)

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

params: Dict[str, Any] = {
"param": param_query,
}
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}

return {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"params": params,
}


def _build_response(*, response: httpx.Response) -> Response[Any]:
return Response(
status_code=response.status_code,
content=response.content,
headers=response.headers,
parsed=None,
)


def sync_detailed(
*,
client: Client,
param_path: str,
param_query: Union[Unset, str] = UNSET,
) -> Response[Any]:
kwargs = _get_kwargs(
client=client,
param_path=param_path,
param_query=param_query,
)

response = httpx.delete(
**kwargs,
)

return _build_response(response=response)


async def asyncio_detailed(
*,
client: Client,
param_path: str,
param_query: Union[Unset, str] = UNSET,
) -> Response[Any]:
kwargs = _get_kwargs(
client=client,
param_path=param_path,
param_query=param_query,
)

async with httpx.AsyncClient() as _client:
response = await _client.delete(**kwargs)

return _build_response(response=response)
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
from typing import Any, Dict

import httpx

from ...client import Client
from ...types import UNSET, Response


def _get_kwargs(
*,
client: Client,
param_path: str,
param_query: str = "overriden_in_GET",
) -> Dict[str, Any]:
url = "{}/common_parameters_overriding/{param}".format(client.base_url, param=param_path)

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

params: Dict[str, Any] = {
"param": param_query,
}
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}

return {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"params": params,
}


def _build_response(*, response: httpx.Response) -> Response[Any]:
return Response(
status_code=response.status_code,
content=response.content,
headers=response.headers,
parsed=None,
)


def sync_detailed(
*,
client: Client,
param_path: str,
param_query: str = "overriden_in_GET",
) -> Response[Any]:
kwargs = _get_kwargs(
client=client,
param_path=param_path,
param_query=param_query,
)

response = httpx.get(
**kwargs,
)

return _build_response(response=response)


async def asyncio_detailed(
*,
client: Client,
param_path: str,
param_query: str = "overriden_in_GET",
) -> Response[Any]:
kwargs = _get_kwargs(
client=client,
param_path=param_path,
param_query=param_query,
)

async with httpx.AsyncClient() as _client:
response = await _client.get(**kwargs)

return _build_response(response=response)
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@
def _get_kwargs(
*,
client: Client,
param_path: Union[Unset, str] = UNSET,
param_path: str,
param_query: Union[Unset, str] = UNSET,
param_header: Union[Unset, str] = UNSET,
param_cookie: Union[Unset, str] = UNSET,
) -> Dict[str, Any]:
url = "{}/same-name-multiple-locations/{param}".format(client.base_url, param=param_path)

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

if param_header is not UNSET:
headers["param"] = param_header

if param_cookie is not UNSET:
cookies["param"] = param_cookie

params: Dict[str, Any] = {
"param": param_query,
}
Expand All @@ -43,13 +51,17 @@ def _build_response(*, response: httpx.Response) -> Response[Any]:
def sync_detailed(
*,
client: Client,
param_path: Union[Unset, str] = UNSET,
param_path: str,
param_query: Union[Unset, str] = UNSET,
param_header: Union[Unset, str] = UNSET,
param_cookie: Union[Unset, str] = UNSET,
) -> Response[Any]:
kwargs = _get_kwargs(
client=client,
param_path=param_path,
param_query=param_query,
param_header=param_header,
param_cookie=param_cookie,
)

response = httpx.get(
Expand All @@ -62,13 +74,17 @@ def sync_detailed(
async def asyncio_detailed(
*,
client: Client,
param_path: Union[Unset, str] = UNSET,
param_path: str,
param_query: Union[Unset, str] = UNSET,
param_header: Union[Unset, str] = UNSET,
param_cookie: Union[Unset, str] = UNSET,
) -> Response[Any]:
kwargs = _get_kwargs(
client=client,
param_path=param_path,
param_query=param_query,
param_header=param_header,
param_cookie=param_cookie,
)

async with httpx.AsyncClient() as _client:
Expand Down
Loading