From 762f02051c4266fd813a01d488c4ce2302390c77 Mon Sep 17 00:00:00 2001 From: v1nvn Date: Thu, 23 Mar 2023 09:20:07 +0530 Subject: [PATCH 1/9] fix: added more exceptions in reserved words --- openapi_python_client/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi_python_client/utils.py b/openapi_python_client/utils.py index c16237533..de1b020d7 100644 --- a/openapi_python_client/utils.py +++ b/openapi_python_client/utils.py @@ -48,7 +48,7 @@ def split_words(value: str) -> List[str]: return re.findall(rf"[^{DELIMITERS}]+", value) -RESERVED_WORDS = (set(dir(builtins)) | {"self", "true", "false", "datetime"}) - {"type", "id"} +RESERVED_WORDS = (set(dir(builtins)) | {"self", "true", "false", "datetime"}) - {"type", "id", "input", "min", "max"} def fix_reserved_words(value: str) -> str: From 39769bcf5ec2010101fddb701ce28221a7a1609a Mon Sep 17 00:00:00 2001 From: v1nvn Date: Thu, 23 Mar 2023 09:48:49 +0530 Subject: [PATCH 2/9] fix: moved generated endpoints from api to root directory --- .../my_test_api_client/api/__init__.py | 46 ------------------- .../{api => }/default/__init__.py | 0 .../{api => }/location/__init__.py | 0 .../parameter_references/__init__.py | 0 .../{api => }/parameters/__init__.py | 0 .../{api => }/responses/__init__.py | 0 .../{api => }/tag1/__init__.py | 0 .../{api => }/tests/__init__.py | 0 .../{api => }/true_/__init__.py | 0 .../my_test_api_client/api/__init__.py | 1 - .../{api => }/default/__init__.py | 0 .../default/get_common_parameters.py | 6 +-- .../default/post_common_parameters.py | 6 +-- .../{api => }/location/__init__.py | 0 .../location/get_location_header_types.py | 10 ++-- .../get_location_query_optionality.py | 6 +-- .../parameter_references/__init__.py | 0 .../get_parameter_references_path_param.py | 6 +-- .../{api => }/parameters/__init__.py | 0 ...lete_common_parameters_overriding_param.py | 6 +-- .../get_common_parameters_overriding_param.py | 6 +-- .../get_same_name_multiple_locations_param.py | 6 +-- .../parameters/multiple_path_parameters.py | 6 +-- .../{api => }/responses/__init__.py | 0 ..._responses_unions_simple_before_complex.py | 8 ++-- .../{api => }/tag1/__init__.py | 0 .../{api => }/tag1/get_tag_with_number.py | 6 +-- .../{api => }/tests/__init__.py | 0 .../{api => }/tests/callback_test.py | 10 ++-- .../tests/defaults_tests_defaults_post.py | 12 ++--- .../tests/description_with_backslash.py | 6 +-- .../tests/get_basic_list_of_booleans.py | 6 +-- .../tests/get_basic_list_of_floats.py | 6 +-- .../tests/get_basic_list_of_integers.py | 6 +-- .../tests/get_basic_list_of_strings.py | 6 +-- .../{api => }/tests/get_user_list.py | 14 +++--- .../tests/int_enum_tests_int_enum_post.py | 10 ++-- .../tests/json_body_tests_json_body_post.py | 10 ++-- .../no_response_tests_no_response_get.py | 6 +-- .../octet_stream_tests_octet_stream_get.py | 6 +-- .../{api => }/tests/post_form_data.py | 8 ++-- .../{api => }/tests/post_form_data_inline.py | 8 ++-- .../tests/post_tests_json_body_string.py | 8 ++-- .../{api => }/tests/test_inline_objects.py | 10 ++-- ..._with_cookie_auth_token_with_cookie_get.py | 6 +-- ...d_content_tests_unsupported_content_get.py | 6 +-- .../tests/upload_file_tests_upload_post.py | 10 ++-- ...upload_multiple_files_tests_upload_post.py | 8 ++-- .../{api => }/true_/__init__.py | 0 .../{api => }/true_/false_.py | 6 +-- end_to_end_tests/test_end_to_end.py | 3 +- openapi_python_client/__init__.py | 7 +-- openapi_python_client/parser/openapi.py | 2 +- .../templates/api_init.py.jinja | 1 - .../templates/endpoint_module.py.jinja | 6 +-- tests/test_parser/test_openapi.py | 6 +-- 56 files changed, 129 insertions(+), 183 deletions(-) delete mode 100644 end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/__init__.py rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{api => }/default/__init__.py (100%) rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{api => }/location/__init__.py (100%) rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{api => }/parameter_references/__init__.py (100%) rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{api => }/parameters/__init__.py (100%) rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{api => }/responses/__init__.py (100%) rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{api => }/tag1/__init__.py (100%) rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{api => }/tests/__init__.py (100%) rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{api => }/true_/__init__.py (100%) delete mode 100644 end_to_end_tests/golden-record/my_test_api_client/api/__init__.py rename end_to_end_tests/golden-record/my_test_api_client/{api => }/default/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/default/get_common_parameters.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/default/post_common_parameters.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/location/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/location/get_location_header_types.py (94%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/location/get_location_query_optionality.py (98%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/parameter_references/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/parameter_references/get_parameter_references_path_param.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/parameters/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/parameters/delete_common_parameters_overriding_param.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/parameters/get_common_parameters_overriding_param.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/parameters/get_same_name_multiple_locations_param.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/parameters/multiple_path_parameters.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/responses/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/responses/post_responses_unions_simple_before_complex.py (95%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tag1/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tag1/get_tag_with_number.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/callback_test.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/defaults_tests_defaults_post.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/description_with_backslash.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/get_basic_list_of_booleans.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/get_basic_list_of_floats.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/get_basic_list_of_integers.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/get_basic_list_of_strings.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/get_user_list.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/int_enum_tests_int_enum_post.py (95%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/json_body_tests_json_body_post.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/no_response_tests_no_response_get.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/octet_stream_tests_octet_stream_get.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/post_form_data.py (95%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/post_form_data_inline.py (94%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/post_tests_json_body_string.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/test_inline_objects.py (94%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/token_with_cookie_auth_token_with_cookie_get.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/unsupported_content_tests_unsupported_content_get.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/upload_file_tests_upload_post.py (95%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/tests/upload_multiple_files_tests_upload_post.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/true_/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{api => }/true_/false_.py (96%) delete mode 100644 openapi_python_client/templates/api_init.py.jinja diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/__init__.py deleted file mode 100644 index 15e304e77..000000000 --- a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -""" Contains methods for accessing the API """ - -from typing import Type - -from .default import DefaultEndpoints -from .location import LocationEndpoints -from .parameter_references import ParameterReferencesEndpoints -from .parameters import ParametersEndpoints -from .responses import ResponsesEndpoints -from .tag1 import Tag1Endpoints -from .tests import TestsEndpoints -from .true_ import True_Endpoints - - -class MyTestApiClientApi: - @classmethod - def tests(cls) -> Type[TestsEndpoints]: - return TestsEndpoints - - @classmethod - def responses(cls) -> Type[ResponsesEndpoints]: - return ResponsesEndpoints - - @classmethod - def default(cls) -> Type[DefaultEndpoints]: - return DefaultEndpoints - - @classmethod - def parameters(cls) -> Type[ParametersEndpoints]: - return ParametersEndpoints - - @classmethod - def tag1(cls) -> Type[Tag1Endpoints]: - return Tag1Endpoints - - @classmethod - def location(cls) -> Type[LocationEndpoints]: - return LocationEndpoints - - @classmethod - def true_(cls) -> Type[True_Endpoints]: - return True_Endpoints - - @classmethod - def parameter_references(cls) -> Type[ParameterReferencesEndpoints]: - return ParameterReferencesEndpoints diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/default/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/default/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/default/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/default/__init__.py diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/location/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/location/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/location/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/location/__init__.py diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/parameter_references/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/parameter_references/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/parameter_references/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/parameter_references/__init__.py diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/parameters/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/parameters/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/parameters/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/parameters/__init__.py diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/responses/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/responses/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/responses/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/responses/__init__.py diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tag1/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/tag1/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tag1/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/tag1/__init__.py diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tests/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/tests/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tests/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/tests/__init__.py diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/true_/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/true_/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/true_/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/true_/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/__init__.py deleted file mode 100644 index dc035f4ce..000000000 --- a/end_to_end_tests/golden-record/my_test_api_client/api/__init__.py +++ /dev/null @@ -1 +0,0 @@ -""" Contains methods for accessing the API """ diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/default/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/api/default/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/default/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/default/get_common_parameters.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py rename to end_to_end_tests/golden-record/my_test_api_client/default/get_common_parameters.py index a2478b80d..b116d4717 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/default/get_common_parameters.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import UNSET, Response, Unset +from .. import errors +from ..client import Client +from ..types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/default/post_common_parameters.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py rename to end_to_end_tests/golden-record/my_test_api_client/default/post_common_parameters.py index 99e7f21d7..33d40aa80 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/default/post_common_parameters.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import UNSET, Response, Unset +from .. import errors +from ..client import Client +from ..types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/location/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/api/location/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/location/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py b/end_to_end_tests/golden-record/my_test_api_client/location/get_location_header_types.py similarity index 94% rename from end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py rename to end_to_end_tests/golden-record/my_test_api_client/location/get_location_header_types.py index 9249eab31..766ee4604 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py +++ b/end_to_end_tests/golden-record/my_test_api_client/location/get_location_header_types.py @@ -3,11 +3,11 @@ import httpx -from ... import errors -from ...client import Client -from ...models.get_location_header_types_int_enum_header import GetLocationHeaderTypesIntEnumHeader -from ...models.get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader -from ...types import UNSET, Response, Unset +from .. import errors +from ..client import Client +from ..models.get_location_header_types_int_enum_header import GetLocationHeaderTypesIntEnumHeader +from ..models.get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader +from ..types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py b/end_to_end_tests/golden-record/my_test_api_client/location/get_location_query_optionality.py similarity index 98% rename from end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py rename to end_to_end_tests/golden-record/my_test_api_client/location/get_location_query_optionality.py index 0209c7319..524e49a3b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py +++ b/end_to_end_tests/golden-record/my_test_api_client/location/get_location_query_optionality.py @@ -4,9 +4,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import UNSET, Response, Unset +from .. import errors +from ..client import Client +from ..types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/parameter_references/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/parameter_references/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py b/end_to_end_tests/golden-record/my_test_api_client/parameter_references/get_parameter_references_path_param.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py rename to end_to_end_tests/golden-record/my_test_api_client/parameter_references/get_parameter_references_path_param.py index b8c33ec94..f3e505216 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/parameter_references/get_parameter_references_path_param.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import UNSET, Response, Unset +from .. import errors +from ..client import Client +from ..types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/parameters/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/api/parameters/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/parameters/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/parameters/delete_common_parameters_overriding_param.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py rename to end_to_end_tests/golden-record/my_test_api_client/parameters/delete_common_parameters_overriding_param.py index 2816ec304..d7c282eb7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/parameters/delete_common_parameters_overriding_param.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import UNSET, Response, Unset +from .. import errors +from ..client import Client +from ..types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/parameters/get_common_parameters_overriding_param.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py rename to end_to_end_tests/golden-record/my_test_api_client/parameters/get_common_parameters_overriding_param.py index f1d97abc5..bbf4279cc 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/parameters/get_common_parameters_overriding_param.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import UNSET, Response +from .. import errors +from ..client import Client +from ..types import UNSET, Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py b/end_to_end_tests/golden-record/my_test_api_client/parameters/get_same_name_multiple_locations_param.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py rename to end_to_end_tests/golden-record/my_test_api_client/parameters/get_same_name_multiple_locations_param.py index ee9c35016..6198a5c01 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/parameters/get_same_name_multiple_locations_param.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import UNSET, Response, Unset +from .. import errors +from ..client import Client +from ..types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/parameters/multiple_path_parameters.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py rename to end_to_end_tests/golden-record/my_test_api_client/parameters/multiple_path_parameters.py index 347aa36b4..2928637a4 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/parameters/multiple_path_parameters.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import Response +from .. import errors +from ..client import Client +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/responses/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/api/responses/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/responses/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py b/end_to_end_tests/golden-record/my_test_api_client/responses/post_responses_unions_simple_before_complex.py similarity index 95% rename from end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py rename to end_to_end_tests/golden-record/my_test_api_client/responses/post_responses_unions_simple_before_complex.py index 9e43e738a..6f79e7575 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py +++ b/end_to_end_tests/golden-record/my_test_api_client/responses/post_responses_unions_simple_before_complex.py @@ -3,12 +3,12 @@ import httpx -from ... import errors -from ...client import Client -from ...models.post_responses_unions_simple_before_complex_response_200 import ( +from .. import errors +from ..client import Client +from ..models.post_responses_unions_simple_before_complex_response_200 import ( PostResponsesUnionsSimpleBeforeComplexResponse200, ) -from ...types import Response +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/tag1/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/api/tag1/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/tag1/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py b/end_to_end_tests/golden-record/my_test_api_client/tag1/get_tag_with_number.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py rename to end_to_end_tests/golden-record/my_test_api_client/tag1/get_tag_with_number.py index 05f976082..1854e1e30 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tag1/get_tag_with_number.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import Response +from .. import errors +from ..client import Client +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/tests/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py b/end_to_end_tests/golden-record/my_test_api_client/tests/callback_test.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/callback_test.py index c68e64be7..3c6991db7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/callback_test.py @@ -3,11 +3,11 @@ import httpx -from ... import errors -from ...client import Client -from ...models.a_model import AModel -from ...models.http_validation_error import HTTPValidationError -from ...types import Response +from .. import errors +from ..client import Client +from ..models.a_model import AModel +from ..models.http_validation_error import HTTPValidationError +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py b/end_to_end_tests/golden-record/my_test_api_client/tests/defaults_tests_defaults_post.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/defaults_tests_defaults_post.py index 1e1e4beb1..95abefb47 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/defaults_tests_defaults_post.py @@ -5,12 +5,12 @@ import httpx from dateutil.parser import isoparse -from ... import errors -from ...client import Client -from ...models.an_enum import AnEnum -from ...models.http_validation_error import HTTPValidationError -from ...models.model_with_union_property import ModelWithUnionProperty -from ...types import UNSET, Response, Unset +from .. import errors +from ..client import Client +from ..models.an_enum import AnEnum +from ..models.http_validation_error import HTTPValidationError +from ..models.model_with_union_property import ModelWithUnionProperty +from ..types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py b/end_to_end_tests/golden-record/my_test_api_client/tests/description_with_backslash.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/description_with_backslash.py index 31923ad11..dfce5c7df 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/description_with_backslash.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import Response +from .. import errors +from ..client import Client +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py b/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_booleans.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_booleans.py index f36aa9a9a..160c5c329 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_booleans.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import Response +from .. import errors +from ..client import Client +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py b/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_floats.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_floats.py index cfc9fec4d..7a80038dc 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_floats.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import Response +from .. import errors +from ..client import Client +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py b/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_integers.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_integers.py index ab31821b5..78ae594a9 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_integers.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import Response +from .. import errors +from ..client import Client +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py b/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_strings.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_strings.py index 4c62d518b..4a3889e5d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_strings.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import Response +from .. import errors +from ..client import Client +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py b/end_to_end_tests/golden-record/my_test_api_client/tests/get_user_list.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/get_user_list.py index cf0c1c375..883356a76 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/get_user_list.py @@ -4,13 +4,13 @@ import httpx -from ... import errors -from ...client import Client -from ...models.a_model import AModel -from ...models.an_enum import AnEnum -from ...models.an_enum_with_null import AnEnumWithNull -from ...models.http_validation_error import HTTPValidationError -from ...types import UNSET, Response +from .. import errors +from ..client import Client +from ..models.a_model import AModel +from ..models.an_enum import AnEnum +from ..models.an_enum_with_null import AnEnumWithNull +from ..models.http_validation_error import HTTPValidationError +from ..types import UNSET, Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py b/end_to_end_tests/golden-record/my_test_api_client/tests/int_enum_tests_int_enum_post.py similarity index 95% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/int_enum_tests_int_enum_post.py index d6777f84c..483928158 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/int_enum_tests_int_enum_post.py @@ -3,11 +3,11 @@ import httpx -from ... import errors -from ...client import Client -from ...models.an_int_enum import AnIntEnum -from ...models.http_validation_error import HTTPValidationError -from ...types import UNSET, Response +from .. import errors +from ..client import Client +from ..models.an_int_enum import AnIntEnum +from ..models.http_validation_error import HTTPValidationError +from ..types import UNSET, Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py b/end_to_end_tests/golden-record/my_test_api_client/tests/json_body_tests_json_body_post.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/json_body_tests_json_body_post.py index d977511d4..15d937055 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/json_body_tests_json_body_post.py @@ -3,11 +3,11 @@ import httpx -from ... import errors -from ...client import Client -from ...models.a_model import AModel -from ...models.http_validation_error import HTTPValidationError -from ...types import Response +from .. import errors +from ..client import Client +from ..models.a_model import AModel +from ..models.http_validation_error import HTTPValidationError +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py b/end_to_end_tests/golden-record/my_test_api_client/tests/no_response_tests_no_response_get.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/no_response_tests_no_response_get.py index 075452512..dee0d50b2 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/no_response_tests_no_response_get.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import Response +from .. import errors +from ..client import Client +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py b/end_to_end_tests/golden-record/my_test_api_client/tests/octet_stream_tests_octet_stream_get.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/octet_stream_tests_octet_stream_get.py index a10ad95a7..3d7169156 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/octet_stream_tests_octet_stream_get.py @@ -4,9 +4,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import File, Response +from .. import errors +from ..client import Client +from ..types import File, Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py b/end_to_end_tests/golden-record/my_test_api_client/tests/post_form_data.py similarity index 95% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/post_form_data.py index 07c0b225e..0ccf91def 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/post_form_data.py @@ -3,10 +3,10 @@ import httpx -from ... import errors -from ...client import Client -from ...models.a_form_data import AFormData -from ...types import Response +from .. import errors +from ..client import Client +from ..models.a_form_data import AFormData +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py b/end_to_end_tests/golden-record/my_test_api_client/tests/post_form_data_inline.py similarity index 94% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/post_form_data_inline.py index e93a22986..6a14c8a0f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/post_form_data_inline.py @@ -3,10 +3,10 @@ import httpx -from ... import errors -from ...client import Client -from ...models.post_form_data_inline_data import PostFormDataInlineData -from ...types import Response +from .. import errors +from ..client import Client +from ..models.post_form_data_inline_data import PostFormDataInlineData +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py b/end_to_end_tests/golden-record/my_test_api_client/tests/post_tests_json_body_string.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/post_tests_json_body_string.py index 7bd2c3b16..ba458b5a9 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/post_tests_json_body_string.py @@ -3,10 +3,10 @@ import httpx -from ... import errors -from ...client import Client -from ...models.http_validation_error import HTTPValidationError -from ...types import Response +from .. import errors +from ..client import Client +from ..models.http_validation_error import HTTPValidationError +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py b/end_to_end_tests/golden-record/my_test_api_client/tests/test_inline_objects.py similarity index 94% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/test_inline_objects.py index 7e3baf769..06f697e43 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/test_inline_objects.py @@ -3,11 +3,11 @@ import httpx -from ... import errors -from ...client import Client -from ...models.test_inline_objects_json_body import TestInlineObjectsJsonBody -from ...models.test_inline_objects_response_200 import TestInlineObjectsResponse200 -from ...types import Response +from .. import errors +from ..client import Client +from ..models.test_inline_objects_json_body import TestInlineObjectsJsonBody +from ..models.test_inline_objects_response_200 import TestInlineObjectsResponse200 +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py b/end_to_end_tests/golden-record/my_test_api_client/tests/token_with_cookie_auth_token_with_cookie_get.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/token_with_cookie_auth_token_with_cookie_get.py index 994f1ee4e..3a58175cc 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/token_with_cookie_auth_token_with_cookie_get.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import Response +from .. import errors +from ..client import Client +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py b/end_to_end_tests/golden-record/my_test_api_client/tests/unsupported_content_tests_unsupported_content_get.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/unsupported_content_tests_unsupported_content_get.py index 6b719cb38..d16bbc9c0 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/unsupported_content_tests_unsupported_content_get.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import Response +from .. import errors +from ..client import Client +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/tests/upload_file_tests_upload_post.py similarity index 95% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/upload_file_tests_upload_post.py index 8a49818fb..0ce0268f2 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/upload_file_tests_upload_post.py @@ -3,11 +3,11 @@ import httpx -from ... import errors -from ...client import Client -from ...models.body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost -from ...models.http_validation_error import HTTPValidationError -from ...types import Response +from .. import errors +from ..client import Client +from ..models.body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost +from ..models.http_validation_error import HTTPValidationError +from ..types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/tests/upload_multiple_files_tests_upload_post.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py rename to end_to_end_tests/golden-record/my_test_api_client/tests/upload_multiple_files_tests_upload_post.py index ff5d5132d..f37d3af5f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/tests/upload_multiple_files_tests_upload_post.py @@ -3,10 +3,10 @@ import httpx -from ... import errors -from ...client import Client -from ...models.http_validation_error import HTTPValidationError -from ...types import File, Response +from .. import errors +from ..client import Client +from ..models.http_validation_error import HTTPValidationError +from ..types import File, Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/true_/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/true_/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/api/true_/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/true_/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py b/end_to_end_tests/golden-record/my_test_api_client/true_/false_.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py rename to end_to_end_tests/golden-record/my_test_api_client/true_/false_.py index 05967d439..930856e9a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py +++ b/end_to_end_tests/golden-record/my_test_api_client/true_/false_.py @@ -3,9 +3,9 @@ import httpx -from ... import errors -from ...client import Client -from ...types import UNSET, Response +from .. import errors +from ..client import Client +from ..types import UNSET, Response def _get_kwargs( diff --git a/end_to_end_tests/test_end_to_end.py b/end_to_end_tests/test_end_to_end.py index 6ad49fcb9..312e6c5e3 100644 --- a/end_to_end_tests/test_end_to_end.py +++ b/end_to_end_tests/test_end_to_end.py @@ -92,12 +92,11 @@ def test_end_to_end(): def test_custom_templates(): expected_differences = {} # key: path relative to generated directory, value: expected generated content - api_dir = Path("my_test_api_client").joinpath("api") + api_dir = Path("my_test_api_client") golden_tpls_root_dir = Path(__file__).parent.joinpath("custom-templates-golden-record") expected_difference_paths = [ Path("README.md"), - api_dir.joinpath("__init__.py"), ] for expected_difference_path in expected_difference_paths: diff --git a/openapi_python_client/__init__.py b/openapi_python_client/__init__.py index 109ce84c7..b4edd5415 100644 --- a/openapi_python_client/__init__.py +++ b/openapi_python_client/__init__.py @@ -271,12 +271,7 @@ def _build_api(self) -> None: errors_path.write_text(errors_template.render(), encoding=self.file_encoding) # Generate endpoints - api_dir = self.package_dir / "api" - api_dir.mkdir() - api_init_path = api_dir / "__init__.py" - api_init_template = self.env.get_template("api_init.py.jinja") - api_init_path.write_text(api_init_template.render(), encoding=self.file_encoding) - + api_dir = self.package_dir endpoint_collections_by_tag = self.openapi.endpoint_collections_by_tag endpoint_template = self.env.get_template( "endpoint_module.py.jinja", globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"} diff --git a/openapi_python_client/parser/openapi.py b/openapi_python_client/parser/openapi.py index b7c4a8142..d222af1ad 100644 --- a/openapi_python_client/parser/openapi.py +++ b/openapi_python_client/parser/openapi.py @@ -99,7 +99,7 @@ def generate_operation_id(*, path: str, method: str) -> str: return f"{method}_{clean_path}" -models_relative_prefix: str = "..." +models_relative_prefix: str = ".." # pylint: disable=too-many-instance-attributes diff --git a/openapi_python_client/templates/api_init.py.jinja b/openapi_python_client/templates/api_init.py.jinja deleted file mode 100644 index dc035f4ce..000000000 --- a/openapi_python_client/templates/api_init.py.jinja +++ /dev/null @@ -1 +0,0 @@ -""" Contains methods for accessing the API """ diff --git a/openapi_python_client/templates/endpoint_module.py.jinja b/openapi_python_client/templates/endpoint_module.py.jinja index 3ea8991fb..6c169bac7 100644 --- a/openapi_python_client/templates/endpoint_module.py.jinja +++ b/openapi_python_client/templates/endpoint_module.py.jinja @@ -3,9 +3,9 @@ from typing import Any, Dict, List, Optional, Union, cast import httpx -from ...client import AuthenticatedClient, Client -from ...types import Response, UNSET -from ... import errors +from ..client import AuthenticatedClient, Client +from ..types import Response, UNSET +from .. import errors {% for relative in endpoint.relative_imports %} {{ relative }} diff --git a/tests/test_parser/test_openapi.py b/tests/test_parser/test_openapi.py index 9cc7398d9..ecee5167f 100644 --- a/tests/test_parser/test_openapi.py +++ b/tests/test_parser/test_openapi.py @@ -421,9 +421,9 @@ def test_add_body_happy(self, mocker): parse_multipart_body.assert_called_once_with( body=request_body, schemas=json_schemas, parent_name="name", config=config ) - form_body.get_imports.assert_called_once_with(prefix="...") - json_body.get_imports.assert_called_once_with(prefix="...") - multipart_body.get_imports.assert_called_once_with(prefix="...") + form_body.get_imports.assert_called_once_with(prefix="..") + json_body.get_imports.assert_called_once_with(prefix="..") + multipart_body.get_imports.assert_called_once_with(prefix="..") assert endpoint.relative_imports == {"import_3", form_body_imports, json_body_imports, multipart_body_imports} assert endpoint.json_body == json_body assert endpoint.form_body == form_body From 73cae06f777fc2de130b6035945982c481365ca5 Mon Sep 17 00:00:00 2001 From: v1nvn Date: Thu, 23 Mar 2023 19:28:53 +0530 Subject: [PATCH 3/9] feat: added simple dict property --- .../my_test_api_client/models/a_form_data.py | 8 +++ .../models/free_form_model.py | 19 +++++-- .../my_test_api_client/models/import_.py | 19 +++++-- .../my_test_api_client/models/model_name.py | 19 +++++-- .../models/model_reference_with_periods.py | 20 +++++-- .../model_with_backslash_in_description.py | 16 +++++- .../my_test_api_client/models/none.py | 19 +++++-- ...ple_before_complex_response_200a_type_1.py | 19 +++++-- end_to_end_tests/openapi.json | 54 ++++++++++++++++--- .../parser/properties/__init__.py | 19 +++++++ tests/conftest.py | 14 +++++ .../test_parser/test_properties/test_init.py | 48 +++++------------ .../test_properties/test_model_property.py | 3 +- 13 files changed, 213 insertions(+), 64 deletions(-) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/a_form_data.py b/end_to_end_tests/golden-record/my_test_api_client/models/a_form_data.py index 958b24ab5..b3606f842 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/a_form_data.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/a_form_data.py @@ -13,15 +13,18 @@ class AFormData: Attributes: an_required_field (str): an_optional_field (Union[Unset, str]): + a_simple_dict (Union[Unset, Dict[str, Any]]): """ an_required_field: str an_optional_field: Union[Unset, str] = UNSET + a_simple_dict: Union[Unset, Dict[str, Any]] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: an_required_field = self.an_required_field an_optional_field = self.an_optional_field + a_simple_dict = self.a_simple_dict field_dict: Dict[str, Any] = {} field_dict.update(self.additional_properties) @@ -32,6 +35,8 @@ def to_dict(self) -> Dict[str, Any]: ) if an_optional_field is not UNSET: field_dict["an_optional_field"] = an_optional_field + if a_simple_dict is not UNSET: + field_dict["a_simple_dict"] = a_simple_dict return field_dict @@ -42,9 +47,12 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: an_optional_field = d.pop("an_optional_field", UNSET) + a_simple_dict = d.pop("a_simple_dict", UNSET) + a_form_data = cls( an_required_field=an_required_field, an_optional_field=an_optional_field, + a_simple_dict=a_simple_dict, ) a_form_data.additional_properties = d diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/free_form_model.py b/end_to_end_tests/golden-record/my_test_api_client/models/free_form_model.py index f8cc2151c..bb86c4bcc 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/free_form_model.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/free_form_model.py @@ -1,28 +1,41 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, Dict, List, Type, TypeVar, Union import attr +from ..types import UNSET, Unset + T = TypeVar("T", bound="FreeFormModel") @attr.s(auto_attribs=True) class FreeFormModel: - """ """ + """ + Attributes: + prop (Union[Unset, str]): + """ + prop: Union[Unset, str] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: + prop = self.prop field_dict: Dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) + if prop is not UNSET: + field_dict["prop"] = prop return field_dict @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() - free_form_model = cls() + prop = d.pop("prop", UNSET) + + free_form_model = cls( + prop=prop, + ) free_form_model.additional_properties = d return free_form_model diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/import_.py b/end_to_end_tests/golden-record/my_test_api_client/models/import_.py index 276a4f21b..d7ea6a1ec 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/import_.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/import_.py @@ -1,28 +1,41 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, Dict, List, Type, TypeVar, Union import attr +from ..types import UNSET, Unset + T = TypeVar("T", bound="Import") @attr.s(auto_attribs=True) class Import: - """ """ + """ + Attributes: + prop (Union[Unset, str]): + """ + prop: Union[Unset, str] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: + prop = self.prop field_dict: Dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) + if prop is not UNSET: + field_dict["prop"] = prop return field_dict @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() - import_ = cls() + prop = d.pop("prop", UNSET) + + import_ = cls( + prop=prop, + ) import_.additional_properties = d return import_ diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_name.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_name.py index c87d4c208..f7df40af5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_name.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_name.py @@ -1,28 +1,41 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, Dict, List, Type, TypeVar, Union import attr +from ..types import UNSET, Unset + T = TypeVar("T", bound="ModelName") @attr.s(auto_attribs=True) class ModelName: - """ """ + """ + Attributes: + prop (Union[Unset, str]): + """ + prop: Union[Unset, str] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: + prop = self.prop field_dict: Dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) + if prop is not UNSET: + field_dict["prop"] = prop return field_dict @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() - model_name = cls() + prop = d.pop("prop", UNSET) + + model_name = cls( + prop=prop, + ) model_name.additional_properties = d return model_name diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_reference_with_periods.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_reference_with_periods.py index 15bab8de5..41786141c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_reference_with_periods.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_reference_with_periods.py @@ -1,28 +1,42 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, Dict, List, Type, TypeVar, Union import attr +from ..types import UNSET, Unset + T = TypeVar("T", bound="ModelReferenceWithPeriods") @attr.s(auto_attribs=True) class ModelReferenceWithPeriods: - """A Model with periods in its reference""" + """A Model with periods in its reference + + Attributes: + prop (Union[Unset, str]): + """ + prop: Union[Unset, str] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: + prop = self.prop field_dict: Dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) + if prop is not UNSET: + field_dict["prop"] = prop return field_dict @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() - model_reference_with_periods = cls() + prop = d.pop("prop", UNSET) + + model_reference_with_periods = cls( + prop=prop, + ) model_reference_with_periods.additional_properties = d return model_reference_with_periods diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_backslash_in_description.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_backslash_in_description.py index d52952236..b2d434021 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_backslash_in_description.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_backslash_in_description.py @@ -1,7 +1,9 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, Dict, List, Type, TypeVar, Union import attr +from ..types import UNSET, Unset + T = TypeVar("T", bound="ModelWithBackslashInDescription") @@ -9,22 +11,32 @@ class ModelWithBackslashInDescription: r""" Description with special character: \ + Attributes: + prop (Union[Unset, str]): """ + prop: Union[Unset, str] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: + prop = self.prop field_dict: Dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) + if prop is not UNSET: + field_dict["prop"] = prop return field_dict @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() - model_with_backslash_in_description = cls() + prop = d.pop("prop", UNSET) + + model_with_backslash_in_description = cls( + prop=prop, + ) model_with_backslash_in_description.additional_properties = d return model_with_backslash_in_description diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/none.py b/end_to_end_tests/golden-record/my_test_api_client/models/none.py index e1722f094..4eb1314a7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/none.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/none.py @@ -1,28 +1,41 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, Dict, List, Type, TypeVar, Union import attr +from ..types import UNSET, Unset + T = TypeVar("T", bound="None_") @attr.s(auto_attribs=True) class None_: - """ """ + """ + Attributes: + prop (Union[Unset, str]): + """ + prop: Union[Unset, str] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: + prop = self.prop field_dict: Dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) + if prop is not UNSET: + field_dict["prop"] = prop return field_dict @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() - none = cls() + prop = d.pop("prop", UNSET) + + none = cls( + prop=prop, + ) none.additional_properties = d return none diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py b/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py index 6b9ae2484..90c0c7db8 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py @@ -1,28 +1,41 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, Dict, List, Type, TypeVar, Union import attr +from ..types import UNSET, Unset + T = TypeVar("T", bound="PostResponsesUnionsSimpleBeforeComplexResponse200AType1") @attr.s(auto_attribs=True) class PostResponsesUnionsSimpleBeforeComplexResponse200AType1: - """ """ + """ + Attributes: + prop (Union[Unset, str]): + """ + prop: Union[Unset, str] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: + prop = self.prop field_dict: Dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) + if prop is not UNSET: + field_dict["prop"] = prop return field_dict @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() - post_responses_unions_simple_before_complex_response_200a_type_1 = cls() + prop = d.pop("prop", UNSET) + + post_responses_unions_simple_before_complex_response_200a_type_1 = cls( + prop=prop, + ) post_responses_unions_simple_before_complex_response_200a_type_1.additional_properties = d return post_responses_unions_simple_before_complex_response_200a_type_1 diff --git a/end_to_end_tests/openapi.json b/end_to_end_tests/openapi.json index 11baa0cc5..6bff4d125 100644 --- a/end_to_end_tests/openapi.json +++ b/end_to_end_tests/openapi.json @@ -770,7 +770,14 @@ "a": { "oneOf": [ {"type": "string"}, - {"type": "object"} + { + "type": "object", + "properties": { + "prop" : { + "type": "string" + } + } + } ] } } @@ -1256,6 +1263,9 @@ }, "an_required_field": { "type": "string" + }, + "a_simple_dict": { + "type": "object" } }, "required": [ @@ -1676,7 +1686,12 @@ }, "FreeFormModel": { "title": "FreeFormModel", - "type": "object" + "type": "object", + "properties": { + "prop" : { + "type": "string" + } + } }, "ModelWithAdditionalPropertiesInlined": { "type": "object", @@ -1812,7 +1827,12 @@ }, "model_reference_doesnt_match": { "title": "ModelName", - "type": "object" + "type": "object", + "properties": { + "prop" : { + "type": "string" + } + } }, "ModelWithPropertyRef": { "type": "object", @@ -2128,14 +2148,29 @@ "format": "byte" }, "import": { - "type": "object" + "type": "object", + "properties": { + "prop" : { + "type": "string" + } + } }, "None": { - "type": "object" + "type": "object", + "properties": { + "prop" : { + "type": "string" + } + } }, "model.reference.with.Periods": { "type": "object", - "description": "A Model with periods in its reference" + "description": "A Model with periods in its reference", + "properties": { + "prop" : { + "type": "string" + } + } }, "ModelWithRecursiveRef": { "type": "object", @@ -2241,7 +2276,12 @@ }, "ModelWithBackslashInDescription": { "type": "object", - "description": "Description with special character: \\" + "description": "Description with special character: \\", + "properties": { + "prop" : { + "type": "string" + } + } } }, "parameters": { diff --git a/openapi_python_client/parser/properties/__init__.py b/openapi_python_client/parser/properties/__init__.py index c4fe245e0..775b7f898 100644 --- a/openapi_python_client/parser/properties/__init__.py +++ b/openapi_python_client/parser/properties/__init__.py @@ -177,6 +177,12 @@ class BooleanProperty(Property): } template: ClassVar[str] = "boolean_property.py.jinja" +@attr.s(auto_attribs=True, frozen=True) +class DictProperty(Property): + """A property of type Dict[str, Any]""" + + _type_string: ClassVar[str] = "Dict[str, Any]" + _json_type_string: ClassVar[str] = "Dict[str, Any]" InnerProp = TypeVar("InnerProp", bound=Property) @@ -696,6 +702,19 @@ def _property_from_data( process_properties=process_properties, roots=roots, ) + if data.type == oai.DataType.OBJECT and not data.allOf and not data.properties and not data.additionalProperties: + return ( + DictProperty( + name=name, + default=data.default, + required=required, + nullable=data.nullable, + python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + description=data.description, + example=data.example, + ), + schemas, + ) if data.type == oai.DataType.OBJECT or data.allOf or (data.type is None and data.properties): return build_model_property( data=data, diff --git a/tests/conftest.py b/tests/conftest.py index 7f8442ab7..c9c60d11d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,6 +8,7 @@ BooleanProperty, DateProperty, DateTimeProperty, + DictProperty, EnumProperty, FileProperty, IntProperty, @@ -193,6 +194,19 @@ def _factory(**kwargs): return _factory +@pytest.fixture +def dict_property_factory() -> Callable[..., DictProperty]: + """ + This fixture surfaces in the test as a function which manufactures StringProperties with defaults. + + You can pass the same params into this as the StringProperty constructor to override defaults. + """ + + def _factory(**kwargs): + kwargs = _common_kwargs(kwargs) + return DictProperty(**kwargs) + + return _factory @pytest.fixture def file_property_factory() -> Callable[..., FileProperty]: diff --git a/tests/test_parser/test_properties/test_init.py b/tests/test_parser/test_properties/test_init.py index 85ffe8570..b625eaa05 100644 --- a/tests/test_parser/test_properties/test_init.py +++ b/tests/test_parser/test_properties/test_init.py @@ -763,43 +763,19 @@ def test_property_from_data_array(self, mocker): roots=roots, ) - def test_property_from_data_object(self, mocker): - from openapi_python_client.parser.properties import Schemas, property_from_data - - name = mocker.MagicMock() - required = mocker.MagicMock() - data = oai.Schema( - type="object", - ) - build_model_property = mocker.patch(f"{MODULE_NAME}.build_model_property") - mocker.patch("openapi_python_client.utils.remove_string_escapes", return_value=name) - schemas = Schemas() - config = MagicMock() - roots = {"root"} - process_properties = False - - response = property_from_data( - name=name, - required=required, - data=data, - schemas=schemas, - parent_name="parent", - config=config, - process_properties=process_properties, - roots=roots, - ) + @pytest.mark.parametrize( + "required, nullable, expected", + ( + (True, False, "Dict[str, Any]"), + (True, True, "Optional[Dict[str, Any]]"), + (False, True, "Union[Unset, None, Dict[str, Any]]"), + (False, False, "Union[Unset, Dict[str, Any]]"), + ), + ) + def test_property_from_data_object(self, dict_property_factory, required, nullable, expected): + p = dict_property_factory(required=required, nullable=nullable) - assert response == build_model_property.return_value - build_model_property.assert_called_once_with( - data=data, - name=name, - required=required, - schemas=schemas, - parent_name="parent", - config=config, - process_properties=process_properties, - roots=roots, - ) + assert p.get_type_string() == expected def test_property_from_data_union(self, mocker): from openapi_python_client.parser.properties import Schemas, property_from_data diff --git a/tests/test_parser/test_properties/test_model_property.py b/tests/test_parser/test_properties/test_model_property.py index 8e82145bb..d3d507c7c 100644 --- a/tests/test_parser/test_properties/test_model_property.py +++ b/tests/test_parser/test_properties/test_model_property.py @@ -389,7 +389,8 @@ def test_process_properties_model_property_roots(self, model_property_factory): from openapi_python_client.parser.properties.model_property import _process_properties roots = {"root"} - data = oai.Schema(properties={"test_model_property": oai.Schema.construct(type="object")}) + data = oai.Schema(properties={"test_model_property": oai.Schema.construct( + type="object", properties={"test_model_nested_property": oai.Schema.construct(type="string")})}) result = _process_properties(data=data, class_name="", schemas=Schemas(), config=Config(), roots=roots) From f7cd91b99e9d5d583dcfc0460245ecf6068fc241 Mon Sep 17 00:00:00 2001 From: v1nvn Date: Tue, 28 Mar 2023 08:35:54 +0530 Subject: [PATCH 4/9] feat: added model and api doc generation --- .../my_test_api_client/docs/1.md | 15 + .../my_test_api_client/docs/AFormData.md | 10 + .../my_test_api_client/docs/AModel.md | 32 ++ ...WithPropertiesReferenceThatAreNotObject.md | 37 +++ .../docs/AllOfHasPropertiesButNoType.md | 10 + .../my_test_api_client/docs/AllOfSubModel.md | 10 + ...ArrayWithACircularRefInItemsObjectAItem.md | 8 + ...fInItemsObjectAdditionalPropertiesAItem.md | 4 + ...fInItemsObjectAdditionalPropertiesBItem.md | 4 + ...ArrayWithACircularRefInItemsObjectBItem.md | 8 + ...efInItemsObjectAdditionalPropertiesItem.md | 4 + ...ArrayWithARecursiveRefInItemsObjectItem.md | 8 + .../docs/AnotherAllOfSubModel.md | 10 + .../docs/BodyUploadFileTestsUploadPost.md | 18 ++ ...adFileTestsUploadPostAdditionalProperty.md | 8 + ...adFileTestsUploadPostSomeNullableObject.md | 8 + ...BodyUploadFileTestsUploadPostSomeObject.md | 9 + ...adFileTestsUploadPostSomeOptionalObject.md | 8 + .../my_test_api_client/docs/Default.md | 33 ++ .../my_test_api_client/docs/FreeFormModel.md | 8 + .../docs/HTTPValidationError.md | 8 + .../my_test_api_client/docs/Import.md | 8 + .../my_test_api_client/docs/Location.md | 41 +++ .../my_test_api_client/docs/ModelFromAllOf.md | 11 + .../my_test_api_client/docs/ModelName.md | 8 + .../docs/ModelReferenceWithPeriods.md | 10 + .../ModelWithAdditionalPropertiesInlined.md | 8 + ...onalPropertiesInlinedAdditionalProperty.md | 8 + .../ModelWithAdditionalPropertiesRefed.md | 4 + .../docs/ModelWithAnyJsonProperties.md | 4 + ...nyJsonPropertiesAdditionalPropertyType0.md | 4 + .../docs/ModelWithBackslashInDescription.md | 10 + .../docs/ModelWithCircularRefA.md | 8 + .../docs/ModelWithCircularRefB.md | 8 + ...lWithCircularRefInAdditionalPropertiesA.md | 4 + ...lWithCircularRefInAdditionalPropertiesB.md | 4 + .../docs/ModelWithDateTimeProperty.md | 8 + .../ModelWithPrimitiveAdditionalProperties.md | 8 + ...rimitiveAdditionalPropertiesADateHolder.md | 4 + .../docs/ModelWithPropertyRef.md | 8 + .../docs/ModelWithRecursiveRef.md | 8 + ...lWithRecursiveRefInAdditionalProperties.md | 4 + .../docs/ModelWithUnionProperty.md | 8 + .../docs/ModelWithUnionPropertyInlined.md | 8 + ...ModelWithUnionPropertyInlinedFruitType0.md | 8 + ...ModelWithUnionPropertyInlinedFruitType1.md | 8 + .../my_test_api_client/docs/None_.md | 8 + .../docs/ParameterReferences.md | 26 ++ .../my_test_api_client/docs/Parameters.md | 69 ++++ .../docs/PostFormDataInlineData.md | 9 + ...sesUnionsSimpleBeforeComplexResponse200.md | 8 + ...onsSimpleBeforeComplexResponse200AType1.md | 8 + .../my_test_api_client/docs/Responses.md | 17 + .../docs/TestInlineObjectsJsonBody.md | 8 + .../docs/TestInlineObjectsResponse200.md | 8 + .../my_test_api_client/docs/Tests.md | 296 ++++++++++++++++++ .../my_test_api_client/docs/True_.md | 20 ++ .../docs/ValidationError.md | 10 + end_to_end_tests/regen_golden_record.py | 2 +- openapi_python_client/__init__.py | 24 +- openapi_python_client/parser/openapi.py | 6 +- .../templates/endpoints.md.jinja | 35 +++ .../templates/model.md.jinja | 20 ++ 63 files changed, 1042 insertions(+), 4 deletions(-) create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/1.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/AFormData.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/AModel.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/AModelWithPropertiesReferenceThatAreNotObject.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/AllOfHasPropertiesButNoType.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/AllOfSubModel.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectAItem.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectBItem.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithARecursiveRefInItemsObjectItem.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/AnotherAllOfSubModel.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPost.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostAdditionalProperty.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostSomeNullableObject.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostSomeObject.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostSomeOptionalObject.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/Default.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/FreeFormModel.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/HTTPValidationError.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/Import.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/Location.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelFromAllOf.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelName.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelReferenceWithPeriods.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAdditionalPropertiesInlined.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAdditionalPropertiesInlinedAdditionalProperty.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAdditionalPropertiesRefed.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAnyJsonProperties.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAnyJsonPropertiesAdditionalPropertyType0.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithBackslashInDescription.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefA.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefB.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefInAdditionalPropertiesA.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefInAdditionalPropertiesB.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithDateTimeProperty.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithPrimitiveAdditionalProperties.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithPrimitiveAdditionalPropertiesADateHolder.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithPropertyRef.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithRecursiveRef.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithRecursiveRefInAdditionalProperties.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionProperty.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionPropertyInlined.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionPropertyInlinedFruitType0.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionPropertyInlinedFruitType1.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/None_.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ParameterReferences.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/Parameters.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/PostFormDataInlineData.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/PostResponsesUnionsSimpleBeforeComplexResponse200.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/PostResponsesUnionsSimpleBeforeComplexResponse200AType1.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/Responses.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/TestInlineObjectsJsonBody.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/TestInlineObjectsResponse200.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/Tests.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/True_.md create mode 100644 end_to_end_tests/golden-record/my_test_api_client/docs/ValidationError.md create mode 100644 openapi_python_client/templates/endpoints.md.jinja create mode 100644 openapi_python_client/templates/model.md.jinja diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/1.md b/end_to_end_tests/golden-record/my_test_api_client/docs/1.md new file mode 100644 index 000000000..4299e29e7 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/1.md @@ -0,0 +1,15 @@ +# 1 + + +Method | HTTP Request | Description +------------- | ------------- | ------------- +[**get_tag_with_number**](#get_tag_with_number) | GET /tag_with_number | + + +# **get_tag_with_number** + + + +### Response Type +Any + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/AFormData.md b/end_to_end_tests/golden-record/my_test_api_client/docs/AFormData.md new file mode 100644 index 000000000..332f519ea --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/AFormData.md @@ -0,0 +1,10 @@ +# AFormData + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +an_required_field | str | None +an_optional_field | Union[Unset, str] | None +a_simple_dict | Union[Unset, Dict[str, Any]] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/AModel.md b/end_to_end_tests/golden-record/my_test_api_client/docs/AModel.md new file mode 100644 index 000000000..72887ffcb --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/AModel.md @@ -0,0 +1,32 @@ +# AModelA Model for testing all the ways custom objects can be used + + + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +an_enum_value | AnEnum | For testing Enums in all the ways they can be used +an_allof_enum_with_overridden_default | AnAllOfEnum | None +a_camel_date_time | Union[datetime.date, datetime.datetime] | None +a_date | datetime.date | None +required_not_nullable | str | None +one_of_models | Union['FreeFormModel', 'ModelWithUnionProperty', Any] | None +model | ModelWithUnionProperty | +any_value | Union[Unset, Any] | None +an_optional_allof_enum | Union[Unset, AnAllOfEnum] | None +nested_list_of_enums | Union[Unset, List[List[DifferentEnum]]] | None +a_nullable_date | Optional[datetime.date] | None +a_not_required_date | Union[Unset, datetime.date] | None +attr_1_leading_digit | Union[Unset, str] | None +attr_leading_underscore | Union[Unset, str] | None +required_nullable | Optional[str] | None +not_required_nullable | Union[Unset, None, str] | None +not_required_not_nullable | Union[Unset, str] | None +nullable_one_of_models | Union['FreeFormModel', 'ModelWithUnionProperty', None] | None +not_required_one_of_models | Union['FreeFormModel', 'ModelWithUnionProperty', Unset] | None +not_required_nullable_one_of_models | Union['FreeFormModel', 'ModelWithUnionProperty', None, Unset, str] | None +nullable_model | Optional[ModelWithUnionProperty] | +not_required_model | Union[Unset, ModelWithUnionProperty] | +not_required_nullable_model | Union[Unset, None, ModelWithUnionProperty] | + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/AModelWithPropertiesReferenceThatAreNotObject.md b/end_to_end_tests/golden-record/my_test_api_client/docs/AModelWithPropertiesReferenceThatAreNotObject.md new file mode 100644 index 000000000..6f52243d7 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/AModelWithPropertiesReferenceThatAreNotObject.md @@ -0,0 +1,37 @@ +# AModelWithPropertiesReferenceThatAreNotObject + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +enum_properties_ref | List[AnEnum] | None +str_properties_ref | List[str] | None +date_properties_ref | List[datetime.date] | None +datetime_properties_ref | List[datetime.datetime] | None +int32_properties_ref | List[int] | None +int64_properties_ref | List[int] | None +float_properties_ref | List[float] | None +double_properties_ref | List[float] | None +file_properties_ref | List[File] | None +bytestream_properties_ref | List[str] | None +enum_properties | List[AnEnum] | None +str_properties | List[str] | None +date_properties | List[datetime.date] | None +datetime_properties | List[datetime.datetime] | None +int32_properties | List[int] | None +int64_properties | List[int] | None +float_properties | List[float] | None +double_properties | List[float] | None +file_properties | List[File] | None +bytestream_properties | List[str] | None +enum_property_ref | AnEnum | For testing Enums in all the ways they can be used +str_property_ref | str | None +date_property_ref | datetime.date | None +datetime_property_ref | datetime.datetime | None +int32_property_ref | int | None +int64_property_ref | int | None +float_property_ref | float | None +double_property_ref | float | None +file_property_ref | File | None +bytestream_property_ref | str | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/AllOfHasPropertiesButNoType.md b/end_to_end_tests/golden-record/my_test_api_client/docs/AllOfHasPropertiesButNoType.md new file mode 100644 index 000000000..548b18a80 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/AllOfHasPropertiesButNoType.md @@ -0,0 +1,10 @@ +# AllOfHasPropertiesButNoType + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +a_sub_property | Union[Unset, str] | None +type | Union[Unset, str] | None +type_enum | Union[Unset, AllOfHasPropertiesButNoTypeTypeEnum] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/AllOfSubModel.md b/end_to_end_tests/golden-record/my_test_api_client/docs/AllOfSubModel.md new file mode 100644 index 000000000..a4a8ac4b7 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/AllOfSubModel.md @@ -0,0 +1,10 @@ +# AllOfSubModel + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +a_sub_property | Union[Unset, str] | None +type | Union[Unset, str] | None +type_enum | Union[Unset, AllOfSubModelTypeEnum] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectAItem.md b/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectAItem.md new file mode 100644 index 000000000..edf433323 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectAItem.md @@ -0,0 +1,8 @@ +# AnArrayWithACircularRefInItemsObjectAItem + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +circular | Union[Unset, List['AnArrayWithACircularRefInItemsObjectBItem']] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem.md b/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem.md new file mode 100644 index 000000000..34eea0943 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem.md @@ -0,0 +1,4 @@ +# AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem + + + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem.md b/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem.md new file mode 100644 index 000000000..e8450fa9c --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem.md @@ -0,0 +1,4 @@ +# AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem + + + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectBItem.md b/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectBItem.md new file mode 100644 index 000000000..c7716909d --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithACircularRefInItemsObjectBItem.md @@ -0,0 +1,8 @@ +# AnArrayWithACircularRefInItemsObjectBItem + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +circular | Union[Unset, List['AnArrayWithACircularRefInItemsObjectAItem']] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem.md b/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem.md new file mode 100644 index 000000000..0696ae57d --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem.md @@ -0,0 +1,4 @@ +# AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem + + + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithARecursiveRefInItemsObjectItem.md b/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithARecursiveRefInItemsObjectItem.md new file mode 100644 index 000000000..57f71c128 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/AnArrayWithARecursiveRefInItemsObjectItem.md @@ -0,0 +1,8 @@ +# AnArrayWithARecursiveRefInItemsObjectItem + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +recursive | Union[Unset, List['AnArrayWithARecursiveRefInItemsObjectItem']] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/AnotherAllOfSubModel.md b/end_to_end_tests/golden-record/my_test_api_client/docs/AnotherAllOfSubModel.md new file mode 100644 index 000000000..6bbd5a1d9 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/AnotherAllOfSubModel.md @@ -0,0 +1,10 @@ +# AnotherAllOfSubModel + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +another_sub_property | Union[Unset, str] | None +type | Union[Unset, AnotherAllOfSubModelType] | None +type_enum | Union[Unset, AnotherAllOfSubModelTypeEnum] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPost.md b/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPost.md new file mode 100644 index 000000000..d4b77ffcc --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPost.md @@ -0,0 +1,18 @@ +# BodyUploadFileTestsUploadPost + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +some_file | File | None +some_object | BodyUploadFileTestsUploadPostSomeObject | +some_optional_file | Union[Unset, File] | None +some_string | Union[Unset, str] | None +a_datetime | Union[Unset, datetime.datetime] | None +a_date | Union[Unset, datetime.date] | None +some_number | Union[Unset, float] | None +some_array | Union[Unset, List[float]] | None +some_optional_object | Union[Unset, BodyUploadFileTestsUploadPostSomeOptionalObject] | +some_nullable_object | Optional[BodyUploadFileTestsUploadPostSomeNullableObject] | +some_enum | Union[Unset, DifferentEnum] | An enumeration. + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostAdditionalProperty.md b/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostAdditionalProperty.md new file mode 100644 index 000000000..b5f9c74f9 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostAdditionalProperty.md @@ -0,0 +1,8 @@ +# BodyUploadFileTestsUploadPostAdditionalProperty + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +foo | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostSomeNullableObject.md b/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostSomeNullableObject.md new file mode 100644 index 000000000..fb6dd31de --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostSomeNullableObject.md @@ -0,0 +1,8 @@ +# BodyUploadFileTestsUploadPostSomeNullableObject + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +bar | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostSomeObject.md b/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostSomeObject.md new file mode 100644 index 000000000..f2b19b783 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostSomeObject.md @@ -0,0 +1,9 @@ +# BodyUploadFileTestsUploadPostSomeObject + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +num | float | None +text | str | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostSomeOptionalObject.md b/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostSomeOptionalObject.md new file mode 100644 index 000000000..8ac1a48dd --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/BodyUploadFileTestsUploadPostSomeOptionalObject.md @@ -0,0 +1,8 @@ +# BodyUploadFileTestsUploadPostSomeOptionalObject + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +foo | str | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/Default.md b/end_to_end_tests/golden-record/my_test_api_client/docs/Default.md new file mode 100644 index 000000000..96fff7333 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/Default.md @@ -0,0 +1,33 @@ +# default + + +Method | HTTP Request | Description +------------- | ------------- | ------------- +[**get_common_parameters**](#get_common_parameters) | GET /common_parameters | +[**post_common_parameters**](#post_common_parameters) | POST /common_parameters | + + +# **get_common_parameters** + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +common | str | None + + +### Response Type +Any + +# **post_common_parameters** + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +common | str | None + + +### Response Type +Any + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/FreeFormModel.md b/end_to_end_tests/golden-record/my_test_api_client/docs/FreeFormModel.md new file mode 100644 index 000000000..5474efd01 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/FreeFormModel.md @@ -0,0 +1,8 @@ +# FreeFormModel + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +prop | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/HTTPValidationError.md b/end_to_end_tests/golden-record/my_test_api_client/docs/HTTPValidationError.md new file mode 100644 index 000000000..7319d9617 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/HTTPValidationError.md @@ -0,0 +1,8 @@ +# HTTPValidationError + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +detail | Union[Unset, List['ValidationError']] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/Import.md b/end_to_end_tests/golden-record/my_test_api_client/docs/Import.md new file mode 100644 index 000000000..0575432f0 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/Import.md @@ -0,0 +1,8 @@ +# Import + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +prop | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/Location.md b/end_to_end_tests/golden-record/my_test_api_client/docs/Location.md new file mode 100644 index 000000000..eb35e2498 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/Location.md @@ -0,0 +1,41 @@ +# location + + +Method | HTTP Request | Description +------------- | ------------- | ------------- +[**get_location_query_optionality**](#get_location_query_optionality) | GET /location/query/optionality | +[**get_location_header_types**](#get_location_header_types) | GET /location/header/types | + + +# **get_location_query_optionality** + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +not_null_required | datetime.datetime | None +null_required | datetime.datetime | None +null_not_required | datetime.datetime | None +not_null_not_required | datetime.datetime | None + + +### Response Type +Any + +# **get_location_header_types** + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +boolean_header | bool | None +string_header | str | None +number_header | float | None +integer_header | int | None +int_enum_header | GetLocationHeaderTypesIntEnumHeader | None +string_enum_header | GetLocationHeaderTypesStringEnumHeader | None + + +### Response Type +Any + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelFromAllOf.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelFromAllOf.md new file mode 100644 index 000000000..694fb819a --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelFromAllOf.md @@ -0,0 +1,11 @@ +# ModelFromAllOf + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +a_sub_property | Union[Unset, str] | None +type | Union[Unset, AnotherAllOfSubModelType] | None +type_enum | Union[Unset, AnotherAllOfSubModelTypeEnum] | None +another_sub_property | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelName.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelName.md new file mode 100644 index 000000000..bef2d3e58 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelName.md @@ -0,0 +1,8 @@ +# ModelName + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +prop | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelReferenceWithPeriods.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelReferenceWithPeriods.md new file mode 100644 index 000000000..f09fd73d3 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelReferenceWithPeriods.md @@ -0,0 +1,10 @@ +# ModelReferenceWithPeriodsA Model with periods in its reference + + + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +prop | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAdditionalPropertiesInlined.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAdditionalPropertiesInlined.md new file mode 100644 index 000000000..3d25b363d --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAdditionalPropertiesInlined.md @@ -0,0 +1,8 @@ +# ModelWithAdditionalPropertiesInlined + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +a_number | Union[Unset, float] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAdditionalPropertiesInlinedAdditionalProperty.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAdditionalPropertiesInlinedAdditionalProperty.md new file mode 100644 index 000000000..e58ddac23 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAdditionalPropertiesInlinedAdditionalProperty.md @@ -0,0 +1,8 @@ +# ModelWithAdditionalPropertiesInlinedAdditionalProperty + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +extra_props_prop | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAdditionalPropertiesRefed.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAdditionalPropertiesRefed.md new file mode 100644 index 000000000..00b0ee4a7 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAdditionalPropertiesRefed.md @@ -0,0 +1,4 @@ +# ModelWithAdditionalPropertiesRefed + + + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAnyJsonProperties.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAnyJsonProperties.md new file mode 100644 index 000000000..7a5fd47b0 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAnyJsonProperties.md @@ -0,0 +1,4 @@ +# ModelWithAnyJsonProperties + + + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAnyJsonPropertiesAdditionalPropertyType0.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAnyJsonPropertiesAdditionalPropertyType0.md new file mode 100644 index 000000000..de7099313 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithAnyJsonPropertiesAdditionalPropertyType0.md @@ -0,0 +1,4 @@ +# ModelWithAnyJsonPropertiesAdditionalPropertyType0 + + + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithBackslashInDescription.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithBackslashInDescription.md new file mode 100644 index 000000000..baf8e8c08 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithBackslashInDescription.md @@ -0,0 +1,10 @@ +# ModelWithBackslashInDescriptionDescription with special character: \ + + + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +prop | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefA.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefA.md new file mode 100644 index 000000000..8c23cafb1 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefA.md @@ -0,0 +1,8 @@ +# ModelWithCircularRefA + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +circular | Union[Unset, ModelWithCircularRefB] | + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefB.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefB.md new file mode 100644 index 000000000..22b045906 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefB.md @@ -0,0 +1,8 @@ +# ModelWithCircularRefB + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +circular | Union[Unset, ModelWithCircularRefA] | + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefInAdditionalPropertiesA.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefInAdditionalPropertiesA.md new file mode 100644 index 000000000..4ee16f476 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefInAdditionalPropertiesA.md @@ -0,0 +1,4 @@ +# ModelWithCircularRefInAdditionalPropertiesA + + + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefInAdditionalPropertiesB.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefInAdditionalPropertiesB.md new file mode 100644 index 000000000..8b9d4175d --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithCircularRefInAdditionalPropertiesB.md @@ -0,0 +1,4 @@ +# ModelWithCircularRefInAdditionalPropertiesB + + + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithDateTimeProperty.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithDateTimeProperty.md new file mode 100644 index 000000000..60c264345 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithDateTimeProperty.md @@ -0,0 +1,8 @@ +# ModelWithDateTimeProperty + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +datetime_ | Union[Unset, datetime.datetime] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithPrimitiveAdditionalProperties.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithPrimitiveAdditionalProperties.md new file mode 100644 index 000000000..b65a652b7 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithPrimitiveAdditionalProperties.md @@ -0,0 +1,8 @@ +# ModelWithPrimitiveAdditionalProperties + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +a_date_holder | Union[Unset, ModelWithPrimitiveAdditionalPropertiesADateHolder] | + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithPrimitiveAdditionalPropertiesADateHolder.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithPrimitiveAdditionalPropertiesADateHolder.md new file mode 100644 index 000000000..5ebf021d1 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithPrimitiveAdditionalPropertiesADateHolder.md @@ -0,0 +1,4 @@ +# ModelWithPrimitiveAdditionalPropertiesADateHolder + + + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithPropertyRef.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithPropertyRef.md new file mode 100644 index 000000000..85570ce43 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithPropertyRef.md @@ -0,0 +1,8 @@ +# ModelWithPropertyRef + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +inner | Union[Unset, ModelName] | + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithRecursiveRef.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithRecursiveRef.md new file mode 100644 index 000000000..66bb03472 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithRecursiveRef.md @@ -0,0 +1,8 @@ +# ModelWithRecursiveRef + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +recursive | Union[Unset, ModelWithRecursiveRef] | + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithRecursiveRefInAdditionalProperties.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithRecursiveRefInAdditionalProperties.md new file mode 100644 index 000000000..8c1c54a45 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithRecursiveRefInAdditionalProperties.md @@ -0,0 +1,4 @@ +# ModelWithRecursiveRefInAdditionalProperties + + + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionProperty.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionProperty.md new file mode 100644 index 000000000..7e6b70473 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionProperty.md @@ -0,0 +1,8 @@ +# ModelWithUnionProperty + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +a_property | Union[AnEnum, AnIntEnum, Unset] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionPropertyInlined.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionPropertyInlined.md new file mode 100644 index 000000000..84be33853 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionPropertyInlined.md @@ -0,0 +1,8 @@ +# ModelWithUnionPropertyInlined + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +fruit | Union['ModelWithUnionPropertyInlinedFruitType0', 'ModelWithUnionPropertyInlinedFruitType1', Unset] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionPropertyInlinedFruitType0.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionPropertyInlinedFruitType0.md new file mode 100644 index 000000000..9d3cbd5d9 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionPropertyInlinedFruitType0.md @@ -0,0 +1,8 @@ +# ModelWithUnionPropertyInlinedFruitType0 + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +apples | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionPropertyInlinedFruitType1.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionPropertyInlinedFruitType1.md new file mode 100644 index 000000000..665ea6e45 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ModelWithUnionPropertyInlinedFruitType1.md @@ -0,0 +1,8 @@ +# ModelWithUnionPropertyInlinedFruitType1 + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +bananas | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/None_.md b/end_to_end_tests/golden-record/my_test_api_client/docs/None_.md new file mode 100644 index 000000000..1affa74ed --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/None_.md @@ -0,0 +1,8 @@ +# None_ + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +prop | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ParameterReferences.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ParameterReferences.md new file mode 100644 index 000000000..a844011a5 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ParameterReferences.md @@ -0,0 +1,26 @@ +# parameter-references + + +Method | HTTP Request | Description +------------- | ------------- | ------------- +[**get_parameter_references_path_param**](#get_parameter_references_path_param) | GET /parameter-references/{path_param} | + + +# **get_parameter_references_path_param** + +Test different types of parameter references + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +path_param | str | None +string_param | str | None +integer_param | int | None +header_param | str | None +cookie_param | str | None + + +### Response Type +Any + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/Parameters.md b/end_to_end_tests/golden-record/my_test_api_client/docs/Parameters.md new file mode 100644 index 000000000..9956383d6 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/Parameters.md @@ -0,0 +1,69 @@ +# parameters + + +Method | HTTP Request | Description +------------- | ------------- | ------------- +[**get_common_parameters_overriding_param**](#get_common_parameters_overriding_param) | GET /common_parameters_overriding/{param} | Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code +[**delete_common_parameters_overriding_param**](#delete_common_parameters_overriding_param) | DELETE /common_parameters_overriding/{param} | +[**get_same_name_multiple_locations_param**](#get_same_name_multiple_locations_param) | GET /same-name-multiple-locations/{param} | +[**multiple_path_parameters**](#multiple_path_parameters) | GET /multiple-path-parameters/{param4}/something/{param2}/{param1}/{param3} | + + +# **get_common_parameters_overriding_param** + + Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +param_path | str | None +param_query | str | A parameter with the same name as another. + + +### Response Type +Any + +# **delete_common_parameters_overriding_param** + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +param_path | str | None +param_query | str | None + + +### Response Type +Any + +# **get_same_name_multiple_locations_param** + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +param_path | str | None +param_query | str | None +param_header | str | None +param_cookie | str | None + + +### Response Type +Any + +# **multiple_path_parameters** + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +param4 | str | None +param2 | int | None +param1 | str | None +param3 | int | None + + +### Response Type +Any + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/PostFormDataInlineData.md b/end_to_end_tests/golden-record/my_test_api_client/docs/PostFormDataInlineData.md new file mode 100644 index 000000000..0130bd733 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/PostFormDataInlineData.md @@ -0,0 +1,9 @@ +# PostFormDataInlineData + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +a_required_field | str | None +an_optional_field | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/PostResponsesUnionsSimpleBeforeComplexResponse200.md b/end_to_end_tests/golden-record/my_test_api_client/docs/PostResponsesUnionsSimpleBeforeComplexResponse200.md new file mode 100644 index 000000000..253f71d9b --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/PostResponsesUnionsSimpleBeforeComplexResponse200.md @@ -0,0 +1,8 @@ +# PostResponsesUnionsSimpleBeforeComplexResponse200 + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +a | Union['PostResponsesUnionsSimpleBeforeComplexResponse200AType1', str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/PostResponsesUnionsSimpleBeforeComplexResponse200AType1.md b/end_to_end_tests/golden-record/my_test_api_client/docs/PostResponsesUnionsSimpleBeforeComplexResponse200AType1.md new file mode 100644 index 000000000..71e3d0104 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/PostResponsesUnionsSimpleBeforeComplexResponse200AType1.md @@ -0,0 +1,8 @@ +# PostResponsesUnionsSimpleBeforeComplexResponse200AType1 + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +prop | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/Responses.md b/end_to_end_tests/golden-record/my_test_api_client/docs/Responses.md new file mode 100644 index 000000000..baebe912a --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/Responses.md @@ -0,0 +1,17 @@ +# responses + + +Method | HTTP Request | Description +------------- | ------------- | ------------- +[**post_responses_unions_simple_before_complex**](#post_responses_unions_simple_before_complex) | POST /responses/unions/simple_before_complex | Regression test for #603 + + +# **post_responses_unions_simple_before_complex** + + Regression test for #603 + + + +### Response Type +PostResponsesUnionsSimpleBeforeComplexResponse200 + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/TestInlineObjectsJsonBody.md b/end_to_end_tests/golden-record/my_test_api_client/docs/TestInlineObjectsJsonBody.md new file mode 100644 index 000000000..ddf767eb1 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/TestInlineObjectsJsonBody.md @@ -0,0 +1,8 @@ +# TestInlineObjectsJsonBody + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +a_property | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/TestInlineObjectsResponse200.md b/end_to_end_tests/golden-record/my_test_api_client/docs/TestInlineObjectsResponse200.md new file mode 100644 index 000000000..79199769a --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/TestInlineObjectsResponse200.md @@ -0,0 +1,8 @@ +# TestInlineObjectsResponse200 + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +a_property | Union[Unset, str] | None + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/Tests.md b/end_to_end_tests/golden-record/my_test_api_client/docs/Tests.md new file mode 100644 index 000000000..0f221433b --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/Tests.md @@ -0,0 +1,296 @@ +# tests + + +Method | HTTP Request | Description +------------- | ------------- | ------------- +[**get_user_list**](#get_user_list) | GET /tests/ | Get a list of things +[**get_basic_list_of_strings**](#get_basic_list_of_strings) | GET /tests/basic_lists/strings | Get a list of strings +[**get_basic_list_of_integers**](#get_basic_list_of_integers) | GET /tests/basic_lists/integers | Get a list of integers +[**get_basic_list_of_floats**](#get_basic_list_of_floats) | GET /tests/basic_lists/floats | Get a list of floats +[**get_basic_list_of_booleans**](#get_basic_list_of_booleans) | GET /tests/basic_lists/booleans | Get a list of booleans +[**post_form_data**](#post_form_data) | POST /tests/post_form_data | Post form data +[**post_form_data_inline**](#post_form_data_inline) | POST /tests/post_form_data_inline | Post form data (inline schema) +[**upload_file_tests_upload_post**](#upload_file_tests_upload_post) | POST /tests/upload | Upload a file +[**upload_multiple_files_tests_upload_post**](#upload_multiple_files_tests_upload_post) | POST /tests/upload/multiple | Upload several files in the same request +[**json_body_tests_json_body_post**](#json_body_tests_json_body_post) | POST /tests/json_body | Try sending a JSON body +[**post_tests_json_body_string**](#post_tests_json_body_string) | POST /tests/json_body/string | +[**defaults_tests_defaults_post**](#defaults_tests_defaults_post) | POST /tests/defaults | +[**octet_stream_tests_octet_stream_get**](#octet_stream_tests_octet_stream_get) | GET /tests/octet_stream | +[**no_response_tests_no_response_get**](#no_response_tests_no_response_get) | GET /tests/no_response | +[**unsupported_content_tests_unsupported_content_get**](#unsupported_content_tests_unsupported_content_get) | GET /tests/unsupported_content | +[**int_enum_tests_int_enum_post**](#int_enum_tests_int_enum_post) | POST /tests/int_enum | +[**test_inline_objects**](#test_inline_objects) | POST /tests/inline_objects | +[**token_with_cookie_auth_token_with_cookie_get**](#token_with_cookie_auth_token_with_cookie_get) | GET /auth/token_with_cookie | Test optional cookie parameters +[**callback_test**](#callback_test) | POST /tests/callback | Try sending a request related to a callback +[**description_with_backslash**](#description_with_backslash) | GET /tests/description-with-backslash | Test description with \ + + +# **get_user_list** + +Get List + + Get a list of things + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +an_enum_value | [List[AnEnum]](List[AnEnum]) | None +an_enum_value_with_null | [List[Optional[AnEnumWithNull]]](List[Optional[AnEnumWithNull]]) | None +an_enum_value_with_only_null | [List[None]](List[None]) | None +some_date | [Union[datetime.date, datetime.datetime]](Union[datetime.date, datetime.datetime]) | None + + +### Response Type +Union[HTTPValidationError, List['AModel']] + +# **get_basic_list_of_strings** + +Get Basic List Of Strings + + Get a list of strings + + + +### Response Type +List[str] + +# **get_basic_list_of_integers** + +Get Basic List Of Integers + + Get a list of integers + + + +### Response Type +List[int] + +# **get_basic_list_of_floats** + +Get Basic List Of Floats + + Get a list of floats + + + +### Response Type +List[float] + +# **get_basic_list_of_booleans** + +Get Basic List Of Booleans + + Get a list of booleans + + + +### Response Type +List[bool] + +# **post_form_data** + +Post form data + + Post form data + + + +### Response Type +Any + +# **post_form_data_inline** + +Post form data (inline schema) + + Post form data (inline schema) + + + +### Response Type +Any + +# **upload_file_tests_upload_post** + +Upload File + + Upload a file + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +multipart_data | [BodyUploadFileTestsUploadPost](BodyUploadFileTestsUploadPost) | + + +### Response Type +Union[Any, HTTPValidationError] + +# **upload_multiple_files_tests_upload_post** + +Upload multiple files + + Upload several files in the same request + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +multipart_data | [List[File]](List[File]) | None + + +### Response Type +Union[Any, HTTPValidationError] + +# **json_body_tests_json_body_post** + +Json Body + + Try sending a JSON body + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +json_body | [AModel](AModel) | A Model for testing all the ways custom objects can be used + + +### Response Type +Union[Any, HTTPValidationError] + +# **post_tests_json_body_string** + +Json Body Which is String + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +json_body | str | None + + +### Response Type +Union[HTTPValidationError, str] + +# **defaults_tests_defaults_post** + +Defaults + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +string_prop | str | None +date_prop | datetime.date | None +float_prop | float | None +int_prop | int | None +boolean_prop | bool | None +list_prop | [List[AnEnum]](List[AnEnum]) | None +union_prop | [Union[float, str]](Union[float, str]) | None +union_prop_with_ref | [Union[AnEnum, float]](Union[AnEnum, float]) | None +enum_prop | AnEnum | For testing Enums in all the ways they can be used +model_prop | [ModelWithUnionProperty](ModelWithUnionProperty) | +required_model_prop | [ModelWithUnionProperty](ModelWithUnionProperty) | + + +### Response Type +Union[Any, HTTPValidationError] + +# **octet_stream_tests_octet_stream_get** + +Octet Stream + + + +### Response Type +File + +# **no_response_tests_no_response_get** + +No Response + + + +### Response Type +Any + +# **unsupported_content_tests_unsupported_content_get** + +Unsupported Content + + + +### Response Type +Any + +# **int_enum_tests_int_enum_post** + +Int Enum + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +int_enum | AnIntEnum | An enumeration. + + +### Response Type +Union[Any, HTTPValidationError] + +# **test_inline_objects** + +Test Inline Objects + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +json_body | [TestInlineObjectsJsonBody](TestInlineObjectsJsonBody) | + + +### Response Type +TestInlineObjectsResponse200 + +# **token_with_cookie_auth_token_with_cookie_get** + +TOKEN_WITH_COOKIE + + Test optional cookie parameters + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +my_token | str | None + + +### Response Type +Any + +# **callback_test** + +Path with callback + + Try sending a request related to a callback + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +json_body | [AModel](AModel) | A Model for testing all the ways custom objects can be used + + +### Response Type +Union[Any, HTTPValidationError] + +# **description_with_backslash** + +Test description with \ + + Test description with \ + + + +### Response Type +Any + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/True_.md b/end_to_end_tests/golden-record/my_test_api_client/docs/True_.md new file mode 100644 index 000000000..327c80f44 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/True_.md @@ -0,0 +1,20 @@ +# true + + +Method | HTTP Request | Description +------------- | ------------- | ------------- +[**false_**](#false_) | GET /naming/keywords | + + +# **false_** + + +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +import_ | str | None + + +### Response Type +Any + diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/ValidationError.md b/end_to_end_tests/golden-record/my_test_api_client/docs/ValidationError.md new file mode 100644 index 000000000..95d4423cf --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/ValidationError.md @@ -0,0 +1,10 @@ +# ValidationError + + +## Properties +Name | Type | Description +------------ | ------------- | ------------- +loc | List[str] | None +msg | str | None +type | str | None + diff --git a/end_to_end_tests/regen_golden_record.py b/end_to_end_tests/regen_golden_record.py index 1d4dc943d..b387e0b94 100644 --- a/end_to_end_tests/regen_golden_record.py +++ b/end_to_end_tests/regen_golden_record.py @@ -76,4 +76,4 @@ def regen_custom_template_golden_record(): if __name__ == "__main__": regen_golden_record() - regen_custom_template_golden_record() + # regen_custom_template_golden_record() diff --git a/openapi_python_client/__init__.py b/openapi_python_client/__init__.py index b4edd5415..dc299a333 100644 --- a/openapi_python_client/__init__.py +++ b/openapi_python_client/__init__.py @@ -232,17 +232,24 @@ def _build_models(self) -> None: # Generate models models_dir = self.package_dir / "models" models_dir.mkdir() + docs_dir = self.package_dir / "docs" + docs_dir.mkdir(exist_ok=True) models_init = models_dir / "__init__.py" imports = [] alls = [] model_template = self.env.get_template("model.py.jinja") + model_doc_template = self.env.get_template("model.md.jinja") for model in self.openapi.models: module_path = models_dir / f"{model.class_info.module_name}.py" module_path.write_text(model_template.render(model=model), encoding=self.file_encoding) imports.append(import_string_from_class(model.class_info)) alls.append(model.class_info.name) + # Generate model docs + doc_path = docs_dir / f"{model.class_info.name}.md" + doc_path.write_text(model_doc_template.render(model=model), encoding=self.file_encoding) + # Generate enums str_enum_template = self.env.get_template("str_enum.py.jinja") int_enum_template = self.env.get_template("int_enum.py.jinja") @@ -270,12 +277,18 @@ def _build_api(self) -> None: errors_template = self.env.get_template("errors.py.jinja") errors_path.write_text(errors_template.render(), encoding=self.file_encoding) + docs_dir = self.package_dir / "docs" + docs_dir.mkdir(exist_ok=True) + # Generate endpoints api_dir = self.package_dir endpoint_collections_by_tag = self.openapi.endpoint_collections_by_tag endpoint_template = self.env.get_template( "endpoint_module.py.jinja", globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"} ) + endpoints_doc_template = self.env.get_template( + "endpoints.md.jinja", globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"} + ) for tag, collection in endpoint_collections_by_tag.items(): tag_dir = api_dir / tag tag_dir.mkdir() @@ -286,15 +299,24 @@ def _build_api(self) -> None: endpoint_init_template.render(endpoint_collection=collection), encoding=self.file_encoding, ) + + def module_name(endpoint): + return utils.PythonIdentifier(endpoint.name, self.config.field_prefix) for endpoint in collection.endpoints: - module_path = tag_dir / f"{utils.PythonIdentifier(endpoint.name, self.config.field_prefix)}.py" + module_path = tag_dir / f"{module_name(endpoint)}.py" module_path.write_text( endpoint_template.render( endpoint=endpoint, ), encoding=self.file_encoding, ) + + doc_path = docs_dir / f"{utils.ClassName(collection.title, '')}.md" + doc_path.write_text( + endpoints_doc_template.render(endpoint_collection=collection, module_name=module_name), + encoding=self.file_encoding + ) def _get_project_for_url_or_path( # pylint: disable=too-many-arguments diff --git a/openapi_python_client/parser/openapi.py b/openapi_python_client/parser/openapi.py index d222af1ad..d5a55fded 100644 --- a/openapi_python_client/parser/openapi.py +++ b/openapi_python_client/parser/openapi.py @@ -39,6 +39,7 @@ def import_string_from_class(class_: Class, prefix: str = "") -> str: class EndpointCollection: """A bunch of endpoints grouped under a tag that will become a module""" + title: str tag: str endpoints: List["Endpoint"] = field(default_factory=list) parse_errors: List[ParseError] = field(default_factory=list) @@ -57,8 +58,9 @@ def from_data( operation: Optional[oai.Operation] = getattr(path_data, method) if operation is None: continue - tag = utils.PythonIdentifier(value=(operation.tags or ["default"])[0], prefix="tag") - collection = endpoints_by_tag.setdefault(tag, EndpointCollection(tag=tag)) + title = (operation.tags or ["default"])[0] + tag = utils.PythonIdentifier(value=title, prefix="tag") + collection = endpoints_by_tag.setdefault(tag, EndpointCollection(title=title, tag=tag)) endpoint, schemas, parameters = Endpoint.from_data( data=operation, path=path, diff --git a/openapi_python_client/templates/endpoints.md.jinja b/openapi_python_client/templates/endpoints.md.jinja new file mode 100644 index 000000000..2de4f28b0 --- /dev/null +++ b/openapi_python_client/templates/endpoints.md.jinja @@ -0,0 +1,35 @@ +# {{endpoint_collection.title}} + + +Method | HTTP Request | Description +------------- | ------------- | ------------- +{% for endpoint in endpoint_collection.endpoints %} +[**{{module_name(endpoint)}}**](#{{module_name(endpoint)}}) | {{endpoint.method.upper()}} {{endpoint.path}} | {{endpoint.description}} +{% endfor %} + + +{% for endpoint in endpoint_collection.endpoints %} +# **{{module_name(endpoint)}}** + +{% if endpoint.summary %}{{ endpoint.summary | wordwrap(100)}} + +{% endif -%} +{%- if endpoint.description %} {{ endpoint.description | wordwrap(100) }} + +{% endif %} + +{% set all_parameters = endpoint.list_all_parameters() %} +{% if all_parameters %} +### Parameters: +Name | Type | Description +------------ | ------------- | ------------- +{% for parameter in all_parameters %} +{{parameter.python_name}} | {% if parameter.is_base_type %}{{parameter.get_type_string(no_optional=True)}}{% else %}[{{parameter.get_type_string(no_optional=True)}}]({{parameter.get_type_string(no_optional=True)}}){% endif %} | {{parameter.description}} +{% endfor %} + +{% endif %} + +### Response Type +{{ endpoint.response_type() }} + +{% endfor %} \ No newline at end of file diff --git a/openapi_python_client/templates/model.md.jinja b/openapi_python_client/templates/model.md.jinja new file mode 100644 index 000000000..6409f1df2 --- /dev/null +++ b/openapi_python_client/templates/model.md.jinja @@ -0,0 +1,20 @@ +# {{ model.class_info.name }} + +{%- if model.description %}{{ model.description | wordwrap(120) }} + +{% endif %} + +{% if model.example %} +### Example: +{{ model.example | string | wordwrap(120) | indent(12) }} +{% endif %} + + +{% if model.required_properties or model.optional_properties %} +## Properties +Name | Type | Description +------------ | ------------- | ------------- +{% for property in model.required_properties + model.optional_properties %} +{{property.python_name}} | {{property.get_type_string()}} | {{property.description}} +{% endfor %}{% endif %} + From 7b7d889249d0ed260ebd7c49125df27a179ade55 Mon Sep 17 00:00:00 2001 From: v1nvn Date: Thu, 6 Apr 2023 12:17:47 +0530 Subject: [PATCH 5/9] revert: moved generated endpoints from api to root directory This reverts commit 39769bcf5ec2010101fddb701ce28221a7a1609a. --- .../my_test_api_client/api/__init__.py | 46 +++++++++++++++++++ .../{ => api}/default/__init__.py | 0 .../{ => api}/location/__init__.py | 0 .../parameter_references/__init__.py | 0 .../{ => api}/parameters/__init__.py | 0 .../{ => api}/responses/__init__.py | 0 .../{ => api}/tag1/__init__.py | 0 .../{ => api}/tests/__init__.py | 0 .../{ => api}/true_/__init__.py | 0 .../my_test_api_client/api/__init__.py | 1 + .../{ => api}/default/__init__.py | 0 .../default/get_common_parameters.py | 6 +-- .../default/post_common_parameters.py | 6 +-- .../{ => api}/location/__init__.py | 0 .../location/get_location_header_types.py | 10 ++-- .../get_location_query_optionality.py | 6 +-- .../parameter_references/__init__.py | 0 .../get_parameter_references_path_param.py | 6 +-- .../{ => api}/parameters/__init__.py | 0 ...lete_common_parameters_overriding_param.py | 6 +-- .../get_common_parameters_overriding_param.py | 6 +-- .../get_same_name_multiple_locations_param.py | 6 +-- .../parameters/multiple_path_parameters.py | 6 +-- .../{ => api}/responses/__init__.py | 0 ..._responses_unions_simple_before_complex.py | 8 ++-- .../{ => api}/tag1/__init__.py | 0 .../{ => api}/tag1/get_tag_with_number.py | 6 +-- .../{ => api}/tests/__init__.py | 0 .../{ => api}/tests/callback_test.py | 10 ++-- .../tests/defaults_tests_defaults_post.py | 12 ++--- .../tests/description_with_backslash.py | 6 +-- .../tests/get_basic_list_of_booleans.py | 6 +-- .../tests/get_basic_list_of_floats.py | 6 +-- .../tests/get_basic_list_of_integers.py | 6 +-- .../tests/get_basic_list_of_strings.py | 6 +-- .../{ => api}/tests/get_user_list.py | 14 +++--- .../tests/int_enum_tests_int_enum_post.py | 10 ++-- .../tests/json_body_tests_json_body_post.py | 10 ++-- .../no_response_tests_no_response_get.py | 6 +-- .../octet_stream_tests_octet_stream_get.py | 6 +-- .../{ => api}/tests/post_form_data.py | 8 ++-- .../{ => api}/tests/post_form_data_inline.py | 8 ++-- .../tests/post_tests_json_body_string.py | 8 ++-- .../{ => api}/tests/test_inline_objects.py | 10 ++-- ..._with_cookie_auth_token_with_cookie_get.py | 6 +-- ...d_content_tests_unsupported_content_get.py | 6 +-- .../tests/upload_file_tests_upload_post.py | 10 ++-- ...upload_multiple_files_tests_upload_post.py | 8 ++-- .../{ => api}/true_/__init__.py | 0 .../{ => api}/true_/false_.py | 6 +-- end_to_end_tests/test_end_to_end.py | 3 +- openapi_python_client/__init__.py | 7 ++- openapi_python_client/parser/openapi.py | 2 +- .../templates/api_init.py.jinja | 1 + .../templates/endpoint_module.py.jinja | 6 +-- tests/test_parser/test_openapi.py | 6 +-- 56 files changed, 183 insertions(+), 129 deletions(-) create mode 100644 end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/__init__.py rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{ => api}/default/__init__.py (100%) rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{ => api}/location/__init__.py (100%) rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{ => api}/parameter_references/__init__.py (100%) rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{ => api}/parameters/__init__.py (100%) rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{ => api}/responses/__init__.py (100%) rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{ => api}/tag1/__init__.py (100%) rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{ => api}/tests/__init__.py (100%) rename end_to_end_tests/custom-templates-golden-record/my_test_api_client/{ => api}/true_/__init__.py (100%) create mode 100644 end_to_end_tests/golden-record/my_test_api_client/api/__init__.py rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/default/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/default/get_common_parameters.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/default/post_common_parameters.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/location/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/location/get_location_header_types.py (94%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/location/get_location_query_optionality.py (98%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/parameter_references/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/parameter_references/get_parameter_references_path_param.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/parameters/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/parameters/delete_common_parameters_overriding_param.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/parameters/get_common_parameters_overriding_param.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/parameters/get_same_name_multiple_locations_param.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/parameters/multiple_path_parameters.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/responses/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/responses/post_responses_unions_simple_before_complex.py (95%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tag1/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tag1/get_tag_with_number.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/callback_test.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/defaults_tests_defaults_post.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/description_with_backslash.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/get_basic_list_of_booleans.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/get_basic_list_of_floats.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/get_basic_list_of_integers.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/get_basic_list_of_strings.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/get_user_list.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/int_enum_tests_int_enum_post.py (95%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/json_body_tests_json_body_post.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/no_response_tests_no_response_get.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/octet_stream_tests_octet_stream_get.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/post_form_data.py (95%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/post_form_data_inline.py (94%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/post_tests_json_body_string.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/test_inline_objects.py (94%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/token_with_cookie_auth_token_with_cookie_get.py (97%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/unsupported_content_tests_unsupported_content_get.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/upload_file_tests_upload_post.py (95%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/tests/upload_multiple_files_tests_upload_post.py (96%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/true_/__init__.py (100%) rename end_to_end_tests/golden-record/my_test_api_client/{ => api}/true_/false_.py (96%) create mode 100644 openapi_python_client/templates/api_init.py.jinja diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/__init__.py new file mode 100644 index 000000000..15e304e77 --- /dev/null +++ b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/__init__.py @@ -0,0 +1,46 @@ +""" Contains methods for accessing the API """ + +from typing import Type + +from .default import DefaultEndpoints +from .location import LocationEndpoints +from .parameter_references import ParameterReferencesEndpoints +from .parameters import ParametersEndpoints +from .responses import ResponsesEndpoints +from .tag1 import Tag1Endpoints +from .tests import TestsEndpoints +from .true_ import True_Endpoints + + +class MyTestApiClientApi: + @classmethod + def tests(cls) -> Type[TestsEndpoints]: + return TestsEndpoints + + @classmethod + def responses(cls) -> Type[ResponsesEndpoints]: + return ResponsesEndpoints + + @classmethod + def default(cls) -> Type[DefaultEndpoints]: + return DefaultEndpoints + + @classmethod + def parameters(cls) -> Type[ParametersEndpoints]: + return ParametersEndpoints + + @classmethod + def tag1(cls) -> Type[Tag1Endpoints]: + return Tag1Endpoints + + @classmethod + def location(cls) -> Type[LocationEndpoints]: + return LocationEndpoints + + @classmethod + def true_(cls) -> Type[True_Endpoints]: + return True_Endpoints + + @classmethod + def parameter_references(cls) -> Type[ParameterReferencesEndpoints]: + return ParameterReferencesEndpoints diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/default/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/default/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/default/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/default/__init__.py diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/location/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/location/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/location/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/location/__init__.py diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/parameter_references/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/parameter_references/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/parameter_references/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/parameter_references/__init__.py diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/parameters/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/parameters/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/parameters/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/parameters/__init__.py diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/responses/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/responses/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/responses/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/responses/__init__.py diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/tag1/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tag1/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/tag1/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tag1/__init__.py diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/tests/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tests/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/tests/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tests/__init__.py diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/true_/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/true_/__init__.py similarity index 100% rename from end_to_end_tests/custom-templates-golden-record/my_test_api_client/true_/__init__.py rename to end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/true_/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/__init__.py new file mode 100644 index 000000000..dc035f4ce --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/api/__init__.py @@ -0,0 +1 @@ +""" Contains methods for accessing the API """ diff --git a/end_to_end_tests/golden-record/my_test_api_client/default/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/default/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/api/default/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/default/get_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/default/get_common_parameters.py rename to end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py index b116d4717..a2478b80d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/default/get_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import UNSET, Response, Unset +from ... import errors +from ...client import Client +from ...types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/default/post_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/default/post_common_parameters.py rename to end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py index 33d40aa80..99e7f21d7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/default/post_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import UNSET, Response, Unset +from ... import errors +from ...client import Client +from ...types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/location/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/location/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/api/location/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/location/get_location_header_types.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py similarity index 94% rename from end_to_end_tests/golden-record/my_test_api_client/location/get_location_header_types.py rename to end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py index 766ee4604..9249eab31 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/location/get_location_header_types.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py @@ -3,11 +3,11 @@ import httpx -from .. import errors -from ..client import Client -from ..models.get_location_header_types_int_enum_header import GetLocationHeaderTypesIntEnumHeader -from ..models.get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader -from ..types import UNSET, Response, Unset +from ... import errors +from ...client import Client +from ...models.get_location_header_types_int_enum_header import GetLocationHeaderTypesIntEnumHeader +from ...models.get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader +from ...types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/location/get_location_query_optionality.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py similarity index 98% rename from end_to_end_tests/golden-record/my_test_api_client/location/get_location_query_optionality.py rename to end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py index 524e49a3b..0209c7319 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/location/get_location_query_optionality.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py @@ -4,9 +4,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import UNSET, Response, Unset +from ... import errors +from ...client import Client +from ...types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/parameter_references/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/parameter_references/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/parameter_references/get_parameter_references_path_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/parameter_references/get_parameter_references_path_param.py rename to end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py index f3e505216..b8c33ec94 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/parameter_references/get_parameter_references_path_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import UNSET, Response, Unset +from ... import errors +from ...client import Client +from ...types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/parameters/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/parameters/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/api/parameters/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/parameters/delete_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/parameters/delete_common_parameters_overriding_param.py rename to end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py index d7c282eb7..2816ec304 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/parameters/delete_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import UNSET, Response, Unset +from ... import errors +from ...client import Client +from ...types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/parameters/get_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/parameters/get_common_parameters_overriding_param.py rename to end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py index bbf4279cc..f1d97abc5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/parameters/get_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import UNSET, Response +from ... import errors +from ...client import Client +from ...types import UNSET, Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/parameters/get_same_name_multiple_locations_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/parameters/get_same_name_multiple_locations_param.py rename to end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py index 6198a5c01..ee9c35016 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/parameters/get_same_name_multiple_locations_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import UNSET, Response, Unset +from ... import errors +from ...client import Client +from ...types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/parameters/multiple_path_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/parameters/multiple_path_parameters.py rename to end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py index 2928637a4..347aa36b4 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/parameters/multiple_path_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import Response +from ... import errors +from ...client import Client +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/responses/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/responses/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/api/responses/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/responses/post_responses_unions_simple_before_complex.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py similarity index 95% rename from end_to_end_tests/golden-record/my_test_api_client/responses/post_responses_unions_simple_before_complex.py rename to end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py index 6f79e7575..9e43e738a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/responses/post_responses_unions_simple_before_complex.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py @@ -3,12 +3,12 @@ import httpx -from .. import errors -from ..client import Client -from ..models.post_responses_unions_simple_before_complex_response_200 import ( +from ... import errors +from ...client import Client +from ...models.post_responses_unions_simple_before_complex_response_200 import ( PostResponsesUnionsSimpleBeforeComplexResponse200, ) -from ..types import Response +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tag1/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/tag1/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tag1/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/tag1/get_tag_with_number.py b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/tag1/get_tag_with_number.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py index 1854e1e30..05f976082 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tag1/get_tag_with_number.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import Response +from ... import errors +from ...client import Client +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/tests/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/callback_test.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/tests/callback_test.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py index 3c6991db7..c68e64be7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/callback_test.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py @@ -3,11 +3,11 @@ import httpx -from .. import errors -from ..client import Client -from ..models.a_model import AModel -from ..models.http_validation_error import HTTPValidationError -from ..types import Response +from ... import errors +from ...client import Client +from ...models.a_model import AModel +from ...models.http_validation_error import HTTPValidationError +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/defaults_tests_defaults_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/tests/defaults_tests_defaults_post.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py index 95abefb47..1e1e4beb1 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/defaults_tests_defaults_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py @@ -5,12 +5,12 @@ import httpx from dateutil.parser import isoparse -from .. import errors -from ..client import Client -from ..models.an_enum import AnEnum -from ..models.http_validation_error import HTTPValidationError -from ..models.model_with_union_property import ModelWithUnionProperty -from ..types import UNSET, Response, Unset +from ... import errors +from ...client import Client +from ...models.an_enum import AnEnum +from ...models.http_validation_error import HTTPValidationError +from ...models.model_with_union_property import ModelWithUnionProperty +from ...types import UNSET, Response, Unset def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/description_with_backslash.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/tests/description_with_backslash.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py index dfce5c7df..31923ad11 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/description_with_backslash.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import Response +from ... import errors +from ...client import Client +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_booleans.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_booleans.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py index 160c5c329..f36aa9a9a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_booleans.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import Response +from ... import errors +from ...client import Client +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_floats.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_floats.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py index 7a80038dc..cfc9fec4d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_floats.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import Response +from ... import errors +from ...client import Client +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_integers.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_integers.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py index 78ae594a9..ab31821b5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_integers.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import Response +from ... import errors +from ...client import Client +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_strings.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_strings.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py index 4a3889e5d..4c62d518b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/get_basic_list_of_strings.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import Response +from ... import errors +from ...client import Client +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/get_user_list.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/tests/get_user_list.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py index 883356a76..cf0c1c375 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/get_user_list.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py @@ -4,13 +4,13 @@ import httpx -from .. import errors -from ..client import Client -from ..models.a_model import AModel -from ..models.an_enum import AnEnum -from ..models.an_enum_with_null import AnEnumWithNull -from ..models.http_validation_error import HTTPValidationError -from ..types import UNSET, Response +from ... import errors +from ...client import Client +from ...models.a_model import AModel +from ...models.an_enum import AnEnum +from ...models.an_enum_with_null import AnEnumWithNull +from ...models.http_validation_error import HTTPValidationError +from ...types import UNSET, Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/int_enum_tests_int_enum_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py similarity index 95% rename from end_to_end_tests/golden-record/my_test_api_client/tests/int_enum_tests_int_enum_post.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py index 483928158..d6777f84c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/int_enum_tests_int_enum_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py @@ -3,11 +3,11 @@ import httpx -from .. import errors -from ..client import Client -from ..models.an_int_enum import AnIntEnum -from ..models.http_validation_error import HTTPValidationError -from ..types import UNSET, Response +from ... import errors +from ...client import Client +from ...models.an_int_enum import AnIntEnum +from ...models.http_validation_error import HTTPValidationError +from ...types import UNSET, Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/json_body_tests_json_body_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/tests/json_body_tests_json_body_post.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py index 15d937055..d977511d4 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/json_body_tests_json_body_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py @@ -3,11 +3,11 @@ import httpx -from .. import errors -from ..client import Client -from ..models.a_model import AModel -from ..models.http_validation_error import HTTPValidationError -from ..types import Response +from ... import errors +from ...client import Client +from ...models.a_model import AModel +from ...models.http_validation_error import HTTPValidationError +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/no_response_tests_no_response_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/tests/no_response_tests_no_response_get.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py index dee0d50b2..075452512 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/no_response_tests_no_response_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import Response +from ... import errors +from ...client import Client +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/octet_stream_tests_octet_stream_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/tests/octet_stream_tests_octet_stream_get.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py index 3d7169156..a10ad95a7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/octet_stream_tests_octet_stream_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py @@ -4,9 +4,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import File, Response +from ... import errors +from ...client import Client +from ...types import File, Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/post_form_data.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py similarity index 95% rename from end_to_end_tests/golden-record/my_test_api_client/tests/post_form_data.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py index 0ccf91def..07c0b225e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/post_form_data.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py @@ -3,10 +3,10 @@ import httpx -from .. import errors -from ..client import Client -from ..models.a_form_data import AFormData -from ..types import Response +from ... import errors +from ...client import Client +from ...models.a_form_data import AFormData +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/post_form_data_inline.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py similarity index 94% rename from end_to_end_tests/golden-record/my_test_api_client/tests/post_form_data_inline.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py index 6a14c8a0f..e93a22986 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/post_form_data_inline.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py @@ -3,10 +3,10 @@ import httpx -from .. import errors -from ..client import Client -from ..models.post_form_data_inline_data import PostFormDataInlineData -from ..types import Response +from ... import errors +from ...client import Client +from ...models.post_form_data_inline_data import PostFormDataInlineData +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/post_tests_json_body_string.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/tests/post_tests_json_body_string.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py index ba458b5a9..7bd2c3b16 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/post_tests_json_body_string.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py @@ -3,10 +3,10 @@ import httpx -from .. import errors -from ..client import Client -from ..models.http_validation_error import HTTPValidationError -from ..types import Response +from ... import errors +from ...client import Client +from ...models.http_validation_error import HTTPValidationError +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/test_inline_objects.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py similarity index 94% rename from end_to_end_tests/golden-record/my_test_api_client/tests/test_inline_objects.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py index 06f697e43..7e3baf769 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/test_inline_objects.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py @@ -3,11 +3,11 @@ import httpx -from .. import errors -from ..client import Client -from ..models.test_inline_objects_json_body import TestInlineObjectsJsonBody -from ..models.test_inline_objects_response_200 import TestInlineObjectsResponse200 -from ..types import Response +from ... import errors +from ...client import Client +from ...models.test_inline_objects_json_body import TestInlineObjectsJsonBody +from ...models.test_inline_objects_response_200 import TestInlineObjectsResponse200 +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/token_with_cookie_auth_token_with_cookie_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py similarity index 97% rename from end_to_end_tests/golden-record/my_test_api_client/tests/token_with_cookie_auth_token_with_cookie_get.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py index 3a58175cc..994f1ee4e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/token_with_cookie_auth_token_with_cookie_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import Response +from ... import errors +from ...client import Client +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/unsupported_content_tests_unsupported_content_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/tests/unsupported_content_tests_unsupported_content_get.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py index d16bbc9c0..6b719cb38 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/unsupported_content_tests_unsupported_content_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import Response +from ... import errors +from ...client import Client +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/upload_file_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py similarity index 95% rename from end_to_end_tests/golden-record/my_test_api_client/tests/upload_file_tests_upload_post.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py index 0ce0268f2..8a49818fb 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/upload_file_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py @@ -3,11 +3,11 @@ import httpx -from .. import errors -from ..client import Client -from ..models.body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost -from ..models.http_validation_error import HTTPValidationError -from ..types import Response +from ... import errors +from ...client import Client +from ...models.body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost +from ...models.http_validation_error import HTTPValidationError +from ...types import Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests/upload_multiple_files_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/tests/upload_multiple_files_tests_upload_post.py rename to end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py index f37d3af5f..ff5d5132d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/tests/upload_multiple_files_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py @@ -3,10 +3,10 @@ import httpx -from .. import errors -from ..client import Client -from ..models.http_validation_error import HTTPValidationError -from ..types import File, Response +from ... import errors +from ...client import Client +from ...models.http_validation_error import HTTPValidationError +from ...types import File, Response def _get_kwargs( diff --git a/end_to_end_tests/golden-record/my_test_api_client/true_/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/true_/__init__.py similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/true_/__init__.py rename to end_to_end_tests/golden-record/my_test_api_client/api/true_/__init__.py diff --git a/end_to_end_tests/golden-record/my_test_api_client/true_/false_.py b/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py similarity index 96% rename from end_to_end_tests/golden-record/my_test_api_client/true_/false_.py rename to end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py index 930856e9a..05967d439 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/true_/false_.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py @@ -3,9 +3,9 @@ import httpx -from .. import errors -from ..client import Client -from ..types import UNSET, Response +from ... import errors +from ...client import Client +from ...types import UNSET, Response def _get_kwargs( diff --git a/end_to_end_tests/test_end_to_end.py b/end_to_end_tests/test_end_to_end.py index 312e6c5e3..6ad49fcb9 100644 --- a/end_to_end_tests/test_end_to_end.py +++ b/end_to_end_tests/test_end_to_end.py @@ -92,11 +92,12 @@ def test_end_to_end(): def test_custom_templates(): expected_differences = {} # key: path relative to generated directory, value: expected generated content - api_dir = Path("my_test_api_client") + api_dir = Path("my_test_api_client").joinpath("api") golden_tpls_root_dir = Path(__file__).parent.joinpath("custom-templates-golden-record") expected_difference_paths = [ Path("README.md"), + api_dir.joinpath("__init__.py"), ] for expected_difference_path in expected_difference_paths: diff --git a/openapi_python_client/__init__.py b/openapi_python_client/__init__.py index dc299a333..21eae5571 100644 --- a/openapi_python_client/__init__.py +++ b/openapi_python_client/__init__.py @@ -281,7 +281,12 @@ def _build_api(self) -> None: docs_dir.mkdir(exist_ok=True) # Generate endpoints - api_dir = self.package_dir + api_dir = self.package_dir / "api" + api_dir.mkdir() + api_init_path = api_dir / "__init__.py" + api_init_template = self.env.get_template("api_init.py.jinja") + api_init_path.write_text(api_init_template.render(), encoding=self.file_encoding) + endpoint_collections_by_tag = self.openapi.endpoint_collections_by_tag endpoint_template = self.env.get_template( "endpoint_module.py.jinja", globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"} diff --git a/openapi_python_client/parser/openapi.py b/openapi_python_client/parser/openapi.py index d5a55fded..95b3b905a 100644 --- a/openapi_python_client/parser/openapi.py +++ b/openapi_python_client/parser/openapi.py @@ -101,7 +101,7 @@ def generate_operation_id(*, path: str, method: str) -> str: return f"{method}_{clean_path}" -models_relative_prefix: str = ".." +models_relative_prefix: str = "..." # pylint: disable=too-many-instance-attributes diff --git a/openapi_python_client/templates/api_init.py.jinja b/openapi_python_client/templates/api_init.py.jinja new file mode 100644 index 000000000..dc035f4ce --- /dev/null +++ b/openapi_python_client/templates/api_init.py.jinja @@ -0,0 +1 @@ +""" Contains methods for accessing the API """ diff --git a/openapi_python_client/templates/endpoint_module.py.jinja b/openapi_python_client/templates/endpoint_module.py.jinja index 6c169bac7..3ea8991fb 100644 --- a/openapi_python_client/templates/endpoint_module.py.jinja +++ b/openapi_python_client/templates/endpoint_module.py.jinja @@ -3,9 +3,9 @@ from typing import Any, Dict, List, Optional, Union, cast import httpx -from ..client import AuthenticatedClient, Client -from ..types import Response, UNSET -from .. import errors +from ...client import AuthenticatedClient, Client +from ...types import Response, UNSET +from ... import errors {% for relative in endpoint.relative_imports %} {{ relative }} diff --git a/tests/test_parser/test_openapi.py b/tests/test_parser/test_openapi.py index ecee5167f..9cc7398d9 100644 --- a/tests/test_parser/test_openapi.py +++ b/tests/test_parser/test_openapi.py @@ -421,9 +421,9 @@ def test_add_body_happy(self, mocker): parse_multipart_body.assert_called_once_with( body=request_body, schemas=json_schemas, parent_name="name", config=config ) - form_body.get_imports.assert_called_once_with(prefix="..") - json_body.get_imports.assert_called_once_with(prefix="..") - multipart_body.get_imports.assert_called_once_with(prefix="..") + form_body.get_imports.assert_called_once_with(prefix="...") + json_body.get_imports.assert_called_once_with(prefix="...") + multipart_body.get_imports.assert_called_once_with(prefix="...") assert endpoint.relative_imports == {"import_3", form_body_imports, json_body_imports, multipart_body_imports} assert endpoint.json_body == json_body assert endpoint.form_body == form_body From 7fb62a830cd9f9f533a41b2384f3a8becf05426f Mon Sep 17 00:00:00 2001 From: v1nvn Date: Sun, 9 Apr 2023 21:06:28 +0530 Subject: [PATCH 6/9] fix: package name based client name --- end_to_end_tests/golden-record/README.md | 44 +++--- .../my_test_api_client/__init__.py | 7 +- .../api/default/get_common_parameters.py | 22 ++- .../api/default/post_common_parameters.py | 22 ++- .../api/location/get_location_header_types.py | 14 +- .../get_location_query_optionality.py | 14 +- .../get_parameter_references_path_param.py | 14 +- ...lete_common_parameters_overriding_param.py | 23 ++- .../get_common_parameters_overriding_param.py | 29 ++-- .../get_same_name_multiple_locations_param.py | 14 +- .../parameters/multiple_path_parameters.py | 39 ++---- ..._responses_unions_simple_before_complex.py | 29 ++-- .../api/tag1/get_tag_with_number.py | 27 ++-- .../api/tests/callback_test.py | 32 ++--- .../api/tests/defaults_tests_defaults_post.py | 18 +-- .../api/tests/description_with_backslash.py | 27 ++-- .../api/tests/get_basic_list_of_booleans.py | 37 ++--- .../api/tests/get_basic_list_of_floats.py | 37 ++--- .../api/tests/get_basic_list_of_integers.py | 37 ++--- .../api/tests/get_basic_list_of_strings.py | 37 ++--- .../api/tests/get_user_list.py | 20 +-- .../api/tests/int_enum_tests_int_enum_post.py | 32 ++--- .../tests/json_body_tests_json_body_post.py | 32 ++--- .../no_response_tests_no_response_get.py | 27 ++-- .../octet_stream_tests_octet_stream_get.py | 37 ++--- .../api/tests/post_form_data.py | 30 ++-- .../api/tests/post_form_data_inline.py | 28 ++-- .../api/tests/post_tests_json_body_string.py | 34 ++--- .../api/tests/test_inline_objects.py | 34 ++--- ..._with_cookie_auth_token_with_cookie_get.py | 30 ++-- ...d_content_tests_unsupported_content_get.py | 27 ++-- .../tests/upload_file_tests_upload_post.py | 32 ++--- ...upload_multiple_files_tests_upload_post.py | 32 ++--- .../my_test_api_client/api/true_/false_.py | 30 ++-- .../my_test_api_client/client.py | 111 ++++++++++----- .../my_test_api_client/default.py | 9 ++ .../my_test_api_client/location.py | 9 ++ .../parameter_references.py | 4 + .../my_test_api_client/parameters.py | 19 +++ .../my_test_api_client/responses.py | 8 ++ .../golden-record/my_test_api_client/tag1.py | 4 + .../golden-record/my_test_api_client/tests.py | 131 ++++++++++++++++++ .../golden-record/my_test_api_client/true_.py | 4 + openapi_python_client/__init__.py | 21 ++- .../templates/README.md.jinja | 44 +++--- .../{endpoints.md.jinja => api.md.jinja} | 0 openapi_python_client/templates/api.py.jinja | 21 +++ .../templates/client.py.jinja | 116 +++++++++++----- .../templates/endpoint_macros.py.jinja | 6 - .../templates/endpoint_module.py.jinja | 15 +- .../templates/package_init.py.jinja | 5 +- tests/test_parser/test_openapi.py | 10 +- 52 files changed, 762 insertions(+), 723 deletions(-) create mode 100644 end_to_end_tests/golden-record/my_test_api_client/default.py create mode 100644 end_to_end_tests/golden-record/my_test_api_client/location.py create mode 100644 end_to_end_tests/golden-record/my_test_api_client/parameter_references.py create mode 100644 end_to_end_tests/golden-record/my_test_api_client/parameters.py create mode 100644 end_to_end_tests/golden-record/my_test_api_client/responses.py create mode 100644 end_to_end_tests/golden-record/my_test_api_client/tag1.py create mode 100644 end_to_end_tests/golden-record/my_test_api_client/tests.py create mode 100644 end_to_end_tests/golden-record/my_test_api_client/true_.py rename openapi_python_client/templates/{endpoints.md.jinja => api.md.jinja} (100%) create mode 100644 openapi_python_client/templates/api.py.jinja diff --git a/end_to_end_tests/golden-record/README.md b/end_to_end_tests/golden-record/README.md index 3def2172e..ed2c3e4ae 100644 --- a/end_to_end_tests/golden-record/README.md +++ b/end_to_end_tests/golden-record/README.md @@ -2,49 +2,41 @@ A client library for accessing My Test API ## Usage -First, create a client: +First, configure a client: ```python -from my_test_api_client import Client +from my_test_api_client import MyTestApiClient -client = Client(base_url="https://api.example.com") -``` - -If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead: - -```python -from my_test_api_client import AuthenticatedClient - -client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken") +MyTestApiClient.configure(base_url="https://api.example.com", token="SuperSecretToken") ``` Now call your endpoint and use your models: ```python from my_test_api_client.models import MyDataModel -from my_test_api_client.api.my_tag import get_my_data_model +from my_test_api_client.my_tag import get_my_data_model from my_test_api_client.types import Response -my_data: MyDataModel = get_my_data_model.sync(client=client) +my_data: MyDataModel = get_my_data_model() # or if you need more info (e.g. status_code) -response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client) +response: Response[MyDataModel] = get_my_data_model_detailed() ``` Or do the same thing with an async version: ```python from my_test_api_client.models import MyDataModel -from my_test_api_client.api.my_tag import get_my_data_model +from my_test_api_client.my_tag import get_my_data_model from my_test_api_client.types import Response -my_data: MyDataModel = await get_my_data_model.asyncio(client=client) -response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client) +my_data: MyDataModel = await get_my_data_model_async() +response: Response[MyDataModel] = await get_my_data_model_async_detailed() ``` By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle. ```python -client = AuthenticatedClient( +MyTestApiClient.configure( base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl="/path/to/certificate_bundle.pem", @@ -54,25 +46,25 @@ client = AuthenticatedClient( You can also disable certificate validation altogether, but beware that **this is a security risk**. ```python -client = AuthenticatedClient( +MyTestApiClient.configure( base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl=False ) ``` -There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. +There are more settings on the generated `MyTestApiClient` class which let you control more runtime behavior, check out the docstring on that class for more info. Things to know: -1. Every path/method combo becomes a Python module with four functions: - 1. `sync`: Blocking request that returns parsed data (if successful) or `None` - 1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful. - 1. `asyncio`: Like `sync` but async instead of blocking - 1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking +1. Every path/method combo becomes provides you with four functions. For example: get_my_data_model has these methods: + 1. `get_my_data_model`: Blocking request that returns parsed data (if successful) or `None` + 1. `get_my_data_model_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful. + 1. `get_my_data_model_async`: Like `sync` but async instead of blocking + 1. `get_my_data_model_async_detailed`: Like `sync_detailed` but async instead of blocking 1. All path/query params, and bodies become method arguments. 1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above) -1. Any endpoint which did not have a tag will be in `my_test_api_client.api.default` +1. Any endpoint which did not have a tag will be in `my_test_api_client.default` ## Building / publishing this Client This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics: diff --git a/end_to_end_tests/golden-record/my_test_api_client/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/__init__.py index 530928e7a..aff096cbb 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/__init__.py @@ -1,7 +1,4 @@ """ A client library for accessing My Test API """ -from .client import AuthenticatedClient, Client +from .client import MyTestApiClient -__all__ = ( - "AuthenticatedClient", - "Client", -) +__all__ = ("MyTestApiClient",) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py index a2478b80d..4d36df4a7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py @@ -4,15 +4,11 @@ import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, - common: Union[Unset, None, str] = UNSET, -) -> Dict[str, Any]: +def _get_kwargs(*, common: Union[Unset, None, str] = UNSET, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/common_parameters".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -34,7 +30,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -43,7 +39,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -53,9 +49,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any def sync_detailed( - *, - client: Client, - common: Union[Unset, None, str] = UNSET, + *, common: Union[Unset, None, str] = UNSET, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Any]: """ Args: @@ -69,6 +63,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, common=common, @@ -83,9 +78,7 @@ def sync_detailed( async def asyncio_detailed( - *, - client: Client, - common: Union[Unset, None, str] = UNSET, + *, common: Union[Unset, None, str] = UNSET, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Any]: """ Args: @@ -99,6 +92,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, common=common, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py index 99e7f21d7..4a83e0a3a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py @@ -4,15 +4,11 @@ import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, - common: Union[Unset, None, str] = UNSET, -) -> Dict[str, Any]: +def _get_kwargs(*, common: Union[Unset, None, str] = UNSET, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/common_parameters".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -34,7 +30,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -43,7 +39,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -53,9 +49,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any def sync_detailed( - *, - client: Client, - common: Union[Unset, None, str] = UNSET, + *, common: Union[Unset, None, str] = UNSET, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Any]: """ Args: @@ -69,6 +63,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, common=common, @@ -83,9 +78,7 @@ def sync_detailed( async def asyncio_detailed( - *, - client: Client, - common: Union[Unset, None, str] = UNSET, + *, common: Union[Unset, None, str] = UNSET, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Any]: """ Args: @@ -99,6 +92,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, common=common, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py index 9249eab31..ae53a4b99 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py @@ -4,7 +4,7 @@ import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...models.get_location_header_types_int_enum_header import GetLocationHeaderTypesIntEnumHeader from ...models.get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader from ...types import UNSET, Response, Unset @@ -12,13 +12,13 @@ def _get_kwargs( *, - client: Client, boolean_header: Union[Unset, bool] = UNSET, string_header: Union[Unset, str] = UNSET, number_header: Union[Unset, float] = UNSET, integer_header: Union[Unset, int] = UNSET, int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, + client: MyTestApiClient, ) -> Dict[str, Any]: url = "{}/location/header/types".format(client.base_url) @@ -53,7 +53,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -62,7 +62,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -73,13 +73,13 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any def sync_detailed( *, - client: Client, boolean_header: Union[Unset, bool] = UNSET, string_header: Union[Unset, str] = UNSET, number_header: Union[Unset, float] = UNSET, integer_header: Union[Unset, int] = UNSET, int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Response[Any]: """ Args: @@ -98,6 +98,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, boolean_header=boolean_header, @@ -118,13 +119,13 @@ def sync_detailed( async def asyncio_detailed( *, - client: Client, boolean_header: Union[Unset, bool] = UNSET, string_header: Union[Unset, str] = UNSET, number_header: Union[Unset, float] = UNSET, integer_header: Union[Unset, int] = UNSET, int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Response[Any]: """ Args: @@ -143,6 +144,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, boolean_header=boolean_header, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py index 0209c7319..f9b9fecf9 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py @@ -5,17 +5,17 @@ import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...types import UNSET, Response, Unset def _get_kwargs( *, - client: Client, not_null_required: datetime.datetime, null_required: Union[Unset, None, datetime.datetime] = UNSET, null_not_required: Union[Unset, None, datetime.datetime] = UNSET, not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, + client: MyTestApiClient, ) -> Dict[str, Any]: url = "{}/location/query/optionality".format(client.base_url) @@ -58,7 +58,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -67,7 +67,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -78,11 +78,11 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any def sync_detailed( *, - client: Client, not_null_required: datetime.datetime, null_required: Union[Unset, None, datetime.datetime] = UNSET, null_not_required: Union[Unset, None, datetime.datetime] = UNSET, not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Response[Any]: """ Args: @@ -99,6 +99,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, not_null_required=not_null_required, @@ -117,11 +118,11 @@ def sync_detailed( async def asyncio_detailed( *, - client: Client, not_null_required: datetime.datetime, null_required: Union[Unset, None, datetime.datetime] = UNSET, null_not_required: Union[Unset, None, datetime.datetime] = UNSET, not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Response[Any]: """ Args: @@ -138,6 +139,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, not_null_required=not_null_required, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py index b8c33ec94..813bc990f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py @@ -4,18 +4,18 @@ import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...types import UNSET, Response, Unset def _get_kwargs( path_param: str, *, - client: Client, string_param: Union[Unset, None, str] = UNSET, integer_param: Union[Unset, None, int] = 0, header_param: Union[Unset, str] = UNSET, cookie_param: Union[Unset, str] = UNSET, + client: MyTestApiClient, ) -> Dict[str, Any]: url = "{}/parameter-references/{path_param}".format(client.base_url, path_param=path_param) @@ -46,7 +46,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -55,7 +55,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -67,11 +67,11 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any def sync_detailed( path_param: str, *, - client: Client, string_param: Union[Unset, None, str] = UNSET, integer_param: Union[Unset, None, int] = 0, header_param: Union[Unset, str] = UNSET, cookie_param: Union[Unset, str] = UNSET, + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Response[Any]: """Test different types of parameter references @@ -90,6 +90,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( path_param=path_param, client=client, @@ -110,11 +111,11 @@ def sync_detailed( async def asyncio_detailed( path_param: str, *, - client: Client, string_param: Union[Unset, None, str] = UNSET, integer_param: Union[Unset, None, int] = 0, header_param: Union[Unset, str] = UNSET, cookie_param: Union[Unset, str] = UNSET, + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Response[Any]: """Test different types of parameter references @@ -133,6 +134,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( path_param=path_param, client=client, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py index 2816ec304..5e47642a4 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py @@ -4,15 +4,12 @@ import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...types import UNSET, Response, Unset def _get_kwargs( - param_path: str, - *, - client: Client, - param_query: Union[Unset, None, str] = UNSET, + param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: MyTestApiClient ) -> Dict[str, Any]: url = "{}/common_parameters_overriding/{param}".format(client.base_url, param=param_path) @@ -35,7 +32,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -44,7 +41,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -54,10 +51,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any def sync_detailed( - param_path: str, - *, - client: Client, - param_query: Union[Unset, None, str] = UNSET, + param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Any]: """ Args: @@ -72,6 +66,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param_path=param_path, client=client, @@ -87,10 +82,7 @@ def sync_detailed( async def asyncio_detailed( - param_path: str, - *, - client: Client, - param_query: Union[Unset, None, str] = UNSET, + param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Any]: """ Args: @@ -105,6 +97,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param_path=param_path, client=client, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py index f1d97abc5..8d081d7d5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py @@ -1,19 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union import httpx from ... import errors -from ...client import Client -from ...types import UNSET, Response +from ...client import MyTestApiClient +from ...types import UNSET, Response, Unset -def _get_kwargs( - param_path: str, - *, - client: Client, - param_query: str = "overridden_in_GET", -) -> Dict[str, Any]: +def _get_kwargs(param_path: str, *, param_query: str = "overridden_in_GET", client: MyTestApiClient) -> Dict[str, Any]: url = "{}/common_parameters_overriding/{param}".format(client.base_url, param=param_path) headers: Dict[str, str] = client.get_headers() @@ -35,7 +30,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -44,7 +39,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -54,10 +49,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any def sync_detailed( - param_path: str, - *, - client: Client, - param_query: str = "overridden_in_GET", + param_path: str, *, param_query: str = "overridden_in_GET", client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Any]: """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code @@ -74,6 +66,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param_path=param_path, client=client, @@ -89,10 +82,7 @@ def sync_detailed( async def asyncio_detailed( - param_path: str, - *, - client: Client, - param_query: str = "overridden_in_GET", + param_path: str, *, param_query: str = "overridden_in_GET", client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Any]: """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code @@ -109,6 +99,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param_path=param_path, client=client, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py index ee9c35016..14f680a7f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py @@ -4,17 +4,17 @@ import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...types import UNSET, Response, Unset def _get_kwargs( param_path: str, *, - client: Client, param_query: Union[Unset, None, str] = UNSET, param_header: Union[Unset, str] = UNSET, param_cookie: Union[Unset, str] = UNSET, + client: MyTestApiClient, ) -> Dict[str, Any]: url = "{}/same-name-multiple-locations/{param}".format(client.base_url, param=param_path) @@ -43,7 +43,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -52,7 +52,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -64,10 +64,10 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any def sync_detailed( param_path: str, *, - client: Client, param_query: Union[Unset, None, str] = UNSET, param_header: Union[Unset, str] = UNSET, param_cookie: Union[Unset, str] = UNSET, + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Response[Any]: """ Args: @@ -84,6 +84,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param_path=param_path, client=client, @@ -103,10 +104,10 @@ def sync_detailed( async def asyncio_detailed( param_path: str, *, - client: Client, param_query: Union[Unset, None, str] = UNSET, param_header: Union[Unset, str] = UNSET, param_cookie: Union[Unset, str] = UNSET, + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Response[Any]: """ Args: @@ -123,6 +124,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param_path=param_path, client=client, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py index 347aa36b4..9a4e660e9 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py @@ -1,21 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union import httpx from ... import errors -from ...client import Client -from ...types import Response - - -def _get_kwargs( - param4: str, - param2: int, - param1: str, - param3: int, - *, - client: Client, -) -> Dict[str, Any]: +from ...client import MyTestApiClient +from ...types import UNSET, Response, Unset + + +def _get_kwargs(param4: str, param2: int, param1: str, param3: int, *, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/multiple-path-parameters/{param4}/something/{param2}/{param1}/{param3}".format( client.base_url, param4=param4, param2=param2, param1=param1, param3=param3 ) @@ -33,7 +26,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -42,7 +35,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,12 +45,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any def sync_detailed( - param4: str, - param2: int, - param1: str, - param3: int, - *, - client: Client, + param4: str, param2: int, param1: str, param3: int, *, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Any]: """ Args: @@ -74,6 +62,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param4=param4, param2=param2, @@ -91,12 +80,7 @@ def sync_detailed( async def asyncio_detailed( - param4: str, - param2: int, - param1: str, - param3: int, - *, - client: Client, + param4: str, param2: int, param1: str, param3: int, *, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Any]: """ Args: @@ -113,6 +97,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param4=param4, param2=param2, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py index 9e43e738a..002a85097 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py @@ -1,20 +1,17 @@ from http import HTTPStatus -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...models.post_responses_unions_simple_before_complex_response_200 import ( PostResponsesUnionsSimpleBeforeComplexResponse200, ) -from ...types import Response +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, -) -> Dict[str, Any]: +def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/responses/unions/simple_before_complex".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -31,7 +28,7 @@ def _get_kwargs( def _parse_response( - *, client: Client, response: httpx.Response + *, client: MyTestApiClient, response: httpx.Response ) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: if response.status_code == HTTPStatus.OK: response_200 = PostResponsesUnionsSimpleBeforeComplexResponse200.from_dict(response.json()) @@ -44,7 +41,7 @@ def _parse_response( def _build_response( - *, client: Client, response: httpx.Response + *, client: MyTestApiClient, response: httpx.Response ) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: return Response( status_code=HTTPStatus(response.status_code), @@ -55,8 +52,7 @@ def _build_response( def sync_detailed( - *, - client: Client, + *, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: """Regression test for #603 @@ -68,6 +64,7 @@ def sync_detailed( Response[PostResponsesUnionsSimpleBeforeComplexResponse200] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -81,8 +78,7 @@ def sync_detailed( def sync( - *, - client: Client, + *, client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: """Regression test for #603 @@ -100,8 +96,7 @@ def sync( async def asyncio_detailed( - *, - client: Client, + *, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: """Regression test for #603 @@ -113,6 +108,7 @@ async def asyncio_detailed( Response[PostResponsesUnionsSimpleBeforeComplexResponse200] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -124,8 +120,7 @@ async def asyncio_detailed( async def asyncio( - *, - client: Client, + *, client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: """Regression test for #603 diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py index 05f976082..8cdd0b48d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py @@ -1,17 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union import httpx from ... import errors -from ...client import Client -from ...types import Response +from ...client import MyTestApiClient +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, -) -> Dict[str, Any]: +def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tag_with_number".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -27,7 +24,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -36,7 +33,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -45,10 +42,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any ) -def sync_detailed( - *, - client: Client, -) -> Response[Any]: +def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: """ Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -58,6 +52,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -70,10 +65,7 @@ def sync_detailed( return _build_response(client=client, response=response) -async def asyncio_detailed( - *, - client: Client, -) -> Response[Any]: +async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: """ Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -83,6 +75,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py index c68e64be7..3904ee966 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py @@ -4,17 +4,13 @@ import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...models.a_model import AModel from ...models.http_validation_error import HTTPValidationError -from ...types import Response +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, - json_body: AModel, -) -> Dict[str, Any]: +def _get_kwargs(*, json_body: AModel, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/callback".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -33,7 +29,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 @@ -47,7 +43,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -57,9 +53,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Uni def sync_detailed( - *, - client: Client, - json_body: AModel, + *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Union[Any, HTTPValidationError]]: """Path with callback @@ -76,6 +70,7 @@ def sync_detailed( Response[Union[Any, HTTPValidationError]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -90,9 +85,7 @@ def sync_detailed( def sync( - *, - client: Client, - json_body: AModel, + *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[Union[Any, HTTPValidationError]]: """Path with callback @@ -116,9 +109,7 @@ def sync( async def asyncio_detailed( - *, - client: Client, - json_body: AModel, + *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Union[Any, HTTPValidationError]]: """Path with callback @@ -135,6 +126,7 @@ async def asyncio_detailed( Response[Union[Any, HTTPValidationError]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -147,9 +139,7 @@ async def asyncio_detailed( async def asyncio( - *, - client: Client, - json_body: AModel, + *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[Union[Any, HTTPValidationError]]: """Path with callback diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py index 1e1e4beb1..32f725ed2 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py @@ -6,7 +6,7 @@ from dateutil.parser import isoparse from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...models.an_enum import AnEnum from ...models.http_validation_error import HTTPValidationError from ...models.model_with_union_property import ModelWithUnionProperty @@ -15,7 +15,6 @@ def _get_kwargs( *, - client: Client, string_prop: str = "the default string", date_prop: datetime.date = isoparse("1010-10-10").date(), float_prop: float = 3.14, @@ -27,6 +26,7 @@ def _get_kwargs( enum_prop: AnEnum, model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", + client: MyTestApiClient, ) -> Dict[str, Any]: url = "{}/tests/defaults".format(client.base_url) @@ -100,7 +100,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 @@ -114,7 +114,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -125,7 +125,6 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Uni def sync_detailed( *, - client: Client, string_prop: str = "the default string", date_prop: datetime.date = isoparse("1010-10-10").date(), float_prop: float = 3.14, @@ -137,6 +136,7 @@ def sync_detailed( enum_prop: AnEnum, model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Response[Union[Any, HTTPValidationError]]: """Defaults @@ -161,6 +161,7 @@ def sync_detailed( Response[Union[Any, HTTPValidationError]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, string_prop=string_prop, @@ -186,7 +187,6 @@ def sync_detailed( def sync( *, - client: Client, string_prop: str = "the default string", date_prop: datetime.date = isoparse("1010-10-10").date(), float_prop: float = 3.14, @@ -198,6 +198,7 @@ def sync( enum_prop: AnEnum, model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Optional[Union[Any, HTTPValidationError]]: """Defaults @@ -240,7 +241,6 @@ def sync( async def asyncio_detailed( *, - client: Client, string_prop: str = "the default string", date_prop: datetime.date = isoparse("1010-10-10").date(), float_prop: float = 3.14, @@ -252,6 +252,7 @@ async def asyncio_detailed( enum_prop: AnEnum, model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Response[Union[Any, HTTPValidationError]]: """Defaults @@ -276,6 +277,7 @@ async def asyncio_detailed( Response[Union[Any, HTTPValidationError]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, string_prop=string_prop, @@ -299,7 +301,6 @@ async def asyncio_detailed( async def asyncio( *, - client: Client, string_prop: str = "the default string", date_prop: datetime.date = isoparse("1010-10-10").date(), float_prop: float = 3.14, @@ -311,6 +312,7 @@ async def asyncio( enum_prop: AnEnum, model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Optional[Union[Any, HTTPValidationError]]: """Defaults diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py index 31923ad11..f65a73cae 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py @@ -1,17 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union import httpx from ... import errors -from ...client import Client -from ...types import Response +from ...client import MyTestApiClient +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, -) -> Dict[str, Any]: +def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/description-with-backslash".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -27,7 +24,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -36,7 +33,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -45,10 +42,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any ) -def sync_detailed( - *, - client: Client, -) -> Response[Any]: +def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: r""" Test description with \ Test description with \ @@ -61,6 +55,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -73,10 +68,7 @@ def sync_detailed( return _build_response(client=client, response=response) -async def asyncio_detailed( - *, - client: Client, -) -> Response[Any]: +async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: r""" Test description with \ Test description with \ @@ -89,6 +81,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py index f36aa9a9a..4c63ce29b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py @@ -1,17 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, cast +from typing import Any, Dict, List, Optional, Union, cast import httpx from ... import errors -from ...client import Client -from ...types import Response +from ...client import MyTestApiClient +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, -) -> Dict[str, Any]: +def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/basic_lists/booleans".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -27,7 +24,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[List[bool]]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[List[bool]]: if response.status_code == HTTPStatus.OK: response_200 = cast(List[bool], response.json()) @@ -38,7 +35,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Lis return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[List[bool]]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[List[bool]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -47,10 +44,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Lis ) -def sync_detailed( - *, - client: Client, -) -> Response[List[bool]]: +def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[bool]]: """Get Basic List Of Booleans Get a list of booleans @@ -63,6 +57,7 @@ def sync_detailed( Response[List[bool]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -75,10 +70,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync( - *, - client: Client, -) -> Optional[List[bool]]: +def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[bool]]: """Get Basic List Of Booleans Get a list of booleans @@ -96,10 +88,7 @@ def sync( ).parsed -async def asyncio_detailed( - *, - client: Client, -) -> Response[List[bool]]: +async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[bool]]: """Get Basic List Of Booleans Get a list of booleans @@ -112,6 +101,7 @@ async def asyncio_detailed( Response[List[bool]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -122,10 +112,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - *, - client: Client, -) -> Optional[List[bool]]: +async def asyncio(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[bool]]: """Get Basic List Of Booleans Get a list of booleans diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py index cfc9fec4d..0b47eef84 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py @@ -1,17 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, cast +from typing import Any, Dict, List, Optional, Union, cast import httpx from ... import errors -from ...client import Client -from ...types import Response +from ...client import MyTestApiClient +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, -) -> Dict[str, Any]: +def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/basic_lists/floats".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -27,7 +24,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[List[float]]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[List[float]]: if response.status_code == HTTPStatus.OK: response_200 = cast(List[float], response.json()) @@ -38,7 +35,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Lis return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[List[float]]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[List[float]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -47,10 +44,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Lis ) -def sync_detailed( - *, - client: Client, -) -> Response[List[float]]: +def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[float]]: """Get Basic List Of Floats Get a list of floats @@ -63,6 +57,7 @@ def sync_detailed( Response[List[float]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -75,10 +70,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync( - *, - client: Client, -) -> Optional[List[float]]: +def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[float]]: """Get Basic List Of Floats Get a list of floats @@ -96,10 +88,7 @@ def sync( ).parsed -async def asyncio_detailed( - *, - client: Client, -) -> Response[List[float]]: +async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[float]]: """Get Basic List Of Floats Get a list of floats @@ -112,6 +101,7 @@ async def asyncio_detailed( Response[List[float]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -122,10 +112,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - *, - client: Client, -) -> Optional[List[float]]: +async def asyncio(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[float]]: """Get Basic List Of Floats Get a list of floats diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py index ab31821b5..9739e5aa4 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py @@ -1,17 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, cast +from typing import Any, Dict, List, Optional, Union, cast import httpx from ... import errors -from ...client import Client -from ...types import Response +from ...client import MyTestApiClient +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, -) -> Dict[str, Any]: +def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/basic_lists/integers".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -27,7 +24,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[List[int]]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[List[int]]: if response.status_code == HTTPStatus.OK: response_200 = cast(List[int], response.json()) @@ -38,7 +35,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Lis return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[List[int]]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[List[int]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -47,10 +44,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Lis ) -def sync_detailed( - *, - client: Client, -) -> Response[List[int]]: +def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[int]]: """Get Basic List Of Integers Get a list of integers @@ -63,6 +57,7 @@ def sync_detailed( Response[List[int]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -75,10 +70,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync( - *, - client: Client, -) -> Optional[List[int]]: +def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[int]]: """Get Basic List Of Integers Get a list of integers @@ -96,10 +88,7 @@ def sync( ).parsed -async def asyncio_detailed( - *, - client: Client, -) -> Response[List[int]]: +async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[int]]: """Get Basic List Of Integers Get a list of integers @@ -112,6 +101,7 @@ async def asyncio_detailed( Response[List[int]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -122,10 +112,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - *, - client: Client, -) -> Optional[List[int]]: +async def asyncio(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[int]]: """Get Basic List Of Integers Get a list of integers diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py index 4c62d518b..31da99599 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py @@ -1,17 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, cast +from typing import Any, Dict, List, Optional, Union, cast import httpx from ... import errors -from ...client import Client -from ...types import Response +from ...client import MyTestApiClient +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, -) -> Dict[str, Any]: +def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/basic_lists/strings".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -27,7 +24,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[List[str]]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[List[str]]: if response.status_code == HTTPStatus.OK: response_200 = cast(List[str], response.json()) @@ -38,7 +35,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Lis return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[List[str]]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[List[str]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -47,10 +44,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Lis ) -def sync_detailed( - *, - client: Client, -) -> Response[List[str]]: +def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[str]]: """Get Basic List Of Strings Get a list of strings @@ -63,6 +57,7 @@ def sync_detailed( Response[List[str]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -75,10 +70,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync( - *, - client: Client, -) -> Optional[List[str]]: +def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[str]]: """Get Basic List Of Strings Get a list of strings @@ -96,10 +88,7 @@ def sync( ).parsed -async def asyncio_detailed( - *, - client: Client, -) -> Response[List[str]]: +async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[str]]: """Get Basic List Of Strings Get a list of strings @@ -112,6 +101,7 @@ async def asyncio_detailed( Response[List[str]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -122,10 +112,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - *, - client: Client, -) -> Optional[List[str]]: +async def asyncio(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[str]]: """Get Basic List Of Strings Get a list of strings diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py index cf0c1c375..aa5beddbb 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py @@ -5,21 +5,21 @@ import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...models.a_model import AModel from ...models.an_enum import AnEnum from ...models.an_enum_with_null import AnEnumWithNull from ...models.http_validation_error import HTTPValidationError -from ...types import UNSET, Response +from ...types import UNSET, Response, Unset def _get_kwargs( *, - client: Client, an_enum_value: List[AnEnum], an_enum_value_with_null: List[Optional[AnEnumWithNull]], an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], + client: MyTestApiClient, ) -> Dict[str, Any]: url = "{}/tests/".format(client.base_url) @@ -72,7 +72,7 @@ def _get_kwargs( def _parse_response( - *, client: Client, response: httpx.Response + *, client: MyTestApiClient, response: httpx.Response ) -> Optional[Union[HTTPValidationError, List["AModel"]]]: if response.status_code == HTTPStatus.OK: response_200 = [] @@ -98,7 +98,7 @@ def _parse_response( def _build_response( - *, client: Client, response: httpx.Response + *, client: MyTestApiClient, response: httpx.Response ) -> Response[Union[HTTPValidationError, List["AModel"]]]: return Response( status_code=HTTPStatus(response.status_code), @@ -110,11 +110,11 @@ def _build_response( def sync_detailed( *, - client: Client, an_enum_value: List[AnEnum], an_enum_value_with_null: List[Optional[AnEnumWithNull]], an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Response[Union[HTTPValidationError, List["AModel"]]]: """Get List @@ -134,6 +134,7 @@ def sync_detailed( Response[Union[HTTPValidationError, List['AModel']]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, an_enum_value=an_enum_value, @@ -152,11 +153,11 @@ def sync_detailed( def sync( *, - client: Client, an_enum_value: List[AnEnum], an_enum_value_with_null: List[Optional[AnEnumWithNull]], an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Optional[Union[HTTPValidationError, List["AModel"]]]: """Get List @@ -187,11 +188,11 @@ def sync( async def asyncio_detailed( *, - client: Client, an_enum_value: List[AnEnum], an_enum_value_with_null: List[Optional[AnEnumWithNull]], an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Response[Union[HTTPValidationError, List["AModel"]]]: """Get List @@ -211,6 +212,7 @@ async def asyncio_detailed( Response[Union[HTTPValidationError, List['AModel']]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, an_enum_value=an_enum_value, @@ -227,11 +229,11 @@ async def asyncio_detailed( async def asyncio( *, - client: Client, an_enum_value: List[AnEnum], an_enum_value_with_null: List[Optional[AnEnumWithNull]], an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], + client: Union[MyTestApiClient, Unset] = UNSET, ) -> Optional[Union[HTTPValidationError, List["AModel"]]]: """Get List diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py index d6777f84c..26c3f3a5d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py @@ -4,17 +4,13 @@ import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...models.an_int_enum import AnIntEnum from ...models.http_validation_error import HTTPValidationError -from ...types import UNSET, Response +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, - int_enum: AnIntEnum, -) -> Dict[str, Any]: +def _get_kwargs(*, int_enum: AnIntEnum, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/int_enum".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -38,7 +34,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 @@ -52,7 +48,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -62,9 +58,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Uni def sync_detailed( - *, - client: Client, - int_enum: AnIntEnum, + *, int_enum: AnIntEnum, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Union[Any, HTTPValidationError]]: """Int Enum @@ -79,6 +73,7 @@ def sync_detailed( Response[Union[Any, HTTPValidationError]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, int_enum=int_enum, @@ -93,9 +88,7 @@ def sync_detailed( def sync( - *, - client: Client, - int_enum: AnIntEnum, + *, int_enum: AnIntEnum, client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[Union[Any, HTTPValidationError]]: """Int Enum @@ -117,9 +110,7 @@ def sync( async def asyncio_detailed( - *, - client: Client, - int_enum: AnIntEnum, + *, int_enum: AnIntEnum, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Union[Any, HTTPValidationError]]: """Int Enum @@ -134,6 +125,7 @@ async def asyncio_detailed( Response[Union[Any, HTTPValidationError]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, int_enum=int_enum, @@ -146,9 +138,7 @@ async def asyncio_detailed( async def asyncio( - *, - client: Client, - int_enum: AnIntEnum, + *, int_enum: AnIntEnum, client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[Union[Any, HTTPValidationError]]: """Int Enum diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py index d977511d4..763823866 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py @@ -4,17 +4,13 @@ import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...models.a_model import AModel from ...models.http_validation_error import HTTPValidationError -from ...types import Response +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, - json_body: AModel, -) -> Dict[str, Any]: +def _get_kwargs(*, json_body: AModel, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/json_body".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -33,7 +29,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 @@ -47,7 +43,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -57,9 +53,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Uni def sync_detailed( - *, - client: Client, - json_body: AModel, + *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Union[Any, HTTPValidationError]]: """Json Body @@ -76,6 +70,7 @@ def sync_detailed( Response[Union[Any, HTTPValidationError]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -90,9 +85,7 @@ def sync_detailed( def sync( - *, - client: Client, - json_body: AModel, + *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[Union[Any, HTTPValidationError]]: """Json Body @@ -116,9 +109,7 @@ def sync( async def asyncio_detailed( - *, - client: Client, - json_body: AModel, + *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Union[Any, HTTPValidationError]]: """Json Body @@ -135,6 +126,7 @@ async def asyncio_detailed( Response[Union[Any, HTTPValidationError]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -147,9 +139,7 @@ async def asyncio_detailed( async def asyncio( - *, - client: Client, - json_body: AModel, + *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[Union[Any, HTTPValidationError]]: """Json Body diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py index 075452512..305b09e14 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py @@ -1,17 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union import httpx from ... import errors -from ...client import Client -from ...types import Response +from ...client import MyTestApiClient +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, -) -> Dict[str, Any]: +def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/no_response".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -27,7 +24,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -36,7 +33,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -45,10 +42,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any ) -def sync_detailed( - *, - client: Client, -) -> Response[Any]: +def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: """No Response Raises: @@ -59,6 +53,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -71,10 +66,7 @@ def sync_detailed( return _build_response(client=client, response=response) -async def asyncio_detailed( - *, - client: Client, -) -> Response[Any]: +async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: """No Response Raises: @@ -85,6 +77,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py index a10ad95a7..3def18598 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py @@ -1,18 +1,15 @@ from http import HTTPStatus from io import BytesIO -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union import httpx from ... import errors -from ...client import Client -from ...types import File, Response +from ...client import MyTestApiClient +from ...types import UNSET, File, Response, Unset -def _get_kwargs( - *, - client: Client, -) -> Dict[str, Any]: +def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/octet_stream".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -28,7 +25,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[File]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[File]: if response.status_code == HTTPStatus.OK: response_200 = File(payload=BytesIO(response.content)) @@ -39,7 +36,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Fil return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[File]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[File]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -48,10 +45,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Fil ) -def sync_detailed( - *, - client: Client, -) -> Response[File]: +def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[File]: """Octet Stream Raises: @@ -62,6 +56,7 @@ def sync_detailed( Response[File] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -74,10 +69,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync( - *, - client: Client, -) -> Optional[File]: +def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[File]: """Octet Stream Raises: @@ -93,10 +85,7 @@ def sync( ).parsed -async def asyncio_detailed( - *, - client: Client, -) -> Response[File]: +async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[File]: """Octet Stream Raises: @@ -107,6 +96,7 @@ async def asyncio_detailed( Response[File] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -117,10 +107,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - *, - client: Client, -) -> Optional[File]: +async def asyncio(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[File]: """Octet Stream Raises: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py index 07c0b225e..7a4ff7d34 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py @@ -1,19 +1,15 @@ from http import HTTPStatus -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...models.a_form_data import AFormData -from ...types import Response +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, - form_data: AFormData, -) -> Dict[str, Any]: +def _get_kwargs(*, form_data: AFormData, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/post_form_data".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -30,7 +26,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -39,7 +35,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -48,11 +44,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any ) -def sync_detailed( - *, - client: Client, - form_data: AFormData, -) -> Response[Any]: +def sync_detailed(*, form_data: AFormData, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: """Post form data Post form data @@ -65,6 +57,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, form_data=form_data, @@ -78,11 +71,7 @@ def sync_detailed( return _build_response(client=client, response=response) -async def asyncio_detailed( - *, - client: Client, - form_data: AFormData, -) -> Response[Any]: +async def asyncio_detailed(*, form_data: AFormData, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: """Post form data Post form data @@ -95,6 +84,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, form_data=form_data, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py index e93a22986..505b99345 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py @@ -1,19 +1,15 @@ from http import HTTPStatus -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...models.post_form_data_inline_data import PostFormDataInlineData -from ...types import Response +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, - form_data: PostFormDataInlineData, -) -> Dict[str, Any]: +def _get_kwargs(*, form_data: PostFormDataInlineData, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/post_form_data_inline".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -30,7 +26,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -39,7 +35,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -48,11 +44,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any ) -def sync_detailed( - *, - client: Client, - form_data: PostFormDataInlineData, -) -> Response[Any]: +def sync_detailed(*, form_data: PostFormDataInlineData, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: """Post form data (inline schema) Post form data (inline schema) @@ -65,6 +57,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, form_data=form_data, @@ -79,9 +72,7 @@ def sync_detailed( async def asyncio_detailed( - *, - client: Client, - form_data: PostFormDataInlineData, + *, form_data: PostFormDataInlineData, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Any]: """Post form data (inline schema) @@ -95,6 +86,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, form_data=form_data, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py index 7bd2c3b16..81ec9867b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py @@ -4,16 +4,12 @@ import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...models.http_validation_error import HTTPValidationError -from ...types import Response +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, - json_body: str, -) -> Dict[str, Any]: +def _get_kwargs(*, json_body: str, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/json_body/string".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -32,7 +28,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, str]]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Union[HTTPValidationError, str]]: if response.status_code == HTTPStatus.OK: response_200 = cast(str, response.json()) return response_200 @@ -46,7 +42,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, str]]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Union[HTTPValidationError, str]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -56,9 +52,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Uni def sync_detailed( - *, - client: Client, - json_body: str, + *, json_body: str, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Union[HTTPValidationError, str]]: """Json Body Which is String @@ -73,6 +67,7 @@ def sync_detailed( Response[Union[HTTPValidationError, str]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -86,11 +81,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync( - *, - client: Client, - json_body: str, -) -> Optional[Union[HTTPValidationError, str]]: +def sync(*, json_body: str, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[Union[HTTPValidationError, str]]: """Json Body Which is String Args: @@ -111,9 +102,7 @@ def sync( async def asyncio_detailed( - *, - client: Client, - json_body: str, + *, json_body: str, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Union[HTTPValidationError, str]]: """Json Body Which is String @@ -128,6 +117,7 @@ async def asyncio_detailed( Response[Union[HTTPValidationError, str]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -140,9 +130,7 @@ async def asyncio_detailed( async def asyncio( - *, - client: Client, - json_body: str, + *, json_body: str, client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[Union[HTTPValidationError, str]]: """Json Body Which is String diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py index 7e3baf769..5a4f15d18 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py @@ -1,20 +1,16 @@ from http import HTTPStatus -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...models.test_inline_objects_json_body import TestInlineObjectsJsonBody from ...models.test_inline_objects_response_200 import TestInlineObjectsResponse200 -from ...types import Response +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, - json_body: TestInlineObjectsJsonBody, -) -> Dict[str, Any]: +def _get_kwargs(*, json_body: TestInlineObjectsJsonBody, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/inline_objects".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -33,7 +29,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[TestInlineObjectsResponse200]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[TestInlineObjectsResponse200]: if response.status_code == HTTPStatus.OK: response_200 = TestInlineObjectsResponse200.from_dict(response.json()) @@ -44,7 +40,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Tes return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[TestInlineObjectsResponse200]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[TestInlineObjectsResponse200]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -54,9 +50,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Tes def sync_detailed( - *, - client: Client, - json_body: TestInlineObjectsJsonBody, + *, json_body: TestInlineObjectsJsonBody, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[TestInlineObjectsResponse200]: """Test Inline Objects @@ -71,6 +65,7 @@ def sync_detailed( Response[TestInlineObjectsResponse200] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -85,9 +80,7 @@ def sync_detailed( def sync( - *, - client: Client, - json_body: TestInlineObjectsJsonBody, + *, json_body: TestInlineObjectsJsonBody, client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[TestInlineObjectsResponse200]: """Test Inline Objects @@ -109,9 +102,7 @@ def sync( async def asyncio_detailed( - *, - client: Client, - json_body: TestInlineObjectsJsonBody, + *, json_body: TestInlineObjectsJsonBody, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[TestInlineObjectsResponse200]: """Test Inline Objects @@ -126,6 +117,7 @@ async def asyncio_detailed( Response[TestInlineObjectsResponse200] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -138,9 +130,7 @@ async def asyncio_detailed( async def asyncio( - *, - client: Client, - json_body: TestInlineObjectsJsonBody, + *, json_body: TestInlineObjectsJsonBody, client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[TestInlineObjectsResponse200]: """Test Inline Objects diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py index 994f1ee4e..552b09389 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py @@ -1,18 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union import httpx from ... import errors -from ...client import Client -from ...types import Response +from ...client import MyTestApiClient +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, - my_token: str, -) -> Dict[str, Any]: +def _get_kwargs(*, my_token: str, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/auth/token_with_cookie".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -30,7 +26,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if response.status_code == HTTPStatus.UNAUTHORIZED: @@ -41,7 +37,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -50,11 +46,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any ) -def sync_detailed( - *, - client: Client, - my_token: str, -) -> Response[Any]: +def sync_detailed(*, my_token: str, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: """TOKEN_WITH_COOKIE Test optional cookie parameters @@ -70,6 +62,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, my_token=my_token, @@ -83,11 +76,7 @@ def sync_detailed( return _build_response(client=client, response=response) -async def asyncio_detailed( - *, - client: Client, - my_token: str, -) -> Response[Any]: +async def asyncio_detailed(*, my_token: str, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: """TOKEN_WITH_COOKIE Test optional cookie parameters @@ -103,6 +92,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, my_token=my_token, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py index 6b719cb38..883168c9c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py @@ -1,17 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union import httpx from ... import errors -from ...client import Client -from ...types import Response +from ...client import MyTestApiClient +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, -) -> Dict[str, Any]: +def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/unsupported_content".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -27,7 +24,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -36,7 +33,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -45,10 +42,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any ) -def sync_detailed( - *, - client: Client, -) -> Response[Any]: +def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: """Unsupported Content Raises: @@ -59,6 +53,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -71,10 +66,7 @@ def sync_detailed( return _build_response(client=client, response=response) -async def asyncio_detailed( - *, - client: Client, -) -> Response[Any]: +async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: """Unsupported Content Raises: @@ -85,6 +77,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py index 8a49818fb..6f93be5ab 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py @@ -4,17 +4,13 @@ import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...models.body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost from ...models.http_validation_error import HTTPValidationError -from ...types import Response +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, - multipart_data: BodyUploadFileTestsUploadPost, -) -> Dict[str, Any]: +def _get_kwargs(*, multipart_data: BodyUploadFileTestsUploadPost, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/upload".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -33,7 +29,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 @@ -47,7 +43,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -57,9 +53,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Uni def sync_detailed( - *, - client: Client, - multipart_data: BodyUploadFileTestsUploadPost, + *, multipart_data: BodyUploadFileTestsUploadPost, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Union[Any, HTTPValidationError]]: """Upload File @@ -76,6 +70,7 @@ def sync_detailed( Response[Union[Any, HTTPValidationError]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, multipart_data=multipart_data, @@ -90,9 +85,7 @@ def sync_detailed( def sync( - *, - client: Client, - multipart_data: BodyUploadFileTestsUploadPost, + *, multipart_data: BodyUploadFileTestsUploadPost, client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[Union[Any, HTTPValidationError]]: """Upload File @@ -116,9 +109,7 @@ def sync( async def asyncio_detailed( - *, - client: Client, - multipart_data: BodyUploadFileTestsUploadPost, + *, multipart_data: BodyUploadFileTestsUploadPost, client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Union[Any, HTTPValidationError]]: """Upload File @@ -135,6 +126,7 @@ async def asyncio_detailed( Response[Union[Any, HTTPValidationError]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, multipart_data=multipart_data, @@ -147,9 +139,7 @@ async def asyncio_detailed( async def asyncio( - *, - client: Client, - multipart_data: BodyUploadFileTestsUploadPost, + *, multipart_data: BodyUploadFileTestsUploadPost, client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[Union[Any, HTTPValidationError]]: """Upload File diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py index ff5d5132d..32bafedd4 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py @@ -4,16 +4,12 @@ import httpx from ... import errors -from ...client import Client +from ...client import MyTestApiClient from ...models.http_validation_error import HTTPValidationError -from ...types import File, Response +from ...types import UNSET, File, Response, Unset -def _get_kwargs( - *, - client: Client, - multipart_data: List[File], -) -> Dict[str, Any]: +def _get_kwargs(*, multipart_data: List[File], client: MyTestApiClient) -> Dict[str, Any]: url = "{}/tests/upload/multiple".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -36,7 +32,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 @@ -50,7 +46,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -60,9 +56,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Uni def sync_detailed( - *, - client: Client, - multipart_data: List[File], + *, multipart_data: List[File], client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Union[Any, HTTPValidationError]]: """Upload multiple files @@ -79,6 +73,7 @@ def sync_detailed( Response[Union[Any, HTTPValidationError]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, multipart_data=multipart_data, @@ -93,9 +88,7 @@ def sync_detailed( def sync( - *, - client: Client, - multipart_data: List[File], + *, multipart_data: List[File], client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[Union[Any, HTTPValidationError]]: """Upload multiple files @@ -119,9 +112,7 @@ def sync( async def asyncio_detailed( - *, - client: Client, - multipart_data: List[File], + *, multipart_data: List[File], client: Union[MyTestApiClient, Unset] = UNSET ) -> Response[Union[Any, HTTPValidationError]]: """Upload multiple files @@ -138,6 +129,7 @@ async def asyncio_detailed( Response[Union[Any, HTTPValidationError]] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, multipart_data=multipart_data, @@ -150,9 +142,7 @@ async def asyncio_detailed( async def asyncio( - *, - client: Client, - multipart_data: List[File], + *, multipart_data: List[File], client: Union[MyTestApiClient, Unset] = UNSET ) -> Optional[Union[Any, HTTPValidationError]]: """Upload multiple files diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py b/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py index 05967d439..1661caf38 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py @@ -1,18 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union import httpx from ... import errors -from ...client import Client -from ...types import UNSET, Response +from ...client import MyTestApiClient +from ...types import UNSET, Response, Unset -def _get_kwargs( - *, - client: Client, - import_: str, -) -> Dict[str, Any]: +def _get_kwargs(*, import_: str, client: MyTestApiClient) -> Dict[str, Any]: url = "{}/naming/keywords".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -34,7 +30,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -43,7 +39,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,11 +48,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Any ) -def sync_detailed( - *, - client: Client, - import_: str, -) -> Response[Any]: +def sync_detailed(*, import_: str, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: """ Args: import_ (str): @@ -69,6 +61,7 @@ def sync_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, import_=import_, @@ -82,11 +75,7 @@ def sync_detailed( return _build_response(client=client, response=response) -async def asyncio_detailed( - *, - client: Client, - import_: str, -) -> Response[Any]: +async def asyncio_detailed(*, import_: str, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: """ Args: import_ (str): @@ -99,6 +88,7 @@ async def asyncio_detailed( Response[Any] """ + client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, import_=import_, diff --git a/end_to_end_tests/golden-record/my_test_api_client/client.py b/end_to_end_tests/golden-record/my_test_api_client/client.py index 2f45c655b..4f63a031d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/client.py +++ b/end_to_end_tests/golden-record/my_test_api_client/client.py @@ -1,11 +1,9 @@ import ssl +import threading from typing import Dict, Union -import attr - -@attr.s(auto_attribs=True) -class Client: +class MyTestApiClient: """A class for keeping track of data related to the API Attributes: @@ -21,46 +19,85 @@ class Client: follow_redirects: Whether or not to follow redirects. Default value is False. """ - base_url: str - cookies: Dict[str, str] = attr.ib(factory=dict, kw_only=True) - headers: Dict[str, str] = attr.ib(factory=dict, kw_only=True) - timeout: float = attr.ib(5.0, kw_only=True) - verify_ssl: Union[str, bool, ssl.SSLContext] = attr.ib(True, kw_only=True) - raise_on_unexpected_status: bool = attr.ib(False, kw_only=True) - follow_redirects: bool = attr.ib(False, kw_only=True) + __lock__ = threading.RLock() + __instance__: Union["MyTestApiClient", None] = None - def get_headers(self) -> Dict[str, str]: - """Get headers to be used in all endpoints""" - return {**self.headers} + @classmethod + def configure( + cls, + base_url: str = "http://localhost:8080", + cookies: Union[Dict[str, str], None] = None, + headers: Union[Dict[str, str], None] = None, + timeout: float = 5.0, + verify_ssl: Union[str, bool, ssl.SSLContext] = True, + raise_on_unexpected_status: bool = False, + follow_redirects: bool = False, + token: Union[str, None] = None, + prefix: str = "Bearer", + auth_header_name: str = "Authorization", + ) -> "MyTestApiClient": + cookies = cookies if cookies is not None else {} + headers = headers if headers is not None else {} - def with_headers(self, headers: Dict[str, str]) -> "Client": - """Get a new client matching this one with additional headers""" - return attr.evolve(self, headers={**self.headers, **headers}) + with cls.__lock__: + cls.__instance__ = cls( + base_url=base_url, + cookies=cookies, + headers=headers, + timeout=timeout, + verify_ssl=verify_ssl, + raise_on_unexpected_status=raise_on_unexpected_status, + follow_redirects=follow_redirects, + token=token, + prefix=prefix, + auth_header_name=auth_header_name, + ) - def get_cookies(self) -> Dict[str, str]: - return {**self.cookies} - - def with_cookies(self, cookies: Dict[str, str]) -> "Client": - """Get a new client matching this one with additional cookies""" - return attr.evolve(self, cookies={**self.cookies, **cookies}) - - def get_timeout(self) -> float: - return self.timeout + return cls.__instance__ - def with_timeout(self, timeout: float) -> "Client": - """Get a new client matching this one with a new timeout (in seconds)""" - return attr.evolve(self, timeout=timeout) + def __init__( + self, + base_url: str, + cookies: Union[Dict[str, str], None] = None, + headers: Union[Dict[str, str], None] = None, + timeout: float = 5.0, + verify_ssl: Union[str, bool, ssl.SSLContext] = True, + raise_on_unexpected_status: bool = False, + follow_redirects: bool = False, + token: Union[str, None] = None, + prefix: str = "Bearer", + auth_header_name: str = "Authorization", + ): + cookies = cookies if cookies is not None else {} + headers = headers if headers is not None else {} + self.base_url = base_url + self.cookies = cookies + self.headers = headers + self.timeout = timeout + self.verify_ssl = verify_ssl + self.raise_on_unexpected_status = raise_on_unexpected_status + self.follow_redirects = follow_redirects + self.token = token + self.prefix = prefix + self.auth_header_name = auth_header_name -@attr.s(auto_attribs=True) -class AuthenticatedClient(Client): - """A Client which has been authenticated for use on secured endpoints""" - - token: str - prefix: str = "Bearer" - auth_header_name: str = "Authorization" + @classmethod + def instance(cls) -> "MyTestApiClient": + if cls.__instance__ is None: + return cls.configure() + else: + return cls.__instance__ def get_headers(self) -> Dict[str, str]: - """Get headers to be used in authenticated endpoints""" + """Get headers to be used in all endpoints""" + if not self.token: + return {**self.headers} auth_header_value = f"{self.prefix} {self.token}" if self.prefix else self.token return {self.auth_header_name: auth_header_value, **self.headers} + + def get_cookies(self) -> Dict[str, str]: + return {**self.cookies} + + def get_timeout(self) -> float: + return self.timeout diff --git a/end_to_end_tests/golden-record/my_test_api_client/default.py b/end_to_end_tests/golden-record/my_test_api_client/default.py new file mode 100644 index 000000000..cf7604f03 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/default.py @@ -0,0 +1,9 @@ +from .api.default import get_common_parameters as __get_common_parameters +from .api.default import post_common_parameters as __post_common_parameters + +get_common_parameters = __get_common_parameters.sync_detailed +get_common_parameters_async = __get_common_parameters.asyncio_detailed + + +post_common_parameters = __post_common_parameters.sync_detailed +post_common_parameters_async = __post_common_parameters.asyncio_detailed diff --git a/end_to_end_tests/golden-record/my_test_api_client/location.py b/end_to_end_tests/golden-record/my_test_api_client/location.py new file mode 100644 index 000000000..2769eabce --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/location.py @@ -0,0 +1,9 @@ +from .api.location import get_location_header_types as __get_location_header_types +from .api.location import get_location_query_optionality as __get_location_query_optionality + +get_location_query_optionality = __get_location_query_optionality.sync_detailed +get_location_query_optionality_async = __get_location_query_optionality.asyncio_detailed + + +get_location_header_types = __get_location_header_types.sync_detailed +get_location_header_types_async = __get_location_header_types.asyncio_detailed diff --git a/end_to_end_tests/golden-record/my_test_api_client/parameter_references.py b/end_to_end_tests/golden-record/my_test_api_client/parameter_references.py new file mode 100644 index 000000000..f3409ddf4 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/parameter_references.py @@ -0,0 +1,4 @@ +from .api.parameter_references import get_parameter_references_path_param as __get_parameter_references_path_param + +get_parameter_references_path_param = __get_parameter_references_path_param.sync_detailed +get_parameter_references_path_param_async = __get_parameter_references_path_param.asyncio_detailed diff --git a/end_to_end_tests/golden-record/my_test_api_client/parameters.py b/end_to_end_tests/golden-record/my_test_api_client/parameters.py new file mode 100644 index 000000000..935a1744f --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/parameters.py @@ -0,0 +1,19 @@ +from .api.parameters import delete_common_parameters_overriding_param as __delete_common_parameters_overriding_param +from .api.parameters import get_common_parameters_overriding_param as __get_common_parameters_overriding_param +from .api.parameters import get_same_name_multiple_locations_param as __get_same_name_multiple_locations_param +from .api.parameters import multiple_path_parameters as __multiple_path_parameters + +get_common_parameters_overriding_param = __get_common_parameters_overriding_param.sync_detailed +get_common_parameters_overriding_param_async = __get_common_parameters_overriding_param.asyncio_detailed + + +delete_common_parameters_overriding_param = __delete_common_parameters_overriding_param.sync_detailed +delete_common_parameters_overriding_param_async = __delete_common_parameters_overriding_param.asyncio_detailed + + +get_same_name_multiple_locations_param = __get_same_name_multiple_locations_param.sync_detailed +get_same_name_multiple_locations_param_async = __get_same_name_multiple_locations_param.asyncio_detailed + + +multiple_path_parameters = __multiple_path_parameters.sync_detailed +multiple_path_parameters_async = __multiple_path_parameters.asyncio_detailed diff --git a/end_to_end_tests/golden-record/my_test_api_client/responses.py b/end_to_end_tests/golden-record/my_test_api_client/responses.py new file mode 100644 index 000000000..a207897ee --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/responses.py @@ -0,0 +1,8 @@ +from .api.responses import post_responses_unions_simple_before_complex as __post_responses_unions_simple_before_complex + +post_responses_unions_simple_before_complex = __post_responses_unions_simple_before_complex.sync +post_responses_unions_simple_before_complex_detailed = __post_responses_unions_simple_before_complex.sync_detailed +post_responses_unions_simple_before_complex_async = __post_responses_unions_simple_before_complex.asyncio +post_responses_unions_simple_before_complex_async_detailed = ( + __post_responses_unions_simple_before_complex.asyncio_detailed +) diff --git a/end_to_end_tests/golden-record/my_test_api_client/tag1.py b/end_to_end_tests/golden-record/my_test_api_client/tag1.py new file mode 100644 index 000000000..ec78db61f --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/tag1.py @@ -0,0 +1,4 @@ +from .api.tag1 import get_tag_with_number as __get_tag_with_number + +get_tag_with_number = __get_tag_with_number.sync_detailed +get_tag_with_number_async = __get_tag_with_number.asyncio_detailed diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests.py b/end_to_end_tests/golden-record/my_test_api_client/tests.py new file mode 100644 index 000000000..f858d514c --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/tests.py @@ -0,0 +1,131 @@ +from .api.tests import callback_test as __callback_test +from .api.tests import defaults_tests_defaults_post as __defaults_tests_defaults_post +from .api.tests import description_with_backslash as __description_with_backslash +from .api.tests import get_basic_list_of_booleans as __get_basic_list_of_booleans +from .api.tests import get_basic_list_of_floats as __get_basic_list_of_floats +from .api.tests import get_basic_list_of_integers as __get_basic_list_of_integers +from .api.tests import get_basic_list_of_strings as __get_basic_list_of_strings +from .api.tests import get_user_list as __get_user_list +from .api.tests import int_enum_tests_int_enum_post as __int_enum_tests_int_enum_post +from .api.tests import json_body_tests_json_body_post as __json_body_tests_json_body_post +from .api.tests import no_response_tests_no_response_get as __no_response_tests_no_response_get +from .api.tests import octet_stream_tests_octet_stream_get as __octet_stream_tests_octet_stream_get +from .api.tests import post_form_data as __post_form_data +from .api.tests import post_form_data_inline as __post_form_data_inline +from .api.tests import post_tests_json_body_string as __post_tests_json_body_string +from .api.tests import test_inline_objects as __test_inline_objects +from .api.tests import token_with_cookie_auth_token_with_cookie_get as __token_with_cookie_auth_token_with_cookie_get +from .api.tests import ( + unsupported_content_tests_unsupported_content_get as __unsupported_content_tests_unsupported_content_get, +) +from .api.tests import upload_file_tests_upload_post as __upload_file_tests_upload_post +from .api.tests import upload_multiple_files_tests_upload_post as __upload_multiple_files_tests_upload_post + +get_user_list = __get_user_list.sync +get_user_list_detailed = __get_user_list.sync_detailed +get_user_list_async = __get_user_list.asyncio +get_user_list_async_detailed = __get_user_list.asyncio_detailed + + +get_basic_list_of_strings = __get_basic_list_of_strings.sync +get_basic_list_of_strings_detailed = __get_basic_list_of_strings.sync_detailed +get_basic_list_of_strings_async = __get_basic_list_of_strings.asyncio +get_basic_list_of_strings_async_detailed = __get_basic_list_of_strings.asyncio_detailed + + +get_basic_list_of_integers = __get_basic_list_of_integers.sync +get_basic_list_of_integers_detailed = __get_basic_list_of_integers.sync_detailed +get_basic_list_of_integers_async = __get_basic_list_of_integers.asyncio +get_basic_list_of_integers_async_detailed = __get_basic_list_of_integers.asyncio_detailed + + +get_basic_list_of_floats = __get_basic_list_of_floats.sync +get_basic_list_of_floats_detailed = __get_basic_list_of_floats.sync_detailed +get_basic_list_of_floats_async = __get_basic_list_of_floats.asyncio +get_basic_list_of_floats_async_detailed = __get_basic_list_of_floats.asyncio_detailed + + +get_basic_list_of_booleans = __get_basic_list_of_booleans.sync +get_basic_list_of_booleans_detailed = __get_basic_list_of_booleans.sync_detailed +get_basic_list_of_booleans_async = __get_basic_list_of_booleans.asyncio +get_basic_list_of_booleans_async_detailed = __get_basic_list_of_booleans.asyncio_detailed + + +post_form_data = __post_form_data.sync_detailed +post_form_data_async = __post_form_data.asyncio_detailed + + +post_form_data_inline = __post_form_data_inline.sync_detailed +post_form_data_inline_async = __post_form_data_inline.asyncio_detailed + + +upload_file_tests_upload_post = __upload_file_tests_upload_post.sync +upload_file_tests_upload_post_detailed = __upload_file_tests_upload_post.sync_detailed +upload_file_tests_upload_post_async = __upload_file_tests_upload_post.asyncio +upload_file_tests_upload_post_async_detailed = __upload_file_tests_upload_post.asyncio_detailed + + +upload_multiple_files_tests_upload_post = __upload_multiple_files_tests_upload_post.sync +upload_multiple_files_tests_upload_post_detailed = __upload_multiple_files_tests_upload_post.sync_detailed +upload_multiple_files_tests_upload_post_async = __upload_multiple_files_tests_upload_post.asyncio +upload_multiple_files_tests_upload_post_async_detailed = __upload_multiple_files_tests_upload_post.asyncio_detailed + + +json_body_tests_json_body_post = __json_body_tests_json_body_post.sync +json_body_tests_json_body_post_detailed = __json_body_tests_json_body_post.sync_detailed +json_body_tests_json_body_post_async = __json_body_tests_json_body_post.asyncio +json_body_tests_json_body_post_async_detailed = __json_body_tests_json_body_post.asyncio_detailed + + +post_tests_json_body_string = __post_tests_json_body_string.sync +post_tests_json_body_string_detailed = __post_tests_json_body_string.sync_detailed +post_tests_json_body_string_async = __post_tests_json_body_string.asyncio +post_tests_json_body_string_async_detailed = __post_tests_json_body_string.asyncio_detailed + + +defaults_tests_defaults_post = __defaults_tests_defaults_post.sync +defaults_tests_defaults_post_detailed = __defaults_tests_defaults_post.sync_detailed +defaults_tests_defaults_post_async = __defaults_tests_defaults_post.asyncio +defaults_tests_defaults_post_async_detailed = __defaults_tests_defaults_post.asyncio_detailed + + +octet_stream_tests_octet_stream_get = __octet_stream_tests_octet_stream_get.sync +octet_stream_tests_octet_stream_get_detailed = __octet_stream_tests_octet_stream_get.sync_detailed +octet_stream_tests_octet_stream_get_async = __octet_stream_tests_octet_stream_get.asyncio +octet_stream_tests_octet_stream_get_async_detailed = __octet_stream_tests_octet_stream_get.asyncio_detailed + + +no_response_tests_no_response_get = __no_response_tests_no_response_get.sync_detailed +no_response_tests_no_response_get_async = __no_response_tests_no_response_get.asyncio_detailed + + +unsupported_content_tests_unsupported_content_get = __unsupported_content_tests_unsupported_content_get.sync_detailed +unsupported_content_tests_unsupported_content_get_async = ( + __unsupported_content_tests_unsupported_content_get.asyncio_detailed +) + + +int_enum_tests_int_enum_post = __int_enum_tests_int_enum_post.sync +int_enum_tests_int_enum_post_detailed = __int_enum_tests_int_enum_post.sync_detailed +int_enum_tests_int_enum_post_async = __int_enum_tests_int_enum_post.asyncio +int_enum_tests_int_enum_post_async_detailed = __int_enum_tests_int_enum_post.asyncio_detailed + + +test_inline_objects = __test_inline_objects.sync +test_inline_objects_detailed = __test_inline_objects.sync_detailed +test_inline_objects_async = __test_inline_objects.asyncio +test_inline_objects_async_detailed = __test_inline_objects.asyncio_detailed + + +token_with_cookie_auth_token_with_cookie_get = __token_with_cookie_auth_token_with_cookie_get.sync_detailed +token_with_cookie_auth_token_with_cookie_get_async = __token_with_cookie_auth_token_with_cookie_get.asyncio_detailed + + +callback_test = __callback_test.sync +callback_test_detailed = __callback_test.sync_detailed +callback_test_async = __callback_test.asyncio +callback_test_async_detailed = __callback_test.asyncio_detailed + + +description_with_backslash = __description_with_backslash.sync_detailed +description_with_backslash_async = __description_with_backslash.asyncio_detailed diff --git a/end_to_end_tests/golden-record/my_test_api_client/true_.py b/end_to_end_tests/golden-record/my_test_api_client/true_.py new file mode 100644 index 000000000..10e82e068 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/true_.py @@ -0,0 +1,4 @@ +from .api.true_ import false_ as __false_ + +false_ = __false_.sync_detailed +false__async = __false_.asyncio_detailed diff --git a/openapi_python_client/__init__.py b/openapi_python_client/__init__.py index 21eae5571..6e20acf31 100644 --- a/openapi_python_client/__init__.py +++ b/openapi_python_client/__init__.py @@ -87,6 +87,7 @@ def __init__( self.project_dir /= self.project_name self.package_name: str = config.package_name_override or self.project_name.replace("-", "_") + self.client_name: str = utils.ClassName(self.package_name, config.field_prefix) self.package_dir: Path = self.project_dir / self.package_name self.package_description: str = utils.remove_string_escapes( f"A client library for accessing {self.openapi.title}" @@ -99,6 +100,7 @@ def __init__( python_identifier=lambda x: utils.PythonIdentifier(x, config.field_prefix), class_name=lambda x: utils.ClassName(x, config.field_prefix), package_name=self.package_name, + client_name=self.client_name, package_dir=self.package_dir, package_description=self.package_description, package_version=self.version, @@ -291,8 +293,11 @@ def _build_api(self) -> None: endpoint_template = self.env.get_template( "endpoint_module.py.jinja", globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"} ) - endpoints_doc_template = self.env.get_template( - "endpoints.md.jinja", globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"} + api_template = self.env.get_template( + "api.py.jinja", globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"} + ) + api_doc_template = self.env.get_template( + "api.md.jinja", globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"} ) for tag, collection in endpoint_collections_by_tag.items(): tag_dir = api_dir / tag @@ -316,10 +321,16 @@ def module_name(endpoint): ), encoding=self.file_encoding, ) + + api_path = self.package_dir / f"{tag}.py" + api_path.write_text( + api_template.render(endpoint_collection=collection, module_name=module_name), + encoding=self.file_encoding + ) - doc_path = docs_dir / f"{utils.ClassName(collection.title, '')}.md" - doc_path.write_text( - endpoints_doc_template.render(endpoint_collection=collection, module_name=module_name), + api_doc_path = docs_dir / f"{utils.ClassName(collection.title, '')}.md" + api_doc_path.write_text( + api_doc_template.render(endpoint_collection=collection, module_name=module_name), encoding=self.file_encoding ) diff --git a/openapi_python_client/templates/README.md.jinja b/openapi_python_client/templates/README.md.jinja index 1d50c8d2a..fcd9ba05e 100644 --- a/openapi_python_client/templates/README.md.jinja +++ b/openapi_python_client/templates/README.md.jinja @@ -2,49 +2,41 @@ {{ package_description }} ## Usage -First, create a client: +First, configure a client: ```python -from {{ package_name }} import Client +from {{ package_name }} import {{ client_name }} -client = Client(base_url="https://api.example.com") -``` - -If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead: - -```python -from {{ package_name }} import AuthenticatedClient - -client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken") +{{ client_name }}.configure(base_url="https://api.example.com", token="SuperSecretToken") ``` Now call your endpoint and use your models: ```python from {{ package_name }}.models import MyDataModel -from {{ package_name }}.api.my_tag import get_my_data_model +from {{ package_name }}.my_tag import get_my_data_model from {{ package_name }}.types import Response -my_data: MyDataModel = get_my_data_model.sync(client=client) +my_data: MyDataModel = get_my_data_model() # or if you need more info (e.g. status_code) -response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client) +response: Response[MyDataModel] = get_my_data_model_detailed() ``` Or do the same thing with an async version: ```python from {{ package_name }}.models import MyDataModel -from {{ package_name }}.api.my_tag import get_my_data_model +from {{ package_name }}.my_tag import get_my_data_model from {{ package_name }}.types import Response -my_data: MyDataModel = await get_my_data_model.asyncio(client=client) -response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client) +my_data: MyDataModel = await get_my_data_model_async() +response: Response[MyDataModel] = await get_my_data_model_async_detailed() ``` By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle. ```python -client = AuthenticatedClient( +{{ client_name }}.configure( base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl="/path/to/certificate_bundle.pem", @@ -54,25 +46,25 @@ client = AuthenticatedClient( You can also disable certificate validation altogether, but beware that **this is a security risk**. ```python -client = AuthenticatedClient( +{{ client_name }}.configure( base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl=False ) ``` -There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. +There are more settings on the generated `{{ client_name }}` class which let you control more runtime behavior, check out the docstring on that class for more info. Things to know: -1. Every path/method combo becomes a Python module with four functions: - 1. `sync`: Blocking request that returns parsed data (if successful) or `None` - 1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful. - 1. `asyncio`: Like `sync` but async instead of blocking - 1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking +1. Every path/method combo becomes provides you with four functions. For example: get_my_data_model has these methods: + 1. `get_my_data_model`: Blocking request that returns parsed data (if successful) or `None` + 1. `get_my_data_model_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful. + 1. `get_my_data_model_async`: Like `sync` but async instead of blocking + 1. `get_my_data_model_async_detailed`: Like `sync_detailed` but async instead of blocking 1. All path/query params, and bodies become method arguments. 1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above) -1. Any endpoint which did not have a tag will be in `{{ package_name }}.api.default` +1. Any endpoint which did not have a tag will be in `{{ package_name }}.default` ## Building / publishing this Client This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics: diff --git a/openapi_python_client/templates/endpoints.md.jinja b/openapi_python_client/templates/api.md.jinja similarity index 100% rename from openapi_python_client/templates/endpoints.md.jinja rename to openapi_python_client/templates/api.md.jinja diff --git a/openapi_python_client/templates/api.py.jinja b/openapi_python_client/templates/api.py.jinja new file mode 100644 index 000000000..464228740 --- /dev/null +++ b/openapi_python_client/templates/api.py.jinja @@ -0,0 +1,21 @@ +from .api.{{ endpoint_collection.tag }} import ( +{% for endpoint in endpoint_collection.endpoints %} +{{ module_name(endpoint) }} as __{{ module_name(endpoint) }}, +{% endfor %} +) + + +{% for endpoint in endpoint_collection.endpoints %} +{% set mod = module_name(endpoint) %} + +{% if (endpoint.responses | length > 0) and endpoint.response_type() != "Any" %} +{{ mod }} = __{{ mod }}.sync +{{ mod }}_detailed = __{{ mod }}.sync_detailed +{{ mod }}_async = __{{ mod }}.asyncio +{{ mod }}_async_detailed = __{{ mod }}.asyncio_detailed +{% else %} +{{ mod }} = __{{ mod }}.sync_detailed +{{ mod }}_async = __{{ mod }}.asyncio_detailed +{% endif %} + +{% endfor %} diff --git a/openapi_python_client/templates/client.py.jinja b/openapi_python_client/templates/client.py.jinja index c6e6b2305..0a0383ce5 100644 --- a/openapi_python_client/templates/client.py.jinja +++ b/openapi_python_client/templates/client.py.jinja @@ -1,10 +1,10 @@ import ssl +import threading from typing import Dict, Union -import attr -@attr.s(auto_attribs=True) -class Client: - """ A class for keeping track of data related to the API + +class {{ client_name }}: + """A class for keeping track of data related to the API Attributes: base_url: The base URL for the API, all requests are made to a relative path to this URL @@ -18,46 +18,86 @@ class Client: status code that was not documented in the source OpenAPI document. follow_redirects: Whether or not to follow redirects. Default value is False. """ + __lock__ = threading.RLock() + __instance__: Union["{{ client_name }}", None] = None - base_url: str - cookies: Dict[str, str] = attr.ib(factory=dict, kw_only=True) - headers: Dict[str, str] = attr.ib(factory=dict, kw_only=True) - timeout: float = attr.ib(5.0, kw_only=True) - verify_ssl: Union[str, bool, ssl.SSLContext] = attr.ib(True, kw_only=True) - raise_on_unexpected_status: bool = attr.ib(False, kw_only=True) - follow_redirects: bool = attr.ib(False, kw_only=True) - - def get_headers(self) -> Dict[str, str]: - """ Get headers to be used in all endpoints """ - return {**self.headers} - - def with_headers(self, headers: Dict[str, str]) -> "Client": - """ Get a new client matching this one with additional headers """ - return attr.evolve(self, headers={**self.headers, **headers}) - - def get_cookies(self) -> Dict[str, str]: - return {**self.cookies} - - def with_cookies(self, cookies: Dict[str, str]) -> "Client": - """ Get a new client matching this one with additional cookies """ - return attr.evolve(self, cookies={**self.cookies, **cookies}) + @classmethod + def configure( + cls, + base_url: str = "http://localhost:8080", + cookies: Union[Dict[str, str], None] = None, + headers: Union[Dict[str, str], None] = None, + timeout: float = 5.0, + verify_ssl: Union[str, bool, ssl.SSLContext] = True, + raise_on_unexpected_status: bool = False, + follow_redirects: bool = False, + token: Union[str, None] = None, + prefix: str = "Bearer", + auth_header_name: str = "Authorization", + ) -> "{{ client_name }}": + cookies = cookies if cookies is not None else {} + headers = headers if headers is not None else {} - def get_timeout(self) -> float: - return self.timeout + with cls.__lock__: + cls.__instance__ = cls( + base_url=base_url, + cookies=cookies, + headers=headers, + timeout=timeout, + verify_ssl=verify_ssl, + raise_on_unexpected_status=raise_on_unexpected_status, + follow_redirects=follow_redirects, + token=token, + prefix=prefix, + auth_header_name=auth_header_name, + ) + + return cls.__instance__ - def with_timeout(self, timeout: float) -> "Client": - """ Get a new client matching this one with a new timeout (in seconds) """ - return attr.evolve(self, timeout=timeout) + def __init__( + self, + base_url: str, + cookies: Union[Dict[str, str], None] = None, + headers: Union[Dict[str, str], None] = None, + timeout: float = 5.0, + verify_ssl: Union[str, bool, ssl.SSLContext] = True, + raise_on_unexpected_status: bool = False, + follow_redirects: bool = False, + token: Union[str, None] = None, + prefix: str = "Bearer", + auth_header_name: str = "Authorization", + ): + cookies = cookies if cookies is not None else {} + headers = headers if headers is not None else {} + + self.base_url = base_url + self.cookies = cookies + self.headers = headers + self.timeout = timeout + self.verify_ssl = verify_ssl + self.raise_on_unexpected_status = raise_on_unexpected_status + self.follow_redirects = follow_redirects + self.token = token + self.prefix = prefix + self.auth_header_name = auth_header_name -@attr.s(auto_attribs=True) -class AuthenticatedClient(Client): - """ A Client which has been authenticated for use on secured endpoints """ + @classmethod + def instance(cls) -> "{{ client_name }}": + if cls.__instance__ is None: + return cls.configure() + else: + return cls.__instance__ - token: str - prefix: str = "Bearer" - auth_header_name: str = "Authorization" def get_headers(self) -> Dict[str, str]: - """Get headers to be used in authenticated endpoints""" + """Get headers to be used in all endpoints""" + if not self.token: + return {**self.headers} auth_header_value = f"{self.prefix} {self.token}" if self.prefix else self.token return {self.auth_header_name: auth_header_value, **self.headers} + + def get_cookies(self) -> Dict[str, str]: + return {**self.cookies} + + def get_timeout(self) -> float: + return self.timeout diff --git a/openapi_python_client/templates/endpoint_macros.py.jinja b/openapi_python_client/templates/endpoint_macros.py.jinja index fde2e018a..7a3d339d8 100644 --- a/openapi_python_client/templates/endpoint_macros.py.jinja +++ b/openapi_python_client/templates/endpoint_macros.py.jinja @@ -84,12 +84,6 @@ params = {k: v for k, v in params.items() if v is not UNSET and v is not None} {{ parameter.to_string() }}, {% endfor %} *, -{# Proper client based on whether or not the endpoint requires authentication #} -{% if endpoint.requires_security %} -client: AuthenticatedClient, -{% else %} -client: Client, -{% endif %} {# Form data if any #} {% if endpoint.form_body %} form_data: {{ endpoint.form_body.get_type_string() }}, diff --git a/openapi_python_client/templates/endpoint_module.py.jinja b/openapi_python_client/templates/endpoint_module.py.jinja index 3ea8991fb..bc2ab479c 100644 --- a/openapi_python_client/templates/endpoint_module.py.jinja +++ b/openapi_python_client/templates/endpoint_module.py.jinja @@ -3,8 +3,8 @@ from typing import Any, Dict, List, Optional, Union, cast import httpx -from ...client import AuthenticatedClient, Client -from ...types import Response, UNSET +from ...client import {{ client_name }} +from ...types import Response, UNSET, Unset from ... import errors {% for relative in endpoint.relative_imports %} @@ -19,6 +19,7 @@ from ... import errors def _get_kwargs( {{ arguments(endpoint) | indent(4) }} + client: {{ client_name }} ) -> Dict[str, Any]: url = "{}{{ endpoint.path }}".format( client.base_url @@ -60,7 +61,7 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[{{ return_string }}]: +def _parse_response(*, client: {{ client_name }}, response: httpx.Response) -> Optional[{{ return_string }}]: {% for response in endpoint.responses %} if response.status_code == HTTPStatus.{{ response.status_code.name }}: {% if parsed_responses %}{% import "property_templates/" + response.prop.template as prop_template %} @@ -80,7 +81,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[{{ return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[{{ return_string }}]: +def _build_response(*, client: {{ client_name }}, response: httpx.Response) -> Response[{{ return_string }}]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -91,9 +92,11 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[{{ def sync_detailed( {{ arguments(endpoint) | indent(4) }} + client: Union[{{ client_name }}, Unset] = UNSET ) -> Response[{{ return_string }}]: {{ docstring(endpoint, return_string) | indent(4) }} + client = client if not isinstance(client, Unset) else {{ client_name }}.instance() kwargs = _get_kwargs( {{ kwargs(endpoint) }} ) @@ -108,6 +111,7 @@ def sync_detailed( {% if parsed_responses %} def sync( {{ arguments(endpoint) | indent(4) }} + client: Union[{{ client_name }}, Unset] = UNSET ) -> Optional[{{ return_string }}]: {{ docstring(endpoint, return_string) | indent(4) }} @@ -118,9 +122,11 @@ def sync( async def asyncio_detailed( {{ arguments(endpoint) | indent(4) }} + client: Union[{{ client_name }}, Unset] = UNSET ) -> Response[{{ return_string }}]: {{ docstring(endpoint, return_string) | indent(4) }} + client = client if not isinstance(client, Unset) else {{ client_name }}.instance() kwargs = _get_kwargs( {{ kwargs(endpoint) }} ) @@ -135,6 +141,7 @@ async def asyncio_detailed( {% if parsed_responses %} async def asyncio( {{ arguments(endpoint) | indent(4) }} + client: Union[{{ client_name }}, Unset] = UNSET ) -> Optional[{{ return_string }}]: {{ docstring(endpoint, return_string) | indent(4) }} diff --git a/openapi_python_client/templates/package_init.py.jinja b/openapi_python_client/templates/package_init.py.jinja index ecf60e74d..0ff5d905c 100644 --- a/openapi_python_client/templates/package_init.py.jinja +++ b/openapi_python_client/templates/package_init.py.jinja @@ -1,9 +1,8 @@ {% from "helpers.jinja" import safe_docstring %} {{ safe_docstring(package_description) }} -from .client import AuthenticatedClient, Client +from .client import {{ client_name }} __all__ = ( - "AuthenticatedClient", - "Client", + "{{ client_name }}", ) diff --git a/tests/test_parser/test_openapi.py b/tests/test_parser/test_openapi.py index 9cc7398d9..6573c4846 100644 --- a/tests/test_parser/test_openapi.py +++ b/tests/test_parser/test_openapi.py @@ -1300,8 +1300,8 @@ def test_from_data(self, mocker): ) assert result == ( { - "default": EndpointCollection("default", endpoints=[endpoint_1, endpoint_3]), - "tag_2": EndpointCollection("tag_2", endpoints=[endpoint_2]), + "default": EndpointCollection(title="default", tag="default", endpoints=[endpoint_1, endpoint_3]), + "tag_2": EndpointCollection(title="tag_2", tag="tag_2", endpoints=[endpoint_2]), }, schemas_3, parameters_3, @@ -1473,11 +1473,11 @@ def test_from_data_tags_snake_case_sanitizer(self, mocker): ) assert result == ( { - "default": EndpointCollection("default", endpoints=[endpoint_1]), + "default": EndpointCollection(title="default", tag="default", endpoints=[endpoint_1]), "amf_subscription_info_document": EndpointCollection( - "amf_subscription_info_document", endpoints=[endpoint_2] + title="AMF Subscription Info (Document)", tag="amf_subscription_info_document", endpoints=[endpoint_2] ), - "tag3_abc": EndpointCollection("tag3_abc", endpoints=[endpoint_3]), + "tag3_abc": EndpointCollection(title="3. ABC", tag="tag3_abc", endpoints=[endpoint_3]), }, schemas_3, parameters_3, From 88010cba18b2bbff7669d2715d928a541fac5b93 Mon Sep 17 00:00:00 2001 From: v1nvn Date: Mon, 10 Apr 2023 17:57:24 +0530 Subject: [PATCH 7/9] feat: tag overrides --- README.md | 15 ++++++++ .../my_test_api_client/docs/{1.md => Tag1.md} | 0 .../endpoint_init.py.jinja | 2 +- openapi_python_client/__init__.py | 9 +++-- openapi_python_client/config.py | 11 ++++++ openapi_python_client/parser/openapi.py | 35 ++++++++++++++--- openapi_python_client/templates/api.md.jinja | 2 +- openapi_python_client/templates/api.py.jinja | 2 +- tests/test_parser/test_openapi.py | 38 +++++++++++-------- 9 files changed, 85 insertions(+), 29 deletions(-) rename end_to_end_tests/golden-record/my_test_api_client/docs/{1.md => Tag1.md} (100%) diff --git a/README.md b/README.md index cea385093..dcbdedc63 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,21 @@ class_overrides: module_name: short_name ``` +### tag_overrides + +Used to change the name of tags. This param should be a mapping of existing tag name to class_name and identifier_name. +As an example, if the tag in OpenAPI was something like "Very Long Name" and you want the generated client's class names and +identifier names to be called "LongName" with identifier called "long_name" you could do this: + +Example: + +```yaml +tag_overrides: + "Very Long Name": + class_name: LongName + identifier_name: long_name +``` + The easiest way to find what needs to be overridden is probably to generate your client and go look at everything in the models folder. ### project_name_override and package_name_override diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/1.md b/end_to_end_tests/golden-record/my_test_api_client/docs/Tag1.md similarity index 100% rename from end_to_end_tests/golden-record/my_test_api_client/docs/1.md rename to end_to_end_tests/golden-record/my_test_api_client/docs/Tag1.md diff --git a/end_to_end_tests/test_custom_templates/endpoint_init.py.jinja b/end_to_end_tests/test_custom_templates/endpoint_init.py.jinja index dd64d942c..a1470b26f 100644 --- a/end_to_end_tests/test_custom_templates/endpoint_init.py.jinja +++ b/end_to_end_tests/test_custom_templates/endpoint_init.py.jinja @@ -5,7 +5,7 @@ import types from . import {{ python_identifier(endpoint.name) }} {% endfor %} -class {{ class_name(endpoint_collection.tag) }}Endpoints: +class {{ endpoint_collection.tag.class_name }}Endpoints: {% for endpoint in endpoint_collection.endpoints %} diff --git a/openapi_python_client/__init__.py b/openapi_python_client/__init__.py index 6e20acf31..04ea51f42 100644 --- a/openapi_python_client/__init__.py +++ b/openapi_python_client/__init__.py @@ -299,8 +299,9 @@ def _build_api(self) -> None: api_doc_template = self.env.get_template( "api.md.jinja", globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"} ) - for tag, collection in endpoint_collections_by_tag.items(): - tag_dir = api_dir / tag + for _, collection in endpoint_collections_by_tag.items(): + tag = collection.tag + tag_dir = api_dir / tag.identifier_name tag_dir.mkdir() endpoint_init_path = tag_dir / "__init__.py" @@ -322,13 +323,13 @@ def module_name(endpoint): encoding=self.file_encoding, ) - api_path = self.package_dir / f"{tag}.py" + api_path = self.package_dir / f"{tag.identifier_name}.py" api_path.write_text( api_template.render(endpoint_collection=collection, module_name=module_name), encoding=self.file_encoding ) - api_doc_path = docs_dir / f"{utils.ClassName(collection.title, '')}.md" + api_doc_path = docs_dir / f"{tag.class_name}.md" api_doc_path.write_text( api_doc_template.render(endpoint_collection=collection, module_name=module_name), encoding=self.file_encoding diff --git a/openapi_python_client/config.py b/openapi_python_client/config.py index afca35758..251787cd5 100644 --- a/openapi_python_client/config.py +++ b/openapi_python_client/config.py @@ -17,6 +17,16 @@ class ClassOverride(BaseModel): module_name: Optional[str] = None +class TagOverride(BaseModel): + """An override of a single generated class. + + See https://github.com/openapi-generators/openapi-python-client#tag_overrides + """ + + class_name: Optional[str] = None + identifier_name: Optional[str] = None + + class Config(BaseModel): """Contains any configurable values passed by the user. @@ -24,6 +34,7 @@ class Config(BaseModel): """ class_overrides: Dict[str, ClassOverride] = {} + tag_overrides: Dict[str, TagOverride] = {} project_name_override: Optional[str] package_name_override: Optional[str] package_version_override: Optional[str] diff --git a/openapi_python_client/parser/openapi.py b/openapi_python_client/parser/openapi.py index 95b3b905a..35e01223a 100644 --- a/openapi_python_client/parser/openapi.py +++ b/openapi_python_client/parser/openapi.py @@ -11,7 +11,7 @@ from .. import schema as oai from .. import utils from ..config import Config -from ..utils import PythonIdentifier +from ..utils import ClassName, PythonIdentifier from .errors import GeneratorError, ParseError, PropertyError from .properties import ( Class, @@ -39,8 +39,7 @@ def import_string_from_class(class_: Class, prefix: str = "") -> str: class EndpointCollection: """A bunch of endpoints grouped under a tag that will become a module""" - title: str - tag: str + tag: "Tag" endpoints: List["Endpoint"] = field(default_factory=list) parse_errors: List[ParseError] = field(default_factory=list) @@ -58,9 +57,9 @@ def from_data( operation: Optional[oai.Operation] = getattr(path_data, method) if operation is None: continue - title = (operation.tags or ["default"])[0] - tag = utils.PythonIdentifier(value=title, prefix="tag") - collection = endpoints_by_tag.setdefault(tag, EndpointCollection(title=title, tag=tag)) + + tag = Tag.from_string(string=(operation.tags or ["default"])[0], config=config) + collection = endpoints_by_tag.setdefault(tag.identifier_name, EndpointCollection(tag=tag)) endpoint, schemas, parameters = Endpoint.from_data( data=operation, path=path, @@ -585,3 +584,27 @@ def from_dict(data: Dict[str, Any], *, config: Config) -> Union["GeneratorData", errors=schemas.errors + parameters.errors, enums=enums, ) + + +@dataclass +class Tag: + name: str + class_name: ClassName + identifier_name: PythonIdentifier + + @staticmethod + def from_string(*, string: str, config: Config) -> "Tag": + """Get a Class from an arbitrary string""" + identifier_name = PythonIdentifier(string, "tag") + override = config.tag_overrides.get(string) + + if override is not None and isinstance(override.identifier_name, str): + identifier_name = override.identifier_name + + if override is not None and isinstance(override.class_name, str): + class_name = override.class_name + else: + class_name = identifier_name + class_name = ClassName(class_name, "tag") + + return Tag(name=string, class_name=class_name, identifier_name=identifier_name) \ No newline at end of file diff --git a/openapi_python_client/templates/api.md.jinja b/openapi_python_client/templates/api.md.jinja index 2de4f28b0..5f4c23da2 100644 --- a/openapi_python_client/templates/api.md.jinja +++ b/openapi_python_client/templates/api.md.jinja @@ -1,4 +1,4 @@ -# {{endpoint_collection.title}} +# {{endpoint_collection.tag.name}} Method | HTTP Request | Description diff --git a/openapi_python_client/templates/api.py.jinja b/openapi_python_client/templates/api.py.jinja index 464228740..1b6fb37a2 100644 --- a/openapi_python_client/templates/api.py.jinja +++ b/openapi_python_client/templates/api.py.jinja @@ -1,4 +1,4 @@ -from .api.{{ endpoint_collection.tag }} import ( +from .api.{{ endpoint_collection.tag.identifier_name }} import ( {% for endpoint in endpoint_collection.endpoints %} {{ module_name(endpoint) }} as __{{ module_name(endpoint) }}, {% endfor %} diff --git a/tests/test_parser/test_openapi.py b/tests/test_parser/test_openapi.py index 6573c4846..cd4eeb62f 100644 --- a/tests/test_parser/test_openapi.py +++ b/tests/test_parser/test_openapi.py @@ -6,7 +6,7 @@ import openapi_python_client.schema as oai from openapi_python_client import Config, GeneratorError from openapi_python_client.parser.errors import ParseError -from openapi_python_client.parser.openapi import Endpoint, EndpointCollection +from openapi_python_client.parser.openapi import Endpoint, EndpointCollection, Tag from openapi_python_client.parser.properties import IntProperty, Parameters, Schemas from openapi_python_client.schema import ParameterLocation @@ -1264,6 +1264,8 @@ def test_from_data(self, mocker): schemas = mocker.MagicMock() parameters = mocker.MagicMock() config = MagicMock() + tag_1 = Tag.from_string(string="default", config=config) + tag_2 = Tag.from_string(string="tag_2", config=config) result = EndpointCollection.from_data(data=data, schemas=schemas, parameters=parameters, config=config) @@ -1273,7 +1275,7 @@ def test_from_data(self, mocker): data=path_1_put, path="path_1", method="put", - tag="default", + tag=tag_1, schemas=schemas, parameters=parameters, config=config, @@ -1282,7 +1284,7 @@ def test_from_data(self, mocker): data=path_1_post, path="path_1", method="post", - tag="tag_2", + tag=tag_2, schemas=schemas_1, parameters=parameters_1, config=config, @@ -1291,7 +1293,7 @@ def test_from_data(self, mocker): data=path_2_get, path="path_2", method="get", - tag="default", + tag=tag_1, schemas=schemas_2, parameters=parameters_2, config=config, @@ -1300,8 +1302,8 @@ def test_from_data(self, mocker): ) assert result == ( { - "default": EndpointCollection(title="default", tag="default", endpoints=[endpoint_1, endpoint_3]), - "tag_2": EndpointCollection(title="tag_2", tag="tag_2", endpoints=[endpoint_2]), + "default": EndpointCollection(tag=tag_1, endpoints=[endpoint_1, endpoint_3]), + "tag_2": EndpointCollection(tag=tag_2, endpoints=[endpoint_2]), }, schemas_3, parameters_3, @@ -1363,6 +1365,8 @@ def test_from_data_errors(self, mocker): schemas = mocker.MagicMock() parameters = mocker.MagicMock() config = MagicMock() + tag_1 = Tag.from_string(string="default", config=config) + tag_2 = Tag.from_string(string="tag_2", config=config) result, result_schemas, result_parameters = EndpointCollection.from_data( data=data, schemas=schemas, config=config, parameters=parameters @@ -1374,7 +1378,7 @@ def test_from_data_errors(self, mocker): data=path_1_put, path="path_1", method="put", - tag="default", + tag=tag_1, schemas=schemas, parameters=parameters, config=config, @@ -1383,7 +1387,7 @@ def test_from_data_errors(self, mocker): data=path_1_post, path="path_1", method="post", - tag="tag_2", + tag=tag_2, schemas=schemas_1, parameters=parameters_1, config=config, @@ -1392,7 +1396,7 @@ def test_from_data_errors(self, mocker): data=path_2_get, path="path_2", method="get", - tag="default", + tag=tag_1, schemas=schemas_2, parameters=parameters_2, config=config, @@ -1437,6 +1441,9 @@ def test_from_data_tags_snake_case_sanitizer(self, mocker): schemas = mocker.MagicMock() parameters = mocker.MagicMock() config = MagicMock() + tag_1 = Tag.from_string(string="default", config=config) + tag_2 = Tag.from_string(string="AMF Subscription Info (Document)", config=config) + tag_3 = Tag.from_string(string="3. ABC", config=config) result = EndpointCollection.from_data(data=data, schemas=schemas, parameters=parameters, config=config) @@ -1446,7 +1453,7 @@ def test_from_data_tags_snake_case_sanitizer(self, mocker): data=path_1_put, path="path_1", method="put", - tag="default", + tag=tag_1, schemas=schemas, parameters=parameters, config=config, @@ -1455,7 +1462,7 @@ def test_from_data_tags_snake_case_sanitizer(self, mocker): data=path_1_post, path="path_1", method="post", - tag="amf_subscription_info_document", + tag=tag_2, schemas=schemas_1, parameters=parameters_1, config=config, @@ -1464,7 +1471,7 @@ def test_from_data_tags_snake_case_sanitizer(self, mocker): data=path_2_get, path="path_2", method="get", - tag="tag3_abc", + tag=tag_3, schemas=schemas_2, parameters=parameters_2, config=config, @@ -1473,11 +1480,10 @@ def test_from_data_tags_snake_case_sanitizer(self, mocker): ) assert result == ( { - "default": EndpointCollection(title="default", tag="default", endpoints=[endpoint_1]), - "amf_subscription_info_document": EndpointCollection( - title="AMF Subscription Info (Document)", tag="amf_subscription_info_document", endpoints=[endpoint_2] + "default": EndpointCollection(tag=tag_1, endpoints=[endpoint_1]), + "amf_subscription_info_document": EndpointCollection(tag=tag_2, endpoints=[endpoint_2] ), - "tag3_abc": EndpointCollection(title="3. ABC", tag="tag3_abc", endpoints=[endpoint_3]), + "tag3_abc": EndpointCollection(tag=tag_3, endpoints=[endpoint_3]), }, schemas_3, parameters_3, From 306c2e0b3592b7c068cab3633634e69133f376d0 Mon Sep 17 00:00:00 2001 From: v1nvn Date: Fri, 14 Apr 2023 12:14:47 +0530 Subject: [PATCH 8/9] feat: tags in client --- .../my_test_api_client/client.py | 59 ++ end_to_end_tests/golden-record/README.md | 21 +- .../api/default/__init__.py | 102 ++ .../api/default/get_common_parameters.py | 64 +- .../api/default/post_common_parameters.py | 64 +- .../api/location/__init__.py | 155 +++ .../api/location/get_location_header_types.py | 98 +- .../get_location_query_optionality.py | 88 +- .../api/parameter_references/__init__.py | 84 ++ .../get_parameter_references_path_param.py | 94 +- .../api/parameters/__init__.py | 245 +++++ ...lete_common_parameters_overriding_param.py | 66 +- .../get_common_parameters_overriding_param.py | 72 +- .../get_same_name_multiple_locations_param.py | 86 +- .../parameters/multiple_path_parameters.py | 74 +- .../api/responses/__init__.py | 50 + ..._responses_unions_simple_before_complex.py | 34 +- .../my_test_api_client/api/tag1/__init__.py | 43 + .../api/tag1/get_tag_with_number.py | 52 +- .../my_test_api_client/api/tests/__init__.py | 992 ++++++++++++++++++ .../api/tests/callback_test.py | 36 +- .../api/tests/defaults_tests_defaults_post.py | 31 +- .../api/tests/description_with_backslash.py | 58 +- .../api/tests/get_basic_list_of_booleans.py | 26 +- .../api/tests/get_basic_list_of_floats.py | 26 +- .../api/tests/get_basic_list_of_integers.py | 26 +- .../api/tests/get_basic_list_of_strings.py | 26 +- .../api/tests/get_user_list.py | 28 +- .../api/tests/int_enum_tests_int_enum_post.py | 36 +- .../tests/json_body_tests_json_body_post.py | 36 +- .../no_response_tests_no_response_get.py | 54 +- .../octet_stream_tests_octet_stream_get.py | 27 +- .../api/tests/post_form_data.py | 62 +- .../api/tests/post_form_data_inline.py | 64 +- .../api/tests/post_tests_json_body_string.py | 36 +- .../api/tests/test_inline_objects.py | 28 +- ..._with_cookie_auth_token_with_cookie_get.py | 66 +- ...d_content_tests_unsupported_content_get.py | 54 +- .../tests/upload_file_tests_upload_post.py | 30 +- ...upload_multiple_files_tests_upload_post.py | 32 +- .../my_test_api_client/api/true_/__init__.py | 55 + .../my_test_api_client/api/true_/false_.py | 60 +- .../my_test_api_client/client.py | 60 +- .../my_test_api_client/default.py | 9 - .../my_test_api_client/location.py | 9 - .../parameter_references.py | 4 - .../my_test_api_client/parameters.py | 19 - .../my_test_api_client/responses.py | 8 - .../golden-record/my_test_api_client/tag1.py | 4 - .../golden-record/my_test_api_client/tests.py | 131 --- .../golden-record/my_test_api_client/true_.py | 4 - .../test_custom_templates/client.py.jinja | 60 ++ end_to_end_tests/test_end_to_end.py | 1 + openapi_python_client/__init__.py | 17 +- .../templates/README.md.jinja | 21 +- .../templates/client.py.jinja | 48 +- .../templates/endpoint_init.py.jinja | 48 + .../templates/endpoint_macros.py.jinja | 6 +- .../templates/endpoint_module.py.jinja | 29 +- 59 files changed, 3192 insertions(+), 726 deletions(-) create mode 100644 end_to_end_tests/custom-templates-golden-record/my_test_api_client/client.py delete mode 100644 end_to_end_tests/golden-record/my_test_api_client/default.py delete mode 100644 end_to_end_tests/golden-record/my_test_api_client/location.py delete mode 100644 end_to_end_tests/golden-record/my_test_api_client/parameter_references.py delete mode 100644 end_to_end_tests/golden-record/my_test_api_client/parameters.py delete mode 100644 end_to_end_tests/golden-record/my_test_api_client/responses.py delete mode 100644 end_to_end_tests/golden-record/my_test_api_client/tag1.py delete mode 100644 end_to_end_tests/golden-record/my_test_api_client/tests.py delete mode 100644 end_to_end_tests/golden-record/my_test_api_client/true_.py create mode 100644 end_to_end_tests/test_custom_templates/client.py.jinja diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/client.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/client.py new file mode 100644 index 000000000..3944891dd --- /dev/null +++ b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/client.py @@ -0,0 +1,59 @@ +import ssl +from typing import Dict, Union + + +class MyTestApiClient: + """A class for keeping track of data related to the API + + Attributes: + base_url: The base URL for the API, all requests are made to a relative path to this URL + cookies: A dictionary of cookies to be sent with every request + headers: A dictionary of headers to be sent with every request + timeout: The maximum amount of a time in seconds a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + verify_ssl: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. + follow_redirects: Whether or not to follow redirects. Default value is False. + """ + + def __init__( + self, + base_url: str, + cookies: Union[Dict[str, str], None] = None, + headers: Union[Dict[str, str], None] = None, + timeout: float = 5.0, + verify_ssl: Union[str, bool, ssl.SSLContext] = True, + raise_on_unexpected_status: bool = False, + follow_redirects: bool = False, + token: Union[str, None] = None, + prefix: str = "Bearer", + auth_header_name: str = "Authorization", + ): + cookies = cookies if cookies is not None else {} + headers = headers if headers is not None else {} + + self.base_url = base_url + self.cookies = cookies + self.headers = headers + self.timeout = timeout + self.verify_ssl = verify_ssl + self.raise_on_unexpected_status = raise_on_unexpected_status + self.follow_redirects = follow_redirects + self.token = token + self.prefix = prefix + self.auth_header_name = auth_header_name + + def get_headers(self) -> Dict[str, str]: + """Get headers to be used in all endpoints""" + if not self.token: + return {**self.headers} + auth_header_value = f"{self.prefix} {self.token}" if self.prefix else self.token + return {self.auth_header_name: auth_header_value, **self.headers} + + def get_cookies(self) -> Dict[str, str]: + return {**self.cookies} + + def get_timeout(self) -> float: + return self.timeout diff --git a/end_to_end_tests/golden-record/README.md b/end_to_end_tests/golden-record/README.md index ed2c3e4ae..cb80d1412 100644 --- a/end_to_end_tests/golden-record/README.md +++ b/end_to_end_tests/golden-record/README.md @@ -7,36 +7,29 @@ First, configure a client: ```python from my_test_api_client import MyTestApiClient -MyTestApiClient.configure(base_url="https://api.example.com", token="SuperSecretToken") +client = MyTestApiClient(base_url="https://api.example.com", token="SuperSecretToken") ``` Now call your endpoint and use your models: ```python from my_test_api_client.models import MyDataModel -from my_test_api_client.my_tag import get_my_data_model -from my_test_api_client.types import Response -my_data: MyDataModel = get_my_data_model() -# or if you need more info (e.g. status_code) -response: Response[MyDataModel] = get_my_data_model_detailed() +my_data: MyDataModel = client.my_tag.get_my_data_model() ``` Or do the same thing with an async version: ```python from my_test_api_client.models import MyDataModel -from my_test_api_client.my_tag import get_my_data_model -from my_test_api_client.types import Response -my_data: MyDataModel = await get_my_data_model_async() -response: Response[MyDataModel] = await get_my_data_model_async_detailed() +my_data: MyDataModel = await client.get_my_data_model_async() ``` By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle. ```python -MyTestApiClient.configure( +client = MyTestApiClient( base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl="/path/to/certificate_bundle.pem", @@ -46,7 +39,7 @@ MyTestApiClient.configure( You can also disable certificate validation altogether, but beware that **this is a security risk**. ```python -MyTestApiClient.configure( +client = MyTestApiClient( base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl=False @@ -56,11 +49,9 @@ MyTestApiClient.configure( There are more settings on the generated `MyTestApiClient` class which let you control more runtime behavior, check out the docstring on that class for more info. Things to know: -1. Every path/method combo becomes provides you with four functions. For example: get_my_data_model has these methods: +1. Every path/method combo becomes provides you with two functions. For example: get_my_data_model has these methods: 1. `get_my_data_model`: Blocking request that returns parsed data (if successful) or `None` - 1. `get_my_data_model_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful. 1. `get_my_data_model_async`: Like `sync` but async instead of blocking - 1. `get_my_data_model_async_detailed`: Like `sync_detailed` but async instead of blocking 1. All path/query params, and bodies become method arguments. 1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/__init__.py index e69de29bb..4cb250f3f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/__init__.py @@ -0,0 +1,102 @@ +from typing import TYPE_CHECKING, Any, Optional + +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Optional, Union + +from ...types import UNSET, Unset +from . import get_common_parameters, post_common_parameters + + +class Default: + def __init__(self, client: "MyTestApiClient"): + self.__client = client + + def get_common_parameters( + self, + *, + common: Union[Unset, None, str] = UNSET, + ) -> Optional[Any]: + """ + Args: + common (Union[Unset, None, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return get_common_parameters.sync( + client=self.__client, + common=common, + ) + + async def get_common_parameters_async( + self, + *, + common: Union[Unset, None, str] = UNSET, + ) -> Optional[Any]: + """ + Args: + common (Union[Unset, None, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await get_common_parameters.asyncio( + client=self.__client, + common=common, + ) + + def post_common_parameters( + self, + *, + common: Union[Unset, None, str] = UNSET, + ) -> Optional[Any]: + """ + Args: + common (Union[Unset, None, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return post_common_parameters.sync( + client=self.__client, + common=common, + ) + + async def post_common_parameters_async( + self, + *, + common: Union[Unset, None, str] = UNSET, + ) -> Optional[Any]: + """ + Args: + common (Union[Unset, None, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await post_common_parameters.asyncio( + client=self.__client, + common=common, + ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py index 4d36df4a7..25a095c6d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py @@ -1,14 +1,18 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional, Union import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Optional, Union + from ... import errors -from ...client import MyTestApiClient from ...types import UNSET, Response, Unset -def _get_kwargs(*, common: Union[Unset, None, str] = UNSET, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/common_parameters".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -30,7 +34,7 @@ def _get_kwargs(*, common: Union[Unset, None, str] = UNSET, client: MyTestApiCli } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -39,7 +43,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -48,9 +52,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed( - *, common: Union[Unset, None, str] = UNSET, client: Union[MyTestApiClient, Unset] = UNSET -) -> Response[Any]: +def sync_detailed(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Response[Any]: """ Args: common (Union[Unset, None, str]): @@ -63,7 +65,6 @@ def sync_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, common=common, @@ -77,9 +78,26 @@ def sync_detailed( return _build_response(client=client, response=response) -async def asyncio_detailed( - *, common: Union[Unset, None, str] = UNSET, client: Union[MyTestApiClient, Unset] = UNSET -) -> Response[Any]: +def sync(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Optional[Any]: + """ + Args: + common (Union[Unset, None, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + client=client, + common=common, + ).parsed + + +async def asyncio_detailed(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Response[Any]: """ Args: common (Union[Unset, None, str]): @@ -92,7 +110,6 @@ async def asyncio_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, common=common, @@ -102,3 +119,24 @@ async def asyncio_detailed( response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Optional[Any]: + """ + Args: + common (Union[Unset, None, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + client=client, + common=common, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py index 4a83e0a3a..c0107fd2e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py @@ -1,14 +1,18 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional, Union import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Optional, Union + from ... import errors -from ...client import MyTestApiClient from ...types import UNSET, Response, Unset -def _get_kwargs(*, common: Union[Unset, None, str] = UNSET, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/common_parameters".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -30,7 +34,7 @@ def _get_kwargs(*, common: Union[Unset, None, str] = UNSET, client: MyTestApiCli } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -39,7 +43,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -48,9 +52,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed( - *, common: Union[Unset, None, str] = UNSET, client: Union[MyTestApiClient, Unset] = UNSET -) -> Response[Any]: +def sync_detailed(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Response[Any]: """ Args: common (Union[Unset, None, str]): @@ -63,7 +65,6 @@ def sync_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, common=common, @@ -77,9 +78,26 @@ def sync_detailed( return _build_response(client=client, response=response) -async def asyncio_detailed( - *, common: Union[Unset, None, str] = UNSET, client: Union[MyTestApiClient, Unset] = UNSET -) -> Response[Any]: +def sync(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Optional[Any]: + """ + Args: + common (Union[Unset, None, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + client=client, + common=common, + ).parsed + + +async def asyncio_detailed(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Response[Any]: """ Args: common (Union[Unset, None, str]): @@ -92,7 +110,6 @@ async def asyncio_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, common=common, @@ -102,3 +119,24 @@ async def asyncio_detailed( response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Optional[Any]: + """ + Args: + common (Union[Unset, None, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + client=client, + common=common, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/__init__.py index e69de29bb..917a1483c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/__init__.py @@ -0,0 +1,155 @@ +from typing import TYPE_CHECKING, Any, Optional + +if TYPE_CHECKING: + from ...client import MyTestApiClient + +import datetime +from typing import Optional, Union, cast + +from dateutil.parser import isoparse + +from ...models.get_location_header_types_int_enum_header import GetLocationHeaderTypesIntEnumHeader +from ...models.get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader +from ...types import UNSET, Unset +from . import get_location_header_types, get_location_query_optionality + + +class Location: + def __init__(self, client: "MyTestApiClient"): + self.__client = client + + def get_location_query_optionality( + self, + *, + not_null_required: datetime.datetime, + null_required: Union[Unset, None, datetime.datetime] = UNSET, + null_not_required: Union[Unset, None, datetime.datetime] = UNSET, + not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, + ) -> Optional[Any]: + """ + Args: + not_null_required (datetime.datetime): + null_required (Union[Unset, None, datetime.datetime]): + null_not_required (Union[Unset, None, datetime.datetime]): + not_null_not_required (Union[Unset, None, datetime.datetime]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return get_location_query_optionality.sync( + client=self.__client, + not_null_required=not_null_required, + null_required=null_required, + null_not_required=null_not_required, + not_null_not_required=not_null_not_required, + ) + + async def get_location_query_optionality_async( + self, + *, + not_null_required: datetime.datetime, + null_required: Union[Unset, None, datetime.datetime] = UNSET, + null_not_required: Union[Unset, None, datetime.datetime] = UNSET, + not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, + ) -> Optional[Any]: + """ + Args: + not_null_required (datetime.datetime): + null_required (Union[Unset, None, datetime.datetime]): + null_not_required (Union[Unset, None, datetime.datetime]): + not_null_not_required (Union[Unset, None, datetime.datetime]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await get_location_query_optionality.asyncio( + client=self.__client, + not_null_required=not_null_required, + null_required=null_required, + null_not_required=null_not_required, + not_null_not_required=not_null_not_required, + ) + + def get_location_header_types( + self, + *, + boolean_header: Union[Unset, bool] = UNSET, + string_header: Union[Unset, str] = UNSET, + number_header: Union[Unset, float] = UNSET, + integer_header: Union[Unset, int] = UNSET, + int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, + string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, + ) -> Optional[Any]: + """ + Args: + boolean_header (Union[Unset, bool]): + string_header (Union[Unset, str]): + number_header (Union[Unset, float]): + integer_header (Union[Unset, int]): + int_enum_header (Union[Unset, GetLocationHeaderTypesIntEnumHeader]): + string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return get_location_header_types.sync( + client=self.__client, + boolean_header=boolean_header, + string_header=string_header, + number_header=number_header, + integer_header=integer_header, + int_enum_header=int_enum_header, + string_enum_header=string_enum_header, + ) + + async def get_location_header_types_async( + self, + *, + boolean_header: Union[Unset, bool] = UNSET, + string_header: Union[Unset, str] = UNSET, + number_header: Union[Unset, float] = UNSET, + integer_header: Union[Unset, int] = UNSET, + int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, + string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, + ) -> Optional[Any]: + """ + Args: + boolean_header (Union[Unset, bool]): + string_header (Union[Unset, str]): + number_header (Union[Unset, float]): + integer_header (Union[Unset, int]): + int_enum_header (Union[Unset, GetLocationHeaderTypesIntEnumHeader]): + string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await get_location_header_types.asyncio( + client=self.__client, + boolean_header=boolean_header, + string_header=string_header, + number_header=number_header, + integer_header=integer_header, + int_enum_header=int_enum_header, + string_enum_header=string_enum_header, + ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py index ae53a4b99..c855556c8 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py @@ -1,10 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional, Union import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Union + from ... import errors -from ...client import MyTestApiClient from ...models.get_location_header_types_int_enum_header import GetLocationHeaderTypesIntEnumHeader from ...models.get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader from ...types import UNSET, Response, Unset @@ -18,7 +22,7 @@ def _get_kwargs( integer_header: Union[Unset, int] = UNSET, int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, - client: MyTestApiClient, + client: "MyTestApiClient", ) -> Dict[str, Any]: url = "{}/location/header/types".format(client.base_url) @@ -53,7 +57,7 @@ def _get_kwargs( } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -62,7 +66,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -79,7 +83,7 @@ def sync_detailed( integer_header: Union[Unset, int] = UNSET, int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Response[Any]: """ Args: @@ -98,7 +102,6 @@ def sync_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, boolean_header=boolean_header, @@ -117,6 +120,44 @@ def sync_detailed( return _build_response(client=client, response=response) +def sync( + *, + boolean_header: Union[Unset, bool] = UNSET, + string_header: Union[Unset, str] = UNSET, + number_header: Union[Unset, float] = UNSET, + integer_header: Union[Unset, int] = UNSET, + int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, + string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, + client: "MyTestApiClient", +) -> Optional[Any]: + """ + Args: + boolean_header (Union[Unset, bool]): + string_header (Union[Unset, str]): + number_header (Union[Unset, float]): + integer_header (Union[Unset, int]): + int_enum_header (Union[Unset, GetLocationHeaderTypesIntEnumHeader]): + string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + client=client, + boolean_header=boolean_header, + string_header=string_header, + number_header=number_header, + integer_header=integer_header, + int_enum_header=int_enum_header, + string_enum_header=string_enum_header, + ).parsed + + async def asyncio_detailed( *, boolean_header: Union[Unset, bool] = UNSET, @@ -125,7 +166,7 @@ async def asyncio_detailed( integer_header: Union[Unset, int] = UNSET, int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Response[Any]: """ Args: @@ -144,7 +185,6 @@ async def asyncio_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, boolean_header=boolean_header, @@ -159,3 +199,43 @@ async def asyncio_detailed( response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio( + *, + boolean_header: Union[Unset, bool] = UNSET, + string_header: Union[Unset, str] = UNSET, + number_header: Union[Unset, float] = UNSET, + integer_header: Union[Unset, int] = UNSET, + int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, + string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, + client: "MyTestApiClient", +) -> Optional[Any]: + """ + Args: + boolean_header (Union[Unset, bool]): + string_header (Union[Unset, str]): + number_header (Union[Unset, float]): + integer_header (Union[Unset, int]): + int_enum_header (Union[Unset, GetLocationHeaderTypesIntEnumHeader]): + string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + client=client, + boolean_header=boolean_header, + string_header=string_header, + number_header=number_header, + integer_header=integer_header, + int_enum_header=int_enum_header, + string_enum_header=string_enum_header, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py index f9b9fecf9..13b21cde8 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py @@ -1,11 +1,15 @@ -import datetime from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional, Union import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +import datetime +from typing import Optional, Union + from ... import errors -from ...client import MyTestApiClient from ...types import UNSET, Response, Unset @@ -15,7 +19,7 @@ def _get_kwargs( null_required: Union[Unset, None, datetime.datetime] = UNSET, null_not_required: Union[Unset, None, datetime.datetime] = UNSET, not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, - client: MyTestApiClient, + client: "MyTestApiClient", ) -> Dict[str, Any]: url = "{}/location/query/optionality".format(client.base_url) @@ -58,7 +62,7 @@ def _get_kwargs( } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -67,7 +71,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -82,7 +86,7 @@ def sync_detailed( null_required: Union[Unset, None, datetime.datetime] = UNSET, null_not_required: Union[Unset, None, datetime.datetime] = UNSET, not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Response[Any]: """ Args: @@ -99,7 +103,6 @@ def sync_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, not_null_required=not_null_required, @@ -116,13 +119,45 @@ def sync_detailed( return _build_response(client=client, response=response) +def sync( + *, + not_null_required: datetime.datetime, + null_required: Union[Unset, None, datetime.datetime] = UNSET, + null_not_required: Union[Unset, None, datetime.datetime] = UNSET, + not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, + client: "MyTestApiClient", +) -> Optional[Any]: + """ + Args: + not_null_required (datetime.datetime): + null_required (Union[Unset, None, datetime.datetime]): + null_not_required (Union[Unset, None, datetime.datetime]): + not_null_not_required (Union[Unset, None, datetime.datetime]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + client=client, + not_null_required=not_null_required, + null_required=null_required, + null_not_required=null_not_required, + not_null_not_required=not_null_not_required, + ).parsed + + async def asyncio_detailed( *, not_null_required: datetime.datetime, null_required: Union[Unset, None, datetime.datetime] = UNSET, null_not_required: Union[Unset, None, datetime.datetime] = UNSET, not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Response[Any]: """ Args: @@ -139,7 +174,6 @@ async def asyncio_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, not_null_required=not_null_required, @@ -152,3 +186,37 @@ async def asyncio_detailed( response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio( + *, + not_null_required: datetime.datetime, + null_required: Union[Unset, None, datetime.datetime] = UNSET, + null_not_required: Union[Unset, None, datetime.datetime] = UNSET, + not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, + client: "MyTestApiClient", +) -> Optional[Any]: + """ + Args: + not_null_required (datetime.datetime): + null_required (Union[Unset, None, datetime.datetime]): + null_not_required (Union[Unset, None, datetime.datetime]): + not_null_not_required (Union[Unset, None, datetime.datetime]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + client=client, + not_null_required=not_null_required, + null_required=null_required, + null_not_required=null_not_required, + not_null_not_required=not_null_not_required, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/__init__.py index e69de29bb..a11e33354 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/__init__.py @@ -0,0 +1,84 @@ +from typing import TYPE_CHECKING, Any, Optional + +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Optional, Union + +from ...types import UNSET, Unset +from . import get_parameter_references_path_param + + +class ParameterReferences: + def __init__(self, client: "MyTestApiClient"): + self.__client = client + + def get_parameter_references_path_param( + self, + path_param: str, + *, + string_param: Union[Unset, None, str] = UNSET, + integer_param: Union[Unset, None, int] = 0, + header_param: Union[Unset, str] = UNSET, + cookie_param: Union[Unset, str] = UNSET, + ) -> Optional[Any]: + """Test different types of parameter references + + Args: + path_param (str): + string_param (Union[Unset, None, str]): + integer_param (Union[Unset, None, int]): + header_param (Union[Unset, str]): + cookie_param (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return get_parameter_references_path_param.sync( + client=self.__client, + path_param=path_param, + string_param=string_param, + integer_param=integer_param, + header_param=header_param, + cookie_param=cookie_param, + ) + + async def get_parameter_references_path_param_async( + self, + path_param: str, + *, + string_param: Union[Unset, None, str] = UNSET, + integer_param: Union[Unset, None, int] = 0, + header_param: Union[Unset, str] = UNSET, + cookie_param: Union[Unset, str] = UNSET, + ) -> Optional[Any]: + """Test different types of parameter references + + Args: + path_param (str): + string_param (Union[Unset, None, str]): + integer_param (Union[Unset, None, int]): + header_param (Union[Unset, str]): + cookie_param (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await get_parameter_references_path_param.asyncio( + client=self.__client, + path_param=path_param, + string_param=string_param, + integer_param=integer_param, + header_param=header_param, + cookie_param=cookie_param, + ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py index 813bc990f..97de1a324 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py @@ -1,10 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional, Union import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Optional, Union + from ... import errors -from ...client import MyTestApiClient from ...types import UNSET, Response, Unset @@ -15,7 +19,7 @@ def _get_kwargs( integer_param: Union[Unset, None, int] = 0, header_param: Union[Unset, str] = UNSET, cookie_param: Union[Unset, str] = UNSET, - client: MyTestApiClient, + client: "MyTestApiClient", ) -> Dict[str, Any]: url = "{}/parameter-references/{path_param}".format(client.base_url, path_param=path_param) @@ -46,7 +50,7 @@ def _get_kwargs( } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -55,7 +59,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -71,7 +75,7 @@ def sync_detailed( integer_param: Union[Unset, None, int] = 0, header_param: Union[Unset, str] = UNSET, cookie_param: Union[Unset, str] = UNSET, - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Response[Any]: """Test different types of parameter references @@ -90,7 +94,6 @@ def sync_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( path_param=path_param, client=client, @@ -108,6 +111,42 @@ def sync_detailed( return _build_response(client=client, response=response) +def sync( + path_param: str, + *, + string_param: Union[Unset, None, str] = UNSET, + integer_param: Union[Unset, None, int] = 0, + header_param: Union[Unset, str] = UNSET, + cookie_param: Union[Unset, str] = UNSET, + client: "MyTestApiClient", +) -> Optional[Any]: + """Test different types of parameter references + + Args: + path_param (str): + string_param (Union[Unset, None, str]): + integer_param (Union[Unset, None, int]): + header_param (Union[Unset, str]): + cookie_param (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + path_param=path_param, + client=client, + string_param=string_param, + integer_param=integer_param, + header_param=header_param, + cookie_param=cookie_param, + ).parsed + + async def asyncio_detailed( path_param: str, *, @@ -115,7 +154,7 @@ async def asyncio_detailed( integer_param: Union[Unset, None, int] = 0, header_param: Union[Unset, str] = UNSET, cookie_param: Union[Unset, str] = UNSET, - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Response[Any]: """Test different types of parameter references @@ -134,7 +173,6 @@ async def asyncio_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( path_param=path_param, client=client, @@ -148,3 +186,41 @@ async def asyncio_detailed( response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio( + path_param: str, + *, + string_param: Union[Unset, None, str] = UNSET, + integer_param: Union[Unset, None, int] = 0, + header_param: Union[Unset, str] = UNSET, + cookie_param: Union[Unset, str] = UNSET, + client: "MyTestApiClient", +) -> Optional[Any]: + """Test different types of parameter references + + Args: + path_param (str): + string_param (Union[Unset, None, str]): + integer_param (Union[Unset, None, int]): + header_param (Union[Unset, str]): + cookie_param (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + path_param=path_param, + client=client, + string_param=string_param, + integer_param=integer_param, + header_param=header_param, + cookie_param=cookie_param, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/__init__.py index e69de29bb..d5f335cb9 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/__init__.py @@ -0,0 +1,245 @@ +from typing import TYPE_CHECKING, Any, Optional + +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Optional, Union + +from ...types import UNSET, Unset +from . import ( + delete_common_parameters_overriding_param, + get_common_parameters_overriding_param, + get_same_name_multiple_locations_param, + multiple_path_parameters, +) + + +class Parameters: + def __init__(self, client: "MyTestApiClient"): + self.__client = client + + def get_common_parameters_overriding_param( + self, + param_path: str, + *, + param_query: str = "overridden_in_GET", + ) -> Optional[Any]: + """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code + + Args: + param_path (str): + param_query (str): A parameter with the same name as another. Default: + 'overridden_in_GET'. Example: an example string. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return get_common_parameters_overriding_param.sync( + client=self.__client, + param_path=param_path, + param_query=param_query, + ) + + async def get_common_parameters_overriding_param_async( + self, + param_path: str, + *, + param_query: str = "overridden_in_GET", + ) -> Optional[Any]: + """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code + + Args: + param_path (str): + param_query (str): A parameter with the same name as another. Default: + 'overridden_in_GET'. Example: an example string. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await get_common_parameters_overriding_param.asyncio( + client=self.__client, + param_path=param_path, + param_query=param_query, + ) + + def delete_common_parameters_overriding_param( + self, + param_path: str, + *, + param_query: Union[Unset, None, str] = UNSET, + ) -> Optional[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, None, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return delete_common_parameters_overriding_param.sync( + client=self.__client, + param_path=param_path, + param_query=param_query, + ) + + async def delete_common_parameters_overriding_param_async( + self, + param_path: str, + *, + param_query: Union[Unset, None, str] = UNSET, + ) -> Optional[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, None, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await delete_common_parameters_overriding_param.asyncio( + client=self.__client, + param_path=param_path, + param_query=param_query, + ) + + def get_same_name_multiple_locations_param( + self, + param_path: str, + *, + param_query: Union[Unset, None, str] = UNSET, + param_header: Union[Unset, str] = UNSET, + param_cookie: Union[Unset, str] = UNSET, + ) -> Optional[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, None, str]): + param_header (Union[Unset, str]): + param_cookie (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return get_same_name_multiple_locations_param.sync( + client=self.__client, + param_path=param_path, + param_query=param_query, + param_header=param_header, + param_cookie=param_cookie, + ) + + async def get_same_name_multiple_locations_param_async( + self, + param_path: str, + *, + param_query: Union[Unset, None, str] = UNSET, + param_header: Union[Unset, str] = UNSET, + param_cookie: Union[Unset, str] = UNSET, + ) -> Optional[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, None, str]): + param_header (Union[Unset, str]): + param_cookie (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await get_same_name_multiple_locations_param.asyncio( + client=self.__client, + param_path=param_path, + param_query=param_query, + param_header=param_header, + param_cookie=param_cookie, + ) + + def multiple_path_parameters( + self, + param4: str, + param2: int, + param1: str, + param3: int, + ) -> Optional[Any]: + """ + Args: + param4 (str): + param2 (int): + param1 (str): + param3 (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return multiple_path_parameters.sync( + client=self.__client, + param4=param4, + param2=param2, + param1=param1, + param3=param3, + ) + + async def multiple_path_parameters_async( + self, + param4: str, + param2: int, + param1: str, + param3: int, + ) -> Optional[Any]: + """ + Args: + param4 (str): + param2 (int): + param1 (str): + param3 (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await multiple_path_parameters.asyncio( + client=self.__client, + param4=param4, + param2=param2, + param1=param1, + param3=param3, + ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py index 5e47642a4..acc675adf 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py @@ -1,15 +1,19 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional, Union import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Optional, Union + from ... import errors -from ...client import MyTestApiClient from ...types import UNSET, Response, Unset def _get_kwargs( - param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: MyTestApiClient + param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: "MyTestApiClient" ) -> Dict[str, Any]: url = "{}/common_parameters_overriding/{param}".format(client.base_url, param=param_path) @@ -32,7 +36,7 @@ def _get_kwargs( } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -41,7 +45,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -51,7 +55,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res def sync_detailed( - param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: Union[MyTestApiClient, Unset] = UNSET + param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: "MyTestApiClient" ) -> Response[Any]: """ Args: @@ -66,7 +70,6 @@ def sync_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param_path=param_path, client=client, @@ -81,8 +84,29 @@ def sync_detailed( return _build_response(client=client, response=response) +def sync(param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Optional[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, None, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + param_path=param_path, + client=client, + param_query=param_query, + ).parsed + + async def asyncio_detailed( - param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: Union[MyTestApiClient, Unset] = UNSET + param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: "MyTestApiClient" ) -> Response[Any]: """ Args: @@ -97,7 +121,6 @@ async def asyncio_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param_path=param_path, client=client, @@ -108,3 +131,28 @@ async def asyncio_detailed( response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio( + param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: "MyTestApiClient" +) -> Optional[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, None, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + param_path=param_path, + client=client, + param_query=param_query, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py index 8d081d7d5..49aa4eed4 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py @@ -1,14 +1,18 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + from ... import errors -from ...client import MyTestApiClient -from ...types import UNSET, Response, Unset +from ...types import UNSET, Response -def _get_kwargs(param_path: str, *, param_query: str = "overridden_in_GET", client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs( + param_path: str, *, param_query: str = "overridden_in_GET", client: "MyTestApiClient" +) -> Dict[str, Any]: url = "{}/common_parameters_overriding/{param}".format(client.base_url, param=param_path) headers: Dict[str, str] = client.get_headers() @@ -30,7 +34,7 @@ def _get_kwargs(param_path: str, *, param_query: str = "overridden_in_GET", clie } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -39,7 +43,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -49,7 +53,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res def sync_detailed( - param_path: str, *, param_query: str = "overridden_in_GET", client: Union[MyTestApiClient, Unset] = UNSET + param_path: str, *, param_query: str = "overridden_in_GET", client: "MyTestApiClient" ) -> Response[Any]: """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code @@ -66,7 +70,6 @@ def sync_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param_path=param_path, client=client, @@ -81,8 +84,31 @@ def sync_detailed( return _build_response(client=client, response=response) +def sync(param_path: str, *, param_query: str = "overridden_in_GET", client: "MyTestApiClient") -> Optional[Any]: + """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code + + Args: + param_path (str): + param_query (str): A parameter with the same name as another. Default: + 'overridden_in_GET'. Example: an example string. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + param_path=param_path, + client=client, + param_query=param_query, + ).parsed + + async def asyncio_detailed( - param_path: str, *, param_query: str = "overridden_in_GET", client: Union[MyTestApiClient, Unset] = UNSET + param_path: str, *, param_query: str = "overridden_in_GET", client: "MyTestApiClient" ) -> Response[Any]: """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code @@ -99,7 +125,6 @@ async def asyncio_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param_path=param_path, client=client, @@ -110,3 +135,30 @@ async def asyncio_detailed( response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio( + param_path: str, *, param_query: str = "overridden_in_GET", client: "MyTestApiClient" +) -> Optional[Any]: + """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code + + Args: + param_path (str): + param_query (str): A parameter with the same name as another. Default: + 'overridden_in_GET'. Example: an example string. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + param_path=param_path, + client=client, + param_query=param_query, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py index 14f680a7f..da66aa023 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py @@ -1,10 +1,14 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional, Union import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Optional, Union + from ... import errors -from ...client import MyTestApiClient from ...types import UNSET, Response, Unset @@ -14,7 +18,7 @@ def _get_kwargs( param_query: Union[Unset, None, str] = UNSET, param_header: Union[Unset, str] = UNSET, param_cookie: Union[Unset, str] = UNSET, - client: MyTestApiClient, + client: "MyTestApiClient", ) -> Dict[str, Any]: url = "{}/same-name-multiple-locations/{param}".format(client.base_url, param=param_path) @@ -43,7 +47,7 @@ def _get_kwargs( } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -52,7 +56,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -67,7 +71,7 @@ def sync_detailed( param_query: Union[Unset, None, str] = UNSET, param_header: Union[Unset, str] = UNSET, param_cookie: Union[Unset, str] = UNSET, - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Response[Any]: """ Args: @@ -84,7 +88,6 @@ def sync_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param_path=param_path, client=client, @@ -101,13 +104,45 @@ def sync_detailed( return _build_response(client=client, response=response) +def sync( + param_path: str, + *, + param_query: Union[Unset, None, str] = UNSET, + param_header: Union[Unset, str] = UNSET, + param_cookie: Union[Unset, str] = UNSET, + client: "MyTestApiClient", +) -> Optional[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, None, str]): + param_header (Union[Unset, str]): + param_cookie (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + param_path=param_path, + client=client, + param_query=param_query, + param_header=param_header, + param_cookie=param_cookie, + ).parsed + + async def asyncio_detailed( param_path: str, *, param_query: Union[Unset, None, str] = UNSET, param_header: Union[Unset, str] = UNSET, param_cookie: Union[Unset, str] = UNSET, - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Response[Any]: """ Args: @@ -124,7 +159,6 @@ async def asyncio_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param_path=param_path, client=client, @@ -137,3 +171,37 @@ async def asyncio_detailed( response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio( + param_path: str, + *, + param_query: Union[Unset, None, str] = UNSET, + param_header: Union[Unset, str] = UNSET, + param_cookie: Union[Unset, str] = UNSET, + client: "MyTestApiClient", +) -> Optional[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, None, str]): + param_header (Union[Unset, str]): + param_cookie (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + param_path=param_path, + client=client, + param_query=param_query, + param_header=param_header, + param_cookie=param_cookie, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py index 9a4e660e9..ff27d19e7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py @@ -1,14 +1,16 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + from ... import errors -from ...client import MyTestApiClient -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(param4: str, param2: int, param1: str, param3: int, *, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(param4: str, param2: int, param1: str, param3: int, client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/multiple-path-parameters/{param4}/something/{param2}/{param1}/{param3}".format( client.base_url, param4=param4, param2=param2, param1=param1, param3=param3 ) @@ -26,7 +28,7 @@ def _get_kwargs(param4: str, param2: int, param1: str, param3: int, *, client: M } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -35,7 +37,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -44,9 +46,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed( - param4: str, param2: int, param1: str, param3: int, *, client: Union[MyTestApiClient, Unset] = UNSET -) -> Response[Any]: +def sync_detailed(param4: str, param2: int, param1: str, param3: int, client: "MyTestApiClient") -> Response[Any]: """ Args: param4 (str): @@ -62,7 +62,6 @@ def sync_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param4=param4, param2=param2, @@ -79,8 +78,33 @@ def sync_detailed( return _build_response(client=client, response=response) +def sync(param4: str, param2: int, param1: str, param3: int, client: "MyTestApiClient") -> Optional[Any]: + """ + Args: + param4 (str): + param2 (int): + param1 (str): + param3 (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + param4=param4, + param2=param2, + param1=param1, + param3=param3, + client=client, + ).parsed + + async def asyncio_detailed( - param4: str, param2: int, param1: str, param3: int, *, client: Union[MyTestApiClient, Unset] = UNSET + param4: str, param2: int, param1: str, param3: int, client: "MyTestApiClient" ) -> Response[Any]: """ Args: @@ -97,7 +121,6 @@ async def asyncio_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( param4=param4, param2=param2, @@ -110,3 +133,30 @@ async def asyncio_detailed( response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio(param4: str, param2: int, param1: str, param3: int, client: "MyTestApiClient") -> Optional[Any]: + """ + Args: + param4 (str): + param2 (int): + param1 (str): + param3 (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + param4=param4, + param2=param2, + param1=param1, + param3=param3, + client=client, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/__init__.py index e69de29bb..472097eda 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/__init__.py @@ -0,0 +1,50 @@ +from typing import TYPE_CHECKING, Any, Optional + +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Dict, cast + +from ...models.post_responses_unions_simple_before_complex_response_200 import ( + PostResponsesUnionsSimpleBeforeComplexResponse200, +) +from . import post_responses_unions_simple_before_complex + + +class Responses: + def __init__(self, client: "MyTestApiClient"): + self.__client = client + + def post_responses_unions_simple_before_complex( + self, + ) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: + """Regression test for #603 + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PostResponsesUnionsSimpleBeforeComplexResponse200] + """ + + return post_responses_unions_simple_before_complex.sync( + client=self.__client, + ) + + async def post_responses_unions_simple_before_complex_async( + self, + ) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: + """Regression test for #603 + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PostResponsesUnionsSimpleBeforeComplexResponse200] + """ + + return await post_responses_unions_simple_before_complex.asyncio( + client=self.__client, + ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py index 002a85097..813311a0b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py @@ -1,17 +1,21 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Dict + from ... import errors -from ...client import MyTestApiClient from ...models.post_responses_unions_simple_before_complex_response_200 import ( PostResponsesUnionsSimpleBeforeComplexResponse200, ) -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/responses/unions/simple_before_complex".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -28,7 +32,7 @@ def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: def _parse_response( - *, client: MyTestApiClient, response: httpx.Response + *, client: "MyTestApiClient", response: httpx.Response ) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: if response.status_code == HTTPStatus.OK: response_200 = PostResponsesUnionsSimpleBeforeComplexResponse200.from_dict(response.json()) @@ -41,7 +45,7 @@ def _parse_response( def _build_response( - *, client: MyTestApiClient, response: httpx.Response + *, client: "MyTestApiClient", response: httpx.Response ) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: return Response( status_code=HTTPStatus(response.status_code), @@ -51,9 +55,7 @@ def _build_response( ) -def sync_detailed( - *, client: Union[MyTestApiClient, Unset] = UNSET -) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: +def sync_detailed(client: "MyTestApiClient") -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: """Regression test for #603 Raises: @@ -64,7 +66,6 @@ def sync_detailed( Response[PostResponsesUnionsSimpleBeforeComplexResponse200] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -77,9 +78,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync( - *, client: Union[MyTestApiClient, Unset] = UNSET -) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: +def sync(client: "MyTestApiClient") -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: """Regression test for #603 Raises: @@ -95,9 +94,7 @@ def sync( ).parsed -async def asyncio_detailed( - *, client: Union[MyTestApiClient, Unset] = UNSET -) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: +async def asyncio_detailed(client: "MyTestApiClient") -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: """Regression test for #603 Raises: @@ -108,7 +105,6 @@ async def asyncio_detailed( Response[PostResponsesUnionsSimpleBeforeComplexResponse200] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -119,9 +115,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - *, client: Union[MyTestApiClient, Unset] = UNSET -) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: +async def asyncio(client: "MyTestApiClient") -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: """Regression test for #603 Raises: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/__init__.py index e69de29bb..cab48e2fc 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/__init__.py @@ -0,0 +1,43 @@ +from typing import TYPE_CHECKING, Any, Optional + +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from . import get_tag_with_number + + +class Tag1: + def __init__(self, client: "MyTestApiClient"): + self.__client = client + + def get_tag_with_number( + self, + ) -> Optional[Any]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return get_tag_with_number.sync( + client=self.__client, + ) + + async def get_tag_with_number_async( + self, + ) -> Optional[Any]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await get_tag_with_number.asyncio( + client=self.__client, + ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py index 8cdd0b48d..9163bcc6b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py @@ -1,14 +1,16 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + from ... import errors -from ...client import MyTestApiClient -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tag_with_number".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -24,7 +26,7 @@ def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -33,7 +35,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -42,7 +44,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync_detailed(client: "MyTestApiClient") -> Response[Any]: """ Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -52,7 +54,6 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -65,7 +66,22 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ return _build_response(client=client, response=response) -async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync(client: "MyTestApiClient") -> Optional[Any]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed(client: "MyTestApiClient") -> Response[Any]: """ Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -75,7 +91,6 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -84,3 +99,20 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio(client: "MyTestApiClient") -> Optional[Any]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/__init__.py index e69de29bb..2292b1b2e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/__init__.py @@ -0,0 +1,992 @@ +from typing import TYPE_CHECKING, Any, Optional + +if TYPE_CHECKING: + from ...client import MyTestApiClient + +import datetime +from io import BytesIO +from typing import Dict, List, Optional, Union, cast + +from dateutil.parser import isoparse + +from ...models.a_form_data import AFormData +from ...models.a_model import AModel +from ...models.an_enum import AnEnum +from ...models.an_enum_with_null import AnEnumWithNull +from ...models.an_int_enum import AnIntEnum +from ...models.body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost +from ...models.http_validation_error import HTTPValidationError +from ...models.model_with_union_property import ModelWithUnionProperty +from ...models.post_form_data_inline_data import PostFormDataInlineData +from ...models.test_inline_objects_json_body import TestInlineObjectsJsonBody +from ...models.test_inline_objects_response_200 import TestInlineObjectsResponse200 +from ...types import UNSET, File, FileJsonType, Unset +from . import ( + callback_test, + defaults_tests_defaults_post, + description_with_backslash, + get_basic_list_of_booleans, + get_basic_list_of_floats, + get_basic_list_of_integers, + get_basic_list_of_strings, + get_user_list, + int_enum_tests_int_enum_post, + json_body_tests_json_body_post, + no_response_tests_no_response_get, + octet_stream_tests_octet_stream_get, + post_form_data, + post_form_data_inline, + post_tests_json_body_string, + test_inline_objects, + token_with_cookie_auth_token_with_cookie_get, + unsupported_content_tests_unsupported_content_get, + upload_file_tests_upload_post, + upload_multiple_files_tests_upload_post, +) + + +class Tests: + def __init__(self, client: "MyTestApiClient"): + self.__client = client + + def get_user_list( + self, + *, + an_enum_value: List[AnEnum], + an_enum_value_with_null: List[Optional[AnEnumWithNull]], + an_enum_value_with_only_null: List[None], + some_date: Union[datetime.date, datetime.datetime], + ) -> Optional[Union[HTTPValidationError, List["AModel"]]]: + """Get List + + Get a list of things + + Args: + an_enum_value (List[AnEnum]): + an_enum_value_with_null (List[Optional[AnEnumWithNull]]): + an_enum_value_with_only_null (List[None]): + some_date (Union[datetime.date, datetime.datetime]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, List['AModel']]] + """ + + return get_user_list.sync( + client=self.__client, + an_enum_value=an_enum_value, + an_enum_value_with_null=an_enum_value_with_null, + an_enum_value_with_only_null=an_enum_value_with_only_null, + some_date=some_date, + ) + + async def get_user_list_async( + self, + *, + an_enum_value: List[AnEnum], + an_enum_value_with_null: List[Optional[AnEnumWithNull]], + an_enum_value_with_only_null: List[None], + some_date: Union[datetime.date, datetime.datetime], + ) -> Optional[Union[HTTPValidationError, List["AModel"]]]: + """Get List + + Get a list of things + + Args: + an_enum_value (List[AnEnum]): + an_enum_value_with_null (List[Optional[AnEnumWithNull]]): + an_enum_value_with_only_null (List[None]): + some_date (Union[datetime.date, datetime.datetime]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, List['AModel']]] + """ + + return await get_user_list.asyncio( + client=self.__client, + an_enum_value=an_enum_value, + an_enum_value_with_null=an_enum_value_with_null, + an_enum_value_with_only_null=an_enum_value_with_only_null, + some_date=some_date, + ) + + def get_basic_list_of_strings( + self, + ) -> Optional[List[str]]: + """Get Basic List Of Strings + + Get a list of strings + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[List[str]] + """ + + return get_basic_list_of_strings.sync( + client=self.__client, + ) + + async def get_basic_list_of_strings_async( + self, + ) -> Optional[List[str]]: + """Get Basic List Of Strings + + Get a list of strings + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[List[str]] + """ + + return await get_basic_list_of_strings.asyncio( + client=self.__client, + ) + + def get_basic_list_of_integers( + self, + ) -> Optional[List[int]]: + """Get Basic List Of Integers + + Get a list of integers + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[List[int]] + """ + + return get_basic_list_of_integers.sync( + client=self.__client, + ) + + async def get_basic_list_of_integers_async( + self, + ) -> Optional[List[int]]: + """Get Basic List Of Integers + + Get a list of integers + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[List[int]] + """ + + return await get_basic_list_of_integers.asyncio( + client=self.__client, + ) + + def get_basic_list_of_floats( + self, + ) -> Optional[List[float]]: + """Get Basic List Of Floats + + Get a list of floats + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[List[float]] + """ + + return get_basic_list_of_floats.sync( + client=self.__client, + ) + + async def get_basic_list_of_floats_async( + self, + ) -> Optional[List[float]]: + """Get Basic List Of Floats + + Get a list of floats + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[List[float]] + """ + + return await get_basic_list_of_floats.asyncio( + client=self.__client, + ) + + def get_basic_list_of_booleans( + self, + ) -> Optional[List[bool]]: + """Get Basic List Of Booleans + + Get a list of booleans + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[List[bool]] + """ + + return get_basic_list_of_booleans.sync( + client=self.__client, + ) + + async def get_basic_list_of_booleans_async( + self, + ) -> Optional[List[bool]]: + """Get Basic List Of Booleans + + Get a list of booleans + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[List[bool]] + """ + + return await get_basic_list_of_booleans.asyncio( + client=self.__client, + ) + + def post_form_data( + self, + *, + form_data: AFormData, + ) -> Optional[Any]: + """Post form data + + Post form data + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return post_form_data.sync( + client=self.__client, + form_data=form_data, + ) + + async def post_form_data_async( + self, + *, + form_data: AFormData, + ) -> Optional[Any]: + """Post form data + + Post form data + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await post_form_data.asyncio( + client=self.__client, + form_data=form_data, + ) + + def post_form_data_inline( + self, + *, + form_data: PostFormDataInlineData, + ) -> Optional[Any]: + """Post form data (inline schema) + + Post form data (inline schema) + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return post_form_data_inline.sync( + client=self.__client, + form_data=form_data, + ) + + async def post_form_data_inline_async( + self, + *, + form_data: PostFormDataInlineData, + ) -> Optional[Any]: + """Post form data (inline schema) + + Post form data (inline schema) + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await post_form_data_inline.asyncio( + client=self.__client, + form_data=form_data, + ) + + def upload_file_tests_upload_post( + self, + *, + multipart_data: BodyUploadFileTestsUploadPost, + ) -> Optional[Union[Any, HTTPValidationError]]: + """Upload File + + Upload a file + + Args: + multipart_data (BodyUploadFileTestsUploadPost): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + return upload_file_tests_upload_post.sync( + client=self.__client, + multipart_data=multipart_data, + ) + + async def upload_file_tests_upload_post_async( + self, + *, + multipart_data: BodyUploadFileTestsUploadPost, + ) -> Optional[Union[Any, HTTPValidationError]]: + """Upload File + + Upload a file + + Args: + multipart_data (BodyUploadFileTestsUploadPost): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + return await upload_file_tests_upload_post.asyncio( + client=self.__client, + multipart_data=multipart_data, + ) + + def upload_multiple_files_tests_upload_post( + self, + *, + multipart_data: List[File], + ) -> Optional[Union[Any, HTTPValidationError]]: + """Upload multiple files + + Upload several files in the same request + + Args: + multipart_data (List[File]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + return upload_multiple_files_tests_upload_post.sync( + client=self.__client, + multipart_data=multipart_data, + ) + + async def upload_multiple_files_tests_upload_post_async( + self, + *, + multipart_data: List[File], + ) -> Optional[Union[Any, HTTPValidationError]]: + """Upload multiple files + + Upload several files in the same request + + Args: + multipart_data (List[File]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + return await upload_multiple_files_tests_upload_post.asyncio( + client=self.__client, + multipart_data=multipart_data, + ) + + def json_body_tests_json_body_post( + self, + *, + json_body: AModel, + ) -> Optional[Union[Any, HTTPValidationError]]: + """Json Body + + Try sending a JSON body + + Args: + json_body (AModel): A Model for testing all the ways custom objects can be used + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + return json_body_tests_json_body_post.sync( + client=self.__client, + json_body=json_body, + ) + + async def json_body_tests_json_body_post_async( + self, + *, + json_body: AModel, + ) -> Optional[Union[Any, HTTPValidationError]]: + """Json Body + + Try sending a JSON body + + Args: + json_body (AModel): A Model for testing all the ways custom objects can be used + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + return await json_body_tests_json_body_post.asyncio( + client=self.__client, + json_body=json_body, + ) + + def post_tests_json_body_string( + self, + *, + json_body: str, + ) -> Optional[Union[HTTPValidationError, str]]: + """Json Body Which is String + + Args: + json_body (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + return post_tests_json_body_string.sync( + client=self.__client, + json_body=json_body, + ) + + async def post_tests_json_body_string_async( + self, + *, + json_body: str, + ) -> Optional[Union[HTTPValidationError, str]]: + """Json Body Which is String + + Args: + json_body (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + return await post_tests_json_body_string.asyncio( + client=self.__client, + json_body=json_body, + ) + + def defaults_tests_defaults_post( + self, + *, + string_prop: str = "the default string", + date_prop: datetime.date = isoparse("1010-10-10").date(), + float_prop: float = 3.14, + int_prop: int = 7, + boolean_prop: bool = False, + list_prop: List[AnEnum], + union_prop: Union[float, str] = "not a float", + union_prop_with_ref: Union[AnEnum, None, Unset, float] = 0.6, + enum_prop: AnEnum, + model_prop: "ModelWithUnionProperty", + required_model_prop: "ModelWithUnionProperty", + ) -> Optional[Union[Any, HTTPValidationError]]: + """Defaults + + Args: + string_prop (str): Default: 'the default string'. + date_prop (datetime.date): Default: isoparse('1010-10-10').date(). + float_prop (float): Default: 3.14. + int_prop (int): Default: 7. + boolean_prop (bool): + list_prop (List[AnEnum]): + union_prop (Union[float, str]): Default: 'not a float'. + union_prop_with_ref (Union[AnEnum, None, Unset, float]): Default: 0.6. + enum_prop (AnEnum): For testing Enums in all the ways they can be used + model_prop (ModelWithUnionProperty): + required_model_prop (ModelWithUnionProperty): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + return defaults_tests_defaults_post.sync( + client=self.__client, + string_prop=string_prop, + date_prop=date_prop, + float_prop=float_prop, + int_prop=int_prop, + boolean_prop=boolean_prop, + list_prop=list_prop, + union_prop=union_prop, + union_prop_with_ref=union_prop_with_ref, + enum_prop=enum_prop, + model_prop=model_prop, + required_model_prop=required_model_prop, + ) + + async def defaults_tests_defaults_post_async( + self, + *, + string_prop: str = "the default string", + date_prop: datetime.date = isoparse("1010-10-10").date(), + float_prop: float = 3.14, + int_prop: int = 7, + boolean_prop: bool = False, + list_prop: List[AnEnum], + union_prop: Union[float, str] = "not a float", + union_prop_with_ref: Union[AnEnum, None, Unset, float] = 0.6, + enum_prop: AnEnum, + model_prop: "ModelWithUnionProperty", + required_model_prop: "ModelWithUnionProperty", + ) -> Optional[Union[Any, HTTPValidationError]]: + """Defaults + + Args: + string_prop (str): Default: 'the default string'. + date_prop (datetime.date): Default: isoparse('1010-10-10').date(). + float_prop (float): Default: 3.14. + int_prop (int): Default: 7. + boolean_prop (bool): + list_prop (List[AnEnum]): + union_prop (Union[float, str]): Default: 'not a float'. + union_prop_with_ref (Union[AnEnum, None, Unset, float]): Default: 0.6. + enum_prop (AnEnum): For testing Enums in all the ways they can be used + model_prop (ModelWithUnionProperty): + required_model_prop (ModelWithUnionProperty): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + return await defaults_tests_defaults_post.asyncio( + client=self.__client, + string_prop=string_prop, + date_prop=date_prop, + float_prop=float_prop, + int_prop=int_prop, + boolean_prop=boolean_prop, + list_prop=list_prop, + union_prop=union_prop, + union_prop_with_ref=union_prop_with_ref, + enum_prop=enum_prop, + model_prop=model_prop, + required_model_prop=required_model_prop, + ) + + def octet_stream_tests_octet_stream_get( + self, + ) -> Optional[File]: + """Octet Stream + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[File] + """ + + return octet_stream_tests_octet_stream_get.sync( + client=self.__client, + ) + + async def octet_stream_tests_octet_stream_get_async( + self, + ) -> Optional[File]: + """Octet Stream + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[File] + """ + + return await octet_stream_tests_octet_stream_get.asyncio( + client=self.__client, + ) + + def no_response_tests_no_response_get( + self, + ) -> Optional[Any]: + """No Response + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return no_response_tests_no_response_get.sync( + client=self.__client, + ) + + async def no_response_tests_no_response_get_async( + self, + ) -> Optional[Any]: + """No Response + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await no_response_tests_no_response_get.asyncio( + client=self.__client, + ) + + def unsupported_content_tests_unsupported_content_get( + self, + ) -> Optional[Any]: + """Unsupported Content + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return unsupported_content_tests_unsupported_content_get.sync( + client=self.__client, + ) + + async def unsupported_content_tests_unsupported_content_get_async( + self, + ) -> Optional[Any]: + """Unsupported Content + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await unsupported_content_tests_unsupported_content_get.asyncio( + client=self.__client, + ) + + def int_enum_tests_int_enum_post( + self, + *, + int_enum: AnIntEnum, + ) -> Optional[Union[Any, HTTPValidationError]]: + """Int Enum + + Args: + int_enum (AnIntEnum): An enumeration. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + return int_enum_tests_int_enum_post.sync( + client=self.__client, + int_enum=int_enum, + ) + + async def int_enum_tests_int_enum_post_async( + self, + *, + int_enum: AnIntEnum, + ) -> Optional[Union[Any, HTTPValidationError]]: + """Int Enum + + Args: + int_enum (AnIntEnum): An enumeration. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + return await int_enum_tests_int_enum_post.asyncio( + client=self.__client, + int_enum=int_enum, + ) + + def test_inline_objects( + self, + *, + json_body: TestInlineObjectsJsonBody, + ) -> Optional[TestInlineObjectsResponse200]: + """Test Inline Objects + + Args: + json_body (TestInlineObjectsJsonBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[TestInlineObjectsResponse200] + """ + + return test_inline_objects.sync( + client=self.__client, + json_body=json_body, + ) + + async def test_inline_objects_async( + self, + *, + json_body: TestInlineObjectsJsonBody, + ) -> Optional[TestInlineObjectsResponse200]: + """Test Inline Objects + + Args: + json_body (TestInlineObjectsJsonBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[TestInlineObjectsResponse200] + """ + + return await test_inline_objects.asyncio( + client=self.__client, + json_body=json_body, + ) + + def token_with_cookie_auth_token_with_cookie_get( + self, + *, + my_token: str, + ) -> Optional[Any]: + """TOKEN_WITH_COOKIE + + Test optional cookie parameters + + Args: + my_token (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return token_with_cookie_auth_token_with_cookie_get.sync( + client=self.__client, + my_token=my_token, + ) + + async def token_with_cookie_auth_token_with_cookie_get_async( + self, + *, + my_token: str, + ) -> Optional[Any]: + """TOKEN_WITH_COOKIE + + Test optional cookie parameters + + Args: + my_token (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await token_with_cookie_auth_token_with_cookie_get.asyncio( + client=self.__client, + my_token=my_token, + ) + + def callback_test( + self, + *, + json_body: AModel, + ) -> Optional[Union[Any, HTTPValidationError]]: + """Path with callback + + Try sending a request related to a callback + + Args: + json_body (AModel): A Model for testing all the ways custom objects can be used + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + return callback_test.sync( + client=self.__client, + json_body=json_body, + ) + + async def callback_test_async( + self, + *, + json_body: AModel, + ) -> Optional[Union[Any, HTTPValidationError]]: + """Path with callback + + Try sending a request related to a callback + + Args: + json_body (AModel): A Model for testing all the ways custom objects can be used + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + return await callback_test.asyncio( + client=self.__client, + json_body=json_body, + ) + + def description_with_backslash( + self, + ) -> Optional[Any]: + r""" Test description with \ + + Test description with \ + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return description_with_backslash.sync( + client=self.__client, + ) + + async def description_with_backslash_async( + self, + ) -> Optional[Any]: + r""" Test description with \ + + Test description with \ + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await description_with_backslash.asyncio( + client=self.__client, + ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py index 3904ee966..f1bd23aa2 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py @@ -1,16 +1,20 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Dict, cast + from ... import errors -from ...client import MyTestApiClient from ...models.a_model import AModel from ...models.http_validation_error import HTTPValidationError -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, json_body: AModel, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(*, json_body: AModel, client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/callback".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -29,7 +33,9 @@ def _get_kwargs(*, json_body: AModel, client: MyTestApiClient) -> Dict[str, Any] } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response( + *, client: "MyTestApiClient", response: httpx.Response +) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 @@ -43,7 +49,9 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: +def _build_response( + *, client: "MyTestApiClient", response: httpx.Response +) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,9 +60,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed( - *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET -) -> Response[Union[Any, HTTPValidationError]]: +def sync_detailed(*, json_body: AModel, client: "MyTestApiClient") -> Response[Union[Any, HTTPValidationError]]: """Path with callback Try sending a request related to a callback @@ -70,7 +76,6 @@ def sync_detailed( Response[Union[Any, HTTPValidationError]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -84,9 +89,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync( - *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET -) -> Optional[Union[Any, HTTPValidationError]]: +def sync(*, json_body: AModel, client: "MyTestApiClient") -> Optional[Union[Any, HTTPValidationError]]: """Path with callback Try sending a request related to a callback @@ -109,7 +112,7 @@ def sync( async def asyncio_detailed( - *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET + *, json_body: AModel, client: "MyTestApiClient" ) -> Response[Union[Any, HTTPValidationError]]: """Path with callback @@ -126,7 +129,6 @@ async def asyncio_detailed( Response[Union[Any, HTTPValidationError]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -138,9 +140,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET -) -> Optional[Union[Any, HTTPValidationError]]: +async def asyncio(*, json_body: AModel, client: "MyTestApiClient") -> Optional[Union[Any, HTTPValidationError]]: """Path with callback Try sending a request related to a callback diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py index 32f725ed2..99af81bfd 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py @@ -1,12 +1,17 @@ -import datetime from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast import httpx + +if TYPE_CHECKING: + from ...client import MyTestApiClient + +import datetime +from typing import Dict, List, Optional, Union, cast + from dateutil.parser import isoparse from ... import errors -from ...client import MyTestApiClient from ...models.an_enum import AnEnum from ...models.http_validation_error import HTTPValidationError from ...models.model_with_union_property import ModelWithUnionProperty @@ -26,7 +31,7 @@ def _get_kwargs( enum_prop: AnEnum, model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", - client: MyTestApiClient, + client: "MyTestApiClient", ) -> Dict[str, Any]: url = "{}/tests/defaults".format(client.base_url) @@ -100,7 +105,9 @@ def _get_kwargs( } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response( + *, client: "MyTestApiClient", response: httpx.Response +) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 @@ -114,7 +121,9 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: +def _build_response( + *, client: "MyTestApiClient", response: httpx.Response +) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -136,7 +145,7 @@ def sync_detailed( enum_prop: AnEnum, model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Response[Union[Any, HTTPValidationError]]: """Defaults @@ -161,7 +170,6 @@ def sync_detailed( Response[Union[Any, HTTPValidationError]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, string_prop=string_prop, @@ -198,7 +206,7 @@ def sync( enum_prop: AnEnum, model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Optional[Union[Any, HTTPValidationError]]: """Defaults @@ -252,7 +260,7 @@ async def asyncio_detailed( enum_prop: AnEnum, model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Response[Union[Any, HTTPValidationError]]: """Defaults @@ -277,7 +285,6 @@ async def asyncio_detailed( Response[Union[Any, HTTPValidationError]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, string_prop=string_prop, @@ -312,7 +319,7 @@ async def asyncio( enum_prop: AnEnum, model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Optional[Union[Any, HTTPValidationError]]: """Defaults diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py index f65a73cae..002402fc6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py @@ -1,14 +1,16 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + from ... import errors -from ...client import MyTestApiClient -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/description-with-backslash".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -24,7 +26,7 @@ def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -33,7 +35,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -42,7 +44,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync_detailed(client: "MyTestApiClient") -> Response[Any]: r""" Test description with \ Test description with \ @@ -55,7 +57,6 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -68,7 +69,25 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ return _build_response(client=client, response=response) -async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync(client: "MyTestApiClient") -> Optional[Any]: + r""" Test description with \ + + Test description with \ + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed(client: "MyTestApiClient") -> Response[Any]: r""" Test description with \ Test description with \ @@ -81,7 +100,6 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -90,3 +108,23 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio(client: "MyTestApiClient") -> Optional[Any]: + r""" Test description with \ + + Test description with \ + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py index 4c63ce29b..ce0726bc2 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py @@ -1,14 +1,18 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import List, cast + from ... import errors -from ...client import MyTestApiClient -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/basic_lists/booleans".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -24,7 +28,7 @@ def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[List[bool]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[List[bool]]: if response.status_code == HTTPStatus.OK: response_200 = cast(List[bool], response.json()) @@ -35,7 +39,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[List[bool]]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[List[bool]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -44,7 +48,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[bool]]: +def sync_detailed(client: "MyTestApiClient") -> Response[List[bool]]: """Get Basic List Of Booleans Get a list of booleans @@ -57,7 +61,6 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ Response[List[bool]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -70,7 +73,7 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ return _build_response(client=client, response=response) -def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[bool]]: +def sync(client: "MyTestApiClient") -> Optional[List[bool]]: """Get Basic List Of Booleans Get a list of booleans @@ -88,7 +91,7 @@ def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[bool ).parsed -async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[bool]]: +async def asyncio_detailed(client: "MyTestApiClient") -> Response[List[bool]]: """Get Basic List Of Booleans Get a list of booleans @@ -101,7 +104,6 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[bool]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -112,7 +114,7 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> return _build_response(client=client, response=response) -async def asyncio(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[bool]]: +async def asyncio(client: "MyTestApiClient") -> Optional[List[bool]]: """Get Basic List Of Booleans Get a list of booleans diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py index 0b47eef84..897f674fb 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py @@ -1,14 +1,18 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import List, cast + from ... import errors -from ...client import MyTestApiClient -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/basic_lists/floats".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -24,7 +28,7 @@ def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[List[float]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[List[float]]: if response.status_code == HTTPStatus.OK: response_200 = cast(List[float], response.json()) @@ -35,7 +39,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[List[float]]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[List[float]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -44,7 +48,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[float]]: +def sync_detailed(client: "MyTestApiClient") -> Response[List[float]]: """Get Basic List Of Floats Get a list of floats @@ -57,7 +61,6 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ Response[List[float]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -70,7 +73,7 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ return _build_response(client=client, response=response) -def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[float]]: +def sync(client: "MyTestApiClient") -> Optional[List[float]]: """Get Basic List Of Floats Get a list of floats @@ -88,7 +91,7 @@ def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[floa ).parsed -async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[float]]: +async def asyncio_detailed(client: "MyTestApiClient") -> Response[List[float]]: """Get Basic List Of Floats Get a list of floats @@ -101,7 +104,6 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[float]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -112,7 +114,7 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> return _build_response(client=client, response=response) -async def asyncio(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[float]]: +async def asyncio(client: "MyTestApiClient") -> Optional[List[float]]: """Get Basic List Of Floats Get a list of floats diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py index 9739e5aa4..86146196b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py @@ -1,14 +1,18 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import List, cast + from ... import errors -from ...client import MyTestApiClient -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/basic_lists/integers".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -24,7 +28,7 @@ def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[List[int]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[List[int]]: if response.status_code == HTTPStatus.OK: response_200 = cast(List[int], response.json()) @@ -35,7 +39,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[List[int]]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[List[int]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -44,7 +48,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[int]]: +def sync_detailed(client: "MyTestApiClient") -> Response[List[int]]: """Get Basic List Of Integers Get a list of integers @@ -57,7 +61,6 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ Response[List[int]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -70,7 +73,7 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ return _build_response(client=client, response=response) -def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[int]]: +def sync(client: "MyTestApiClient") -> Optional[List[int]]: """Get Basic List Of Integers Get a list of integers @@ -88,7 +91,7 @@ def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[int] ).parsed -async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[int]]: +async def asyncio_detailed(client: "MyTestApiClient") -> Response[List[int]]: """Get Basic List Of Integers Get a list of integers @@ -101,7 +104,6 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[int]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -112,7 +114,7 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> return _build_response(client=client, response=response) -async def asyncio(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[int]]: +async def asyncio(client: "MyTestApiClient") -> Optional[List[int]]: """Get Basic List Of Integers Get a list of integers diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py index 31da99599..0589fc529 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py @@ -1,14 +1,18 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import List, cast + from ... import errors -from ...client import MyTestApiClient -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/basic_lists/strings".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -24,7 +28,7 @@ def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[List[str]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[List[str]]: if response.status_code == HTTPStatus.OK: response_200 = cast(List[str], response.json()) @@ -35,7 +39,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[List[str]]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[List[str]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -44,7 +48,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[str]]: +def sync_detailed(client: "MyTestApiClient") -> Response[List[str]]: """Get Basic List Of Strings Get a list of strings @@ -57,7 +61,6 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ Response[List[str]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -70,7 +73,7 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ return _build_response(client=client, response=response) -def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[str]]: +def sync(client: "MyTestApiClient") -> Optional[List[str]]: """Get Basic List Of Strings Get a list of strings @@ -88,7 +91,7 @@ def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[str] ).parsed -async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[str]]: +async def asyncio_detailed(client: "MyTestApiClient") -> Response[List[str]]: """Get Basic List Of Strings Get a list of strings @@ -101,7 +104,6 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[List[str]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -112,7 +114,7 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> return _build_response(client=client, response=response) -async def asyncio(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[List[str]]: +async def asyncio(client: "MyTestApiClient") -> Optional[List[str]]: """Get Basic List Of Strings Get a list of strings diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py index aa5beddbb..11bb58b58 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py @@ -1,16 +1,20 @@ -import datetime from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +import datetime +from typing import Dict, List, Optional, Union + from ... import errors -from ...client import MyTestApiClient from ...models.a_model import AModel from ...models.an_enum import AnEnum from ...models.an_enum_with_null import AnEnumWithNull from ...models.http_validation_error import HTTPValidationError -from ...types import UNSET, Response, Unset +from ...types import UNSET, Response def _get_kwargs( @@ -19,7 +23,7 @@ def _get_kwargs( an_enum_value_with_null: List[Optional[AnEnumWithNull]], an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], - client: MyTestApiClient, + client: "MyTestApiClient", ) -> Dict[str, Any]: url = "{}/tests/".format(client.base_url) @@ -72,7 +76,7 @@ def _get_kwargs( def _parse_response( - *, client: MyTestApiClient, response: httpx.Response + *, client: "MyTestApiClient", response: httpx.Response ) -> Optional[Union[HTTPValidationError, List["AModel"]]]: if response.status_code == HTTPStatus.OK: response_200 = [] @@ -98,7 +102,7 @@ def _parse_response( def _build_response( - *, client: MyTestApiClient, response: httpx.Response + *, client: "MyTestApiClient", response: httpx.Response ) -> Response[Union[HTTPValidationError, List["AModel"]]]: return Response( status_code=HTTPStatus(response.status_code), @@ -114,7 +118,7 @@ def sync_detailed( an_enum_value_with_null: List[Optional[AnEnumWithNull]], an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Response[Union[HTTPValidationError, List["AModel"]]]: """Get List @@ -134,7 +138,6 @@ def sync_detailed( Response[Union[HTTPValidationError, List['AModel']]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, an_enum_value=an_enum_value, @@ -157,7 +160,7 @@ def sync( an_enum_value_with_null: List[Optional[AnEnumWithNull]], an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Optional[Union[HTTPValidationError, List["AModel"]]]: """Get List @@ -192,7 +195,7 @@ async def asyncio_detailed( an_enum_value_with_null: List[Optional[AnEnumWithNull]], an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Response[Union[HTTPValidationError, List["AModel"]]]: """Get List @@ -212,7 +215,6 @@ async def asyncio_detailed( Response[Union[HTTPValidationError, List['AModel']]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, an_enum_value=an_enum_value, @@ -233,7 +235,7 @@ async def asyncio( an_enum_value_with_null: List[Optional[AnEnumWithNull]], an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], - client: Union[MyTestApiClient, Unset] = UNSET, + client: "MyTestApiClient", ) -> Optional[Union[HTTPValidationError, List["AModel"]]]: """Get List diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py index 26c3f3a5d..e0b2a336b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py @@ -1,16 +1,20 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Dict, cast + from ... import errors -from ...client import MyTestApiClient from ...models.an_int_enum import AnIntEnum from ...models.http_validation_error import HTTPValidationError -from ...types import UNSET, Response, Unset +from ...types import UNSET, Response -def _get_kwargs(*, int_enum: AnIntEnum, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(*, int_enum: AnIntEnum, client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/int_enum".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -34,7 +38,9 @@ def _get_kwargs(*, int_enum: AnIntEnum, client: MyTestApiClient) -> Dict[str, An } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response( + *, client: "MyTestApiClient", response: httpx.Response +) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 @@ -48,7 +54,9 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: +def _build_response( + *, client: "MyTestApiClient", response: httpx.Response +) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -57,9 +65,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed( - *, int_enum: AnIntEnum, client: Union[MyTestApiClient, Unset] = UNSET -) -> Response[Union[Any, HTTPValidationError]]: +def sync_detailed(*, int_enum: AnIntEnum, client: "MyTestApiClient") -> Response[Union[Any, HTTPValidationError]]: """Int Enum Args: @@ -73,7 +79,6 @@ def sync_detailed( Response[Union[Any, HTTPValidationError]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, int_enum=int_enum, @@ -87,9 +92,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync( - *, int_enum: AnIntEnum, client: Union[MyTestApiClient, Unset] = UNSET -) -> Optional[Union[Any, HTTPValidationError]]: +def sync(*, int_enum: AnIntEnum, client: "MyTestApiClient") -> Optional[Union[Any, HTTPValidationError]]: """Int Enum Args: @@ -110,7 +113,7 @@ def sync( async def asyncio_detailed( - *, int_enum: AnIntEnum, client: Union[MyTestApiClient, Unset] = UNSET + *, int_enum: AnIntEnum, client: "MyTestApiClient" ) -> Response[Union[Any, HTTPValidationError]]: """Int Enum @@ -125,7 +128,6 @@ async def asyncio_detailed( Response[Union[Any, HTTPValidationError]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, int_enum=int_enum, @@ -137,9 +139,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - *, int_enum: AnIntEnum, client: Union[MyTestApiClient, Unset] = UNSET -) -> Optional[Union[Any, HTTPValidationError]]: +async def asyncio(*, int_enum: AnIntEnum, client: "MyTestApiClient") -> Optional[Union[Any, HTTPValidationError]]: """Int Enum Args: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py index 763823866..e69224747 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py @@ -1,16 +1,20 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Dict, cast + from ... import errors -from ...client import MyTestApiClient from ...models.a_model import AModel from ...models.http_validation_error import HTTPValidationError -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, json_body: AModel, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(*, json_body: AModel, client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/json_body".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -29,7 +33,9 @@ def _get_kwargs(*, json_body: AModel, client: MyTestApiClient) -> Dict[str, Any] } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response( + *, client: "MyTestApiClient", response: httpx.Response +) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 @@ -43,7 +49,9 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: +def _build_response( + *, client: "MyTestApiClient", response: httpx.Response +) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,9 +60,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed( - *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET -) -> Response[Union[Any, HTTPValidationError]]: +def sync_detailed(*, json_body: AModel, client: "MyTestApiClient") -> Response[Union[Any, HTTPValidationError]]: """Json Body Try sending a JSON body @@ -70,7 +76,6 @@ def sync_detailed( Response[Union[Any, HTTPValidationError]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -84,9 +89,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync( - *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET -) -> Optional[Union[Any, HTTPValidationError]]: +def sync(*, json_body: AModel, client: "MyTestApiClient") -> Optional[Union[Any, HTTPValidationError]]: """Json Body Try sending a JSON body @@ -109,7 +112,7 @@ def sync( async def asyncio_detailed( - *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET + *, json_body: AModel, client: "MyTestApiClient" ) -> Response[Union[Any, HTTPValidationError]]: """Json Body @@ -126,7 +129,6 @@ async def asyncio_detailed( Response[Union[Any, HTTPValidationError]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -138,9 +140,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - *, json_body: AModel, client: Union[MyTestApiClient, Unset] = UNSET -) -> Optional[Union[Any, HTTPValidationError]]: +async def asyncio(*, json_body: AModel, client: "MyTestApiClient") -> Optional[Union[Any, HTTPValidationError]]: """Json Body Try sending a JSON body diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py index 305b09e14..a5f679dd3 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py @@ -1,14 +1,16 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + from ... import errors -from ...client import MyTestApiClient -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/no_response".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -24,7 +26,7 @@ def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -33,7 +35,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -42,7 +44,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync_detailed(client: "MyTestApiClient") -> Response[Any]: """No Response Raises: @@ -53,7 +55,6 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -66,7 +67,23 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ return _build_response(client=client, response=response) -async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync(client: "MyTestApiClient") -> Optional[Any]: + """No Response + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed(client: "MyTestApiClient") -> Response[Any]: """No Response Raises: @@ -77,7 +94,6 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -86,3 +102,21 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio(client: "MyTestApiClient") -> Optional[Any]: + """No Response + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py index 3def18598..77165c017 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py @@ -1,15 +1,18 @@ from http import HTTPStatus -from io import BytesIO -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from io import BytesIO + from ... import errors -from ...client import MyTestApiClient -from ...types import UNSET, File, Response, Unset +from ...types import File, Response -def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/octet_stream".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -25,7 +28,7 @@ def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[File]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[File]: if response.status_code == HTTPStatus.OK: response_200 = File(payload=BytesIO(response.content)) @@ -36,7 +39,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[File]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[File]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -45,7 +48,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[File]: +def sync_detailed(client: "MyTestApiClient") -> Response[File]: """Octet Stream Raises: @@ -56,7 +59,6 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ Response[File] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -69,7 +71,7 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ return _build_response(client=client, response=response) -def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[File]: +def sync(client: "MyTestApiClient") -> Optional[File]: """Octet Stream Raises: @@ -85,7 +87,7 @@ def sync(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[File]: ).parsed -async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[File]: +async def asyncio_detailed(client: "MyTestApiClient") -> Response[File]: """Octet Stream Raises: @@ -96,7 +98,6 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[File] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -107,7 +108,7 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> return _build_response(client=client, response=response) -async def asyncio(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[File]: +async def asyncio(client: "MyTestApiClient") -> Optional[File]: """Octet Stream Raises: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py index 7a4ff7d34..0d65faadd 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py @@ -1,15 +1,19 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Dict + from ... import errors -from ...client import MyTestApiClient from ...models.a_form_data import AFormData -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, form_data: AFormData, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(*, form_data: AFormData, client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/post_form_data".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -26,7 +30,7 @@ def _get_kwargs(*, form_data: AFormData, client: MyTestApiClient) -> Dict[str, A } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -35,7 +39,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -44,7 +48,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed(*, form_data: AFormData, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync_detailed(*, form_data: AFormData, client: "MyTestApiClient") -> Response[Any]: """Post form data Post form data @@ -57,7 +61,6 @@ def sync_detailed(*, form_data: AFormData, client: Union[MyTestApiClient, Unset] Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, form_data=form_data, @@ -71,7 +74,26 @@ def sync_detailed(*, form_data: AFormData, client: Union[MyTestApiClient, Unset] return _build_response(client=client, response=response) -async def asyncio_detailed(*, form_data: AFormData, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync(*, form_data: AFormData, client: "MyTestApiClient") -> Optional[Any]: + """Post form data + + Post form data + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + client=client, + form_data=form_data, + ).parsed + + +async def asyncio_detailed(*, form_data: AFormData, client: "MyTestApiClient") -> Response[Any]: """Post form data Post form data @@ -84,7 +106,6 @@ async def asyncio_detailed(*, form_data: AFormData, client: Union[MyTestApiClien Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, form_data=form_data, @@ -94,3 +115,24 @@ async def asyncio_detailed(*, form_data: AFormData, client: Union[MyTestApiClien response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio(*, form_data: AFormData, client: "MyTestApiClient") -> Optional[Any]: + """Post form data + + Post form data + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + client=client, + form_data=form_data, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py index 505b99345..09465045a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py @@ -1,15 +1,19 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Dict + from ... import errors -from ...client import MyTestApiClient from ...models.post_form_data_inline_data import PostFormDataInlineData -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, form_data: PostFormDataInlineData, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(*, form_data: PostFormDataInlineData, client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/post_form_data_inline".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -26,7 +30,7 @@ def _get_kwargs(*, form_data: PostFormDataInlineData, client: MyTestApiClient) - } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -35,7 +39,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -44,7 +48,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed(*, form_data: PostFormDataInlineData, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync_detailed(*, form_data: PostFormDataInlineData, client: "MyTestApiClient") -> Response[Any]: """Post form data (inline schema) Post form data (inline schema) @@ -57,7 +61,6 @@ def sync_detailed(*, form_data: PostFormDataInlineData, client: Union[MyTestApiC Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, form_data=form_data, @@ -71,9 +74,26 @@ def sync_detailed(*, form_data: PostFormDataInlineData, client: Union[MyTestApiC return _build_response(client=client, response=response) -async def asyncio_detailed( - *, form_data: PostFormDataInlineData, client: Union[MyTestApiClient, Unset] = UNSET -) -> Response[Any]: +def sync(*, form_data: PostFormDataInlineData, client: "MyTestApiClient") -> Optional[Any]: + """Post form data (inline schema) + + Post form data (inline schema) + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + client=client, + form_data=form_data, + ).parsed + + +async def asyncio_detailed(*, form_data: PostFormDataInlineData, client: "MyTestApiClient") -> Response[Any]: """Post form data (inline schema) Post form data (inline schema) @@ -86,7 +106,6 @@ async def asyncio_detailed( Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, form_data=form_data, @@ -96,3 +115,24 @@ async def asyncio_detailed( response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio(*, form_data: PostFormDataInlineData, client: "MyTestApiClient") -> Optional[Any]: + """Post form data (inline schema) + + Post form data (inline schema) + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + client=client, + form_data=form_data, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py index 81ec9867b..7a8510341 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py @@ -1,15 +1,19 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Dict, cast + from ... import errors -from ...client import MyTestApiClient from ...models.http_validation_error import HTTPValidationError -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, json_body: str, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(*, json_body: str, client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/json_body/string".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -28,7 +32,9 @@ def _get_kwargs(*, json_body: str, client: MyTestApiClient) -> Dict[str, Any]: } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Union[HTTPValidationError, str]]: +def _parse_response( + *, client: "MyTestApiClient", response: httpx.Response +) -> Optional[Union[HTTPValidationError, str]]: if response.status_code == HTTPStatus.OK: response_200 = cast(str, response.json()) return response_200 @@ -42,7 +48,9 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Union[HTTPValidationError, str]]: +def _build_response( + *, client: "MyTestApiClient", response: httpx.Response +) -> Response[Union[HTTPValidationError, str]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -51,9 +59,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed( - *, json_body: str, client: Union[MyTestApiClient, Unset] = UNSET -) -> Response[Union[HTTPValidationError, str]]: +def sync_detailed(*, json_body: str, client: "MyTestApiClient") -> Response[Union[HTTPValidationError, str]]: """Json Body Which is String Args: @@ -67,7 +73,6 @@ def sync_detailed( Response[Union[HTTPValidationError, str]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -81,7 +86,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync(*, json_body: str, client: Union[MyTestApiClient, Unset] = UNSET) -> Optional[Union[HTTPValidationError, str]]: +def sync(*, json_body: str, client: "MyTestApiClient") -> Optional[Union[HTTPValidationError, str]]: """Json Body Which is String Args: @@ -101,9 +106,7 @@ def sync(*, json_body: str, client: Union[MyTestApiClient, Unset] = UNSET) -> Op ).parsed -async def asyncio_detailed( - *, json_body: str, client: Union[MyTestApiClient, Unset] = UNSET -) -> Response[Union[HTTPValidationError, str]]: +async def asyncio_detailed(*, json_body: str, client: "MyTestApiClient") -> Response[Union[HTTPValidationError, str]]: """Json Body Which is String Args: @@ -117,7 +120,6 @@ async def asyncio_detailed( Response[Union[HTTPValidationError, str]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -129,9 +131,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - *, json_body: str, client: Union[MyTestApiClient, Unset] = UNSET -) -> Optional[Union[HTTPValidationError, str]]: +async def asyncio(*, json_body: str, client: "MyTestApiClient") -> Optional[Union[HTTPValidationError, str]]: """Json Body Which is String Args: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py index 5a4f15d18..cfba3cb23 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py @@ -1,16 +1,20 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Dict + from ... import errors -from ...client import MyTestApiClient from ...models.test_inline_objects_json_body import TestInlineObjectsJsonBody from ...models.test_inline_objects_response_200 import TestInlineObjectsResponse200 -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, json_body: TestInlineObjectsJsonBody, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(*, json_body: TestInlineObjectsJsonBody, client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/inline_objects".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -29,7 +33,7 @@ def _get_kwargs(*, json_body: TestInlineObjectsJsonBody, client: MyTestApiClient } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[TestInlineObjectsResponse200]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[TestInlineObjectsResponse200]: if response.status_code == HTTPStatus.OK: response_200 = TestInlineObjectsResponse200.from_dict(response.json()) @@ -40,7 +44,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[TestInlineObjectsResponse200]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[TestInlineObjectsResponse200]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -50,7 +54,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res def sync_detailed( - *, json_body: TestInlineObjectsJsonBody, client: Union[MyTestApiClient, Unset] = UNSET + *, json_body: TestInlineObjectsJsonBody, client: "MyTestApiClient" ) -> Response[TestInlineObjectsResponse200]: """Test Inline Objects @@ -65,7 +69,6 @@ def sync_detailed( Response[TestInlineObjectsResponse200] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -79,9 +82,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync( - *, json_body: TestInlineObjectsJsonBody, client: Union[MyTestApiClient, Unset] = UNSET -) -> Optional[TestInlineObjectsResponse200]: +def sync(*, json_body: TestInlineObjectsJsonBody, client: "MyTestApiClient") -> Optional[TestInlineObjectsResponse200]: """Test Inline Objects Args: @@ -102,7 +103,7 @@ def sync( async def asyncio_detailed( - *, json_body: TestInlineObjectsJsonBody, client: Union[MyTestApiClient, Unset] = UNSET + *, json_body: TestInlineObjectsJsonBody, client: "MyTestApiClient" ) -> Response[TestInlineObjectsResponse200]: """Test Inline Objects @@ -117,7 +118,6 @@ async def asyncio_detailed( Response[TestInlineObjectsResponse200] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, json_body=json_body, @@ -130,7 +130,7 @@ async def asyncio_detailed( async def asyncio( - *, json_body: TestInlineObjectsJsonBody, client: Union[MyTestApiClient, Unset] = UNSET + *, json_body: TestInlineObjectsJsonBody, client: "MyTestApiClient" ) -> Optional[TestInlineObjectsResponse200]: """Test Inline Objects diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py index 552b09389..928a3a1ad 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py @@ -1,14 +1,16 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + from ... import errors -from ...client import MyTestApiClient -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, my_token: str, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(*, my_token: str, client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/auth/token_with_cookie".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -26,7 +28,7 @@ def _get_kwargs(*, my_token: str, client: MyTestApiClient) -> Dict[str, Any]: } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if response.status_code == HTTPStatus.UNAUTHORIZED: @@ -37,7 +39,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -46,7 +48,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed(*, my_token: str, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync_detailed(*, my_token: str, client: "MyTestApiClient") -> Response[Any]: """TOKEN_WITH_COOKIE Test optional cookie parameters @@ -62,7 +64,6 @@ def sync_detailed(*, my_token: str, client: Union[MyTestApiClient, Unset] = UNSE Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, my_token=my_token, @@ -76,7 +77,29 @@ def sync_detailed(*, my_token: str, client: Union[MyTestApiClient, Unset] = UNSE return _build_response(client=client, response=response) -async def asyncio_detailed(*, my_token: str, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync(*, my_token: str, client: "MyTestApiClient") -> Optional[Any]: + """TOKEN_WITH_COOKIE + + Test optional cookie parameters + + Args: + my_token (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + client=client, + my_token=my_token, + ).parsed + + +async def asyncio_detailed(*, my_token: str, client: "MyTestApiClient") -> Response[Any]: """TOKEN_WITH_COOKIE Test optional cookie parameters @@ -92,7 +115,6 @@ async def asyncio_detailed(*, my_token: str, client: Union[MyTestApiClient, Unse Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, my_token=my_token, @@ -102,3 +124,27 @@ async def asyncio_detailed(*, my_token: str, client: Union[MyTestApiClient, Unse response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio(*, my_token: str, client: "MyTestApiClient") -> Optional[Any]: + """TOKEN_WITH_COOKIE + + Test optional cookie parameters + + Args: + my_token (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + client=client, + my_token=my_token, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py index 883168c9c..3eb796123 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py @@ -1,14 +1,16 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + from ... import errors -from ...client import MyTestApiClient -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/unsupported_content".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -24,7 +26,7 @@ def _get_kwargs(*, client: MyTestApiClient) -> Dict[str, Any]: } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -33,7 +35,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -42,7 +44,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync_detailed(client: "MyTestApiClient") -> Response[Any]: """Unsupported Content Raises: @@ -53,7 +55,6 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -66,7 +67,23 @@ def sync_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[ return _build_response(client=client, response=response) -async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync(client: "MyTestApiClient") -> Optional[Any]: + """Unsupported Content + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed(client: "MyTestApiClient") -> Response[Any]: """Unsupported Content Raises: @@ -77,7 +94,6 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, ) @@ -86,3 +102,21 @@ async def asyncio_detailed(*, client: Union[MyTestApiClient, Unset] = UNSET) -> response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio(client: "MyTestApiClient") -> Optional[Any]: + """Unsupported Content + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py index 6f93be5ab..37662cade 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py @@ -1,16 +1,20 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Dict, cast + from ... import errors -from ...client import MyTestApiClient from ...models.body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost from ...models.http_validation_error import HTTPValidationError -from ...types import UNSET, Response, Unset +from ...types import Response -def _get_kwargs(*, multipart_data: BodyUploadFileTestsUploadPost, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(*, multipart_data: BodyUploadFileTestsUploadPost, client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/upload".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -29,7 +33,9 @@ def _get_kwargs(*, multipart_data: BodyUploadFileTestsUploadPost, client: MyTest } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response( + *, client: "MyTestApiClient", response: httpx.Response +) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 @@ -43,7 +49,9 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: +def _build_response( + *, client: "MyTestApiClient", response: httpx.Response +) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -53,7 +61,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res def sync_detailed( - *, multipart_data: BodyUploadFileTestsUploadPost, client: Union[MyTestApiClient, Unset] = UNSET + *, multipart_data: BodyUploadFileTestsUploadPost, client: "MyTestApiClient" ) -> Response[Union[Any, HTTPValidationError]]: """Upload File @@ -70,7 +78,6 @@ def sync_detailed( Response[Union[Any, HTTPValidationError]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, multipart_data=multipart_data, @@ -85,7 +92,7 @@ def sync_detailed( def sync( - *, multipart_data: BodyUploadFileTestsUploadPost, client: Union[MyTestApiClient, Unset] = UNSET + *, multipart_data: BodyUploadFileTestsUploadPost, client: "MyTestApiClient" ) -> Optional[Union[Any, HTTPValidationError]]: """Upload File @@ -109,7 +116,7 @@ def sync( async def asyncio_detailed( - *, multipart_data: BodyUploadFileTestsUploadPost, client: Union[MyTestApiClient, Unset] = UNSET + *, multipart_data: BodyUploadFileTestsUploadPost, client: "MyTestApiClient" ) -> Response[Union[Any, HTTPValidationError]]: """Upload File @@ -126,7 +133,6 @@ async def asyncio_detailed( Response[Union[Any, HTTPValidationError]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, multipart_data=multipart_data, @@ -139,7 +145,7 @@ async def asyncio_detailed( async def asyncio( - *, multipart_data: BodyUploadFileTestsUploadPost, client: Union[MyTestApiClient, Unset] = UNSET + *, multipart_data: BodyUploadFileTestsUploadPost, client: "MyTestApiClient" ) -> Optional[Union[Any, HTTPValidationError]]: """Upload File diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py index 32bafedd4..5814d8d9e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py @@ -1,15 +1,19 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from typing import Dict, List, cast + from ... import errors -from ...client import MyTestApiClient from ...models.http_validation_error import HTTPValidationError -from ...types import UNSET, File, Response, Unset +from ...types import File, Response -def _get_kwargs(*, multipart_data: List[File], client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(*, multipart_data: List[File], client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/tests/upload/multiple".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -32,7 +36,9 @@ def _get_kwargs(*, multipart_data: List[File], client: MyTestApiClient) -> Dict[ } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response( + *, client: "MyTestApiClient", response: httpx.Response +) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 @@ -46,7 +52,9 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: +def _build_response( + *, client: "MyTestApiClient", response: httpx.Response +) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -56,7 +64,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res def sync_detailed( - *, multipart_data: List[File], client: Union[MyTestApiClient, Unset] = UNSET + *, multipart_data: List[File], client: "MyTestApiClient" ) -> Response[Union[Any, HTTPValidationError]]: """Upload multiple files @@ -73,7 +81,6 @@ def sync_detailed( Response[Union[Any, HTTPValidationError]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, multipart_data=multipart_data, @@ -87,9 +94,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync( - *, multipart_data: List[File], client: Union[MyTestApiClient, Unset] = UNSET -) -> Optional[Union[Any, HTTPValidationError]]: +def sync(*, multipart_data: List[File], client: "MyTestApiClient") -> Optional[Union[Any, HTTPValidationError]]: """Upload multiple files Upload several files in the same request @@ -112,7 +117,7 @@ def sync( async def asyncio_detailed( - *, multipart_data: List[File], client: Union[MyTestApiClient, Unset] = UNSET + *, multipart_data: List[File], client: "MyTestApiClient" ) -> Response[Union[Any, HTTPValidationError]]: """Upload multiple files @@ -129,7 +134,6 @@ async def asyncio_detailed( Response[Union[Any, HTTPValidationError]] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, multipart_data=multipart_data, @@ -142,7 +146,7 @@ async def asyncio_detailed( async def asyncio( - *, multipart_data: List[File], client: Union[MyTestApiClient, Unset] = UNSET + *, multipart_data: List[File], client: "MyTestApiClient" ) -> Optional[Union[Any, HTTPValidationError]]: """Upload multiple files diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/true_/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/true_/__init__.py index e69de29bb..1fca75837 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/true_/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/true_/__init__.py @@ -0,0 +1,55 @@ +from typing import TYPE_CHECKING, Any, Optional + +if TYPE_CHECKING: + from ...client import MyTestApiClient + +from . import false_ + + +class True_: + def __init__(self, client: "MyTestApiClient"): + self.__client = client + + def false_( + self, + *, + import_: str, + ) -> Optional[Any]: + """ + Args: + import_ (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return false_.sync( + client=self.__client, + import_=import_, + ) + + async def false__async( + self, + *, + import_: str, + ) -> Optional[Any]: + """ + Args: + import_ (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return await false_.asyncio( + client=self.__client, + import_=import_, + ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py b/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py index 1661caf38..d67b71c88 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py @@ -1,14 +1,16 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional import httpx +if TYPE_CHECKING: + from ...client import MyTestApiClient + from ... import errors -from ...client import MyTestApiClient -from ...types import UNSET, Response, Unset +from ...types import UNSET, Response -def _get_kwargs(*, import_: str, client: MyTestApiClient) -> Dict[str, Any]: +def _get_kwargs(*, import_: str, client: "MyTestApiClient") -> Dict[str, Any]: url = "{}/naming/keywords".format(client.base_url) headers: Dict[str, str] = client.get_headers() @@ -30,7 +32,7 @@ def _get_kwargs(*, import_: str, client: MyTestApiClient) -> Dict[str, Any]: } -def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if client.raise_on_unexpected_status: @@ -39,7 +41,7 @@ def _parse_response(*, client: MyTestApiClient, response: httpx.Response) -> Opt return None -def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -48,7 +50,7 @@ def _build_response(*, client: MyTestApiClient, response: httpx.Response) -> Res ) -def sync_detailed(*, import_: str, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync_detailed(*, import_: str, client: "MyTestApiClient") -> Response[Any]: """ Args: import_ (str): @@ -61,7 +63,6 @@ def sync_detailed(*, import_: str, client: Union[MyTestApiClient, Unset] = UNSET Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, import_=import_, @@ -75,7 +76,26 @@ def sync_detailed(*, import_: str, client: Union[MyTestApiClient, Unset] = UNSET return _build_response(client=client, response=response) -async def asyncio_detailed(*, import_: str, client: Union[MyTestApiClient, Unset] = UNSET) -> Response[Any]: +def sync(*, import_: str, client: "MyTestApiClient") -> Optional[Any]: + """ + Args: + import_ (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return sync_detailed( + client=client, + import_=import_, + ).parsed + + +async def asyncio_detailed(*, import_: str, client: "MyTestApiClient") -> Response[Any]: """ Args: import_ (str): @@ -88,7 +108,6 @@ async def asyncio_detailed(*, import_: str, client: Union[MyTestApiClient, Unset Response[Any] """ - client = client if not isinstance(client, Unset) else MyTestApiClient.instance() kwargs = _get_kwargs( client=client, import_=import_, @@ -98,3 +117,24 @@ async def asyncio_detailed(*, import_: str, client: Union[MyTestApiClient, Unset response = await _client.request(**kwargs) return _build_response(client=client, response=response) + + +async def asyncio(*, import_: str, client: "MyTestApiClient") -> Optional[Any]: + """ + Args: + import_ (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + return ( + await asyncio_detailed( + client=client, + import_=import_, + ) + ).parsed diff --git a/end_to_end_tests/golden-record/my_test_api_client/client.py b/end_to_end_tests/golden-record/my_test_api_client/client.py index 4f63a031d..5b8009f11 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/client.py +++ b/end_to_end_tests/golden-record/my_test_api_client/client.py @@ -1,7 +1,15 @@ import ssl -import threading from typing import Dict, Union +from .api.default import Default +from .api.location import Location +from .api.parameter_references import ParameterReferences +from .api.parameters import Parameters +from .api.responses import Responses +from .api.tag1 import Tag1 +from .api.tests import Tests +from .api.true_ import True_ + class MyTestApiClient: """A class for keeping track of data related to the API @@ -19,42 +27,6 @@ class MyTestApiClient: follow_redirects: Whether or not to follow redirects. Default value is False. """ - __lock__ = threading.RLock() - __instance__: Union["MyTestApiClient", None] = None - - @classmethod - def configure( - cls, - base_url: str = "http://localhost:8080", - cookies: Union[Dict[str, str], None] = None, - headers: Union[Dict[str, str], None] = None, - timeout: float = 5.0, - verify_ssl: Union[str, bool, ssl.SSLContext] = True, - raise_on_unexpected_status: bool = False, - follow_redirects: bool = False, - token: Union[str, None] = None, - prefix: str = "Bearer", - auth_header_name: str = "Authorization", - ) -> "MyTestApiClient": - cookies = cookies if cookies is not None else {} - headers = headers if headers is not None else {} - - with cls.__lock__: - cls.__instance__ = cls( - base_url=base_url, - cookies=cookies, - headers=headers, - timeout=timeout, - verify_ssl=verify_ssl, - raise_on_unexpected_status=raise_on_unexpected_status, - follow_redirects=follow_redirects, - token=token, - prefix=prefix, - auth_header_name=auth_header_name, - ) - - return cls.__instance__ - def __init__( self, base_url: str, @@ -82,12 +54,14 @@ def __init__( self.prefix = prefix self.auth_header_name = auth_header_name - @classmethod - def instance(cls) -> "MyTestApiClient": - if cls.__instance__ is None: - return cls.configure() - else: - return cls.__instance__ + self.tests = Tests(client=self) + self.responses = Responses(client=self) + self.default = Default(client=self) + self.parameters = Parameters(client=self) + self.tag1 = Tag1(client=self) + self.location = Location(client=self) + self.true_ = True_(client=self) + self.parameter_references = ParameterReferences(client=self) def get_headers(self) -> Dict[str, str]: """Get headers to be used in all endpoints""" diff --git a/end_to_end_tests/golden-record/my_test_api_client/default.py b/end_to_end_tests/golden-record/my_test_api_client/default.py deleted file mode 100644 index cf7604f03..000000000 --- a/end_to_end_tests/golden-record/my_test_api_client/default.py +++ /dev/null @@ -1,9 +0,0 @@ -from .api.default import get_common_parameters as __get_common_parameters -from .api.default import post_common_parameters as __post_common_parameters - -get_common_parameters = __get_common_parameters.sync_detailed -get_common_parameters_async = __get_common_parameters.asyncio_detailed - - -post_common_parameters = __post_common_parameters.sync_detailed -post_common_parameters_async = __post_common_parameters.asyncio_detailed diff --git a/end_to_end_tests/golden-record/my_test_api_client/location.py b/end_to_end_tests/golden-record/my_test_api_client/location.py deleted file mode 100644 index 2769eabce..000000000 --- a/end_to_end_tests/golden-record/my_test_api_client/location.py +++ /dev/null @@ -1,9 +0,0 @@ -from .api.location import get_location_header_types as __get_location_header_types -from .api.location import get_location_query_optionality as __get_location_query_optionality - -get_location_query_optionality = __get_location_query_optionality.sync_detailed -get_location_query_optionality_async = __get_location_query_optionality.asyncio_detailed - - -get_location_header_types = __get_location_header_types.sync_detailed -get_location_header_types_async = __get_location_header_types.asyncio_detailed diff --git a/end_to_end_tests/golden-record/my_test_api_client/parameter_references.py b/end_to_end_tests/golden-record/my_test_api_client/parameter_references.py deleted file mode 100644 index f3409ddf4..000000000 --- a/end_to_end_tests/golden-record/my_test_api_client/parameter_references.py +++ /dev/null @@ -1,4 +0,0 @@ -from .api.parameter_references import get_parameter_references_path_param as __get_parameter_references_path_param - -get_parameter_references_path_param = __get_parameter_references_path_param.sync_detailed -get_parameter_references_path_param_async = __get_parameter_references_path_param.asyncio_detailed diff --git a/end_to_end_tests/golden-record/my_test_api_client/parameters.py b/end_to_end_tests/golden-record/my_test_api_client/parameters.py deleted file mode 100644 index 935a1744f..000000000 --- a/end_to_end_tests/golden-record/my_test_api_client/parameters.py +++ /dev/null @@ -1,19 +0,0 @@ -from .api.parameters import delete_common_parameters_overriding_param as __delete_common_parameters_overriding_param -from .api.parameters import get_common_parameters_overriding_param as __get_common_parameters_overriding_param -from .api.parameters import get_same_name_multiple_locations_param as __get_same_name_multiple_locations_param -from .api.parameters import multiple_path_parameters as __multiple_path_parameters - -get_common_parameters_overriding_param = __get_common_parameters_overriding_param.sync_detailed -get_common_parameters_overriding_param_async = __get_common_parameters_overriding_param.asyncio_detailed - - -delete_common_parameters_overriding_param = __delete_common_parameters_overriding_param.sync_detailed -delete_common_parameters_overriding_param_async = __delete_common_parameters_overriding_param.asyncio_detailed - - -get_same_name_multiple_locations_param = __get_same_name_multiple_locations_param.sync_detailed -get_same_name_multiple_locations_param_async = __get_same_name_multiple_locations_param.asyncio_detailed - - -multiple_path_parameters = __multiple_path_parameters.sync_detailed -multiple_path_parameters_async = __multiple_path_parameters.asyncio_detailed diff --git a/end_to_end_tests/golden-record/my_test_api_client/responses.py b/end_to_end_tests/golden-record/my_test_api_client/responses.py deleted file mode 100644 index a207897ee..000000000 --- a/end_to_end_tests/golden-record/my_test_api_client/responses.py +++ /dev/null @@ -1,8 +0,0 @@ -from .api.responses import post_responses_unions_simple_before_complex as __post_responses_unions_simple_before_complex - -post_responses_unions_simple_before_complex = __post_responses_unions_simple_before_complex.sync -post_responses_unions_simple_before_complex_detailed = __post_responses_unions_simple_before_complex.sync_detailed -post_responses_unions_simple_before_complex_async = __post_responses_unions_simple_before_complex.asyncio -post_responses_unions_simple_before_complex_async_detailed = ( - __post_responses_unions_simple_before_complex.asyncio_detailed -) diff --git a/end_to_end_tests/golden-record/my_test_api_client/tag1.py b/end_to_end_tests/golden-record/my_test_api_client/tag1.py deleted file mode 100644 index ec78db61f..000000000 --- a/end_to_end_tests/golden-record/my_test_api_client/tag1.py +++ /dev/null @@ -1,4 +0,0 @@ -from .api.tag1 import get_tag_with_number as __get_tag_with_number - -get_tag_with_number = __get_tag_with_number.sync_detailed -get_tag_with_number_async = __get_tag_with_number.asyncio_detailed diff --git a/end_to_end_tests/golden-record/my_test_api_client/tests.py b/end_to_end_tests/golden-record/my_test_api_client/tests.py deleted file mode 100644 index f858d514c..000000000 --- a/end_to_end_tests/golden-record/my_test_api_client/tests.py +++ /dev/null @@ -1,131 +0,0 @@ -from .api.tests import callback_test as __callback_test -from .api.tests import defaults_tests_defaults_post as __defaults_tests_defaults_post -from .api.tests import description_with_backslash as __description_with_backslash -from .api.tests import get_basic_list_of_booleans as __get_basic_list_of_booleans -from .api.tests import get_basic_list_of_floats as __get_basic_list_of_floats -from .api.tests import get_basic_list_of_integers as __get_basic_list_of_integers -from .api.tests import get_basic_list_of_strings as __get_basic_list_of_strings -from .api.tests import get_user_list as __get_user_list -from .api.tests import int_enum_tests_int_enum_post as __int_enum_tests_int_enum_post -from .api.tests import json_body_tests_json_body_post as __json_body_tests_json_body_post -from .api.tests import no_response_tests_no_response_get as __no_response_tests_no_response_get -from .api.tests import octet_stream_tests_octet_stream_get as __octet_stream_tests_octet_stream_get -from .api.tests import post_form_data as __post_form_data -from .api.tests import post_form_data_inline as __post_form_data_inline -from .api.tests import post_tests_json_body_string as __post_tests_json_body_string -from .api.tests import test_inline_objects as __test_inline_objects -from .api.tests import token_with_cookie_auth_token_with_cookie_get as __token_with_cookie_auth_token_with_cookie_get -from .api.tests import ( - unsupported_content_tests_unsupported_content_get as __unsupported_content_tests_unsupported_content_get, -) -from .api.tests import upload_file_tests_upload_post as __upload_file_tests_upload_post -from .api.tests import upload_multiple_files_tests_upload_post as __upload_multiple_files_tests_upload_post - -get_user_list = __get_user_list.sync -get_user_list_detailed = __get_user_list.sync_detailed -get_user_list_async = __get_user_list.asyncio -get_user_list_async_detailed = __get_user_list.asyncio_detailed - - -get_basic_list_of_strings = __get_basic_list_of_strings.sync -get_basic_list_of_strings_detailed = __get_basic_list_of_strings.sync_detailed -get_basic_list_of_strings_async = __get_basic_list_of_strings.asyncio -get_basic_list_of_strings_async_detailed = __get_basic_list_of_strings.asyncio_detailed - - -get_basic_list_of_integers = __get_basic_list_of_integers.sync -get_basic_list_of_integers_detailed = __get_basic_list_of_integers.sync_detailed -get_basic_list_of_integers_async = __get_basic_list_of_integers.asyncio -get_basic_list_of_integers_async_detailed = __get_basic_list_of_integers.asyncio_detailed - - -get_basic_list_of_floats = __get_basic_list_of_floats.sync -get_basic_list_of_floats_detailed = __get_basic_list_of_floats.sync_detailed -get_basic_list_of_floats_async = __get_basic_list_of_floats.asyncio -get_basic_list_of_floats_async_detailed = __get_basic_list_of_floats.asyncio_detailed - - -get_basic_list_of_booleans = __get_basic_list_of_booleans.sync -get_basic_list_of_booleans_detailed = __get_basic_list_of_booleans.sync_detailed -get_basic_list_of_booleans_async = __get_basic_list_of_booleans.asyncio -get_basic_list_of_booleans_async_detailed = __get_basic_list_of_booleans.asyncio_detailed - - -post_form_data = __post_form_data.sync_detailed -post_form_data_async = __post_form_data.asyncio_detailed - - -post_form_data_inline = __post_form_data_inline.sync_detailed -post_form_data_inline_async = __post_form_data_inline.asyncio_detailed - - -upload_file_tests_upload_post = __upload_file_tests_upload_post.sync -upload_file_tests_upload_post_detailed = __upload_file_tests_upload_post.sync_detailed -upload_file_tests_upload_post_async = __upload_file_tests_upload_post.asyncio -upload_file_tests_upload_post_async_detailed = __upload_file_tests_upload_post.asyncio_detailed - - -upload_multiple_files_tests_upload_post = __upload_multiple_files_tests_upload_post.sync -upload_multiple_files_tests_upload_post_detailed = __upload_multiple_files_tests_upload_post.sync_detailed -upload_multiple_files_tests_upload_post_async = __upload_multiple_files_tests_upload_post.asyncio -upload_multiple_files_tests_upload_post_async_detailed = __upload_multiple_files_tests_upload_post.asyncio_detailed - - -json_body_tests_json_body_post = __json_body_tests_json_body_post.sync -json_body_tests_json_body_post_detailed = __json_body_tests_json_body_post.sync_detailed -json_body_tests_json_body_post_async = __json_body_tests_json_body_post.asyncio -json_body_tests_json_body_post_async_detailed = __json_body_tests_json_body_post.asyncio_detailed - - -post_tests_json_body_string = __post_tests_json_body_string.sync -post_tests_json_body_string_detailed = __post_tests_json_body_string.sync_detailed -post_tests_json_body_string_async = __post_tests_json_body_string.asyncio -post_tests_json_body_string_async_detailed = __post_tests_json_body_string.asyncio_detailed - - -defaults_tests_defaults_post = __defaults_tests_defaults_post.sync -defaults_tests_defaults_post_detailed = __defaults_tests_defaults_post.sync_detailed -defaults_tests_defaults_post_async = __defaults_tests_defaults_post.asyncio -defaults_tests_defaults_post_async_detailed = __defaults_tests_defaults_post.asyncio_detailed - - -octet_stream_tests_octet_stream_get = __octet_stream_tests_octet_stream_get.sync -octet_stream_tests_octet_stream_get_detailed = __octet_stream_tests_octet_stream_get.sync_detailed -octet_stream_tests_octet_stream_get_async = __octet_stream_tests_octet_stream_get.asyncio -octet_stream_tests_octet_stream_get_async_detailed = __octet_stream_tests_octet_stream_get.asyncio_detailed - - -no_response_tests_no_response_get = __no_response_tests_no_response_get.sync_detailed -no_response_tests_no_response_get_async = __no_response_tests_no_response_get.asyncio_detailed - - -unsupported_content_tests_unsupported_content_get = __unsupported_content_tests_unsupported_content_get.sync_detailed -unsupported_content_tests_unsupported_content_get_async = ( - __unsupported_content_tests_unsupported_content_get.asyncio_detailed -) - - -int_enum_tests_int_enum_post = __int_enum_tests_int_enum_post.sync -int_enum_tests_int_enum_post_detailed = __int_enum_tests_int_enum_post.sync_detailed -int_enum_tests_int_enum_post_async = __int_enum_tests_int_enum_post.asyncio -int_enum_tests_int_enum_post_async_detailed = __int_enum_tests_int_enum_post.asyncio_detailed - - -test_inline_objects = __test_inline_objects.sync -test_inline_objects_detailed = __test_inline_objects.sync_detailed -test_inline_objects_async = __test_inline_objects.asyncio -test_inline_objects_async_detailed = __test_inline_objects.asyncio_detailed - - -token_with_cookie_auth_token_with_cookie_get = __token_with_cookie_auth_token_with_cookie_get.sync_detailed -token_with_cookie_auth_token_with_cookie_get_async = __token_with_cookie_auth_token_with_cookie_get.asyncio_detailed - - -callback_test = __callback_test.sync -callback_test_detailed = __callback_test.sync_detailed -callback_test_async = __callback_test.asyncio -callback_test_async_detailed = __callback_test.asyncio_detailed - - -description_with_backslash = __description_with_backslash.sync_detailed -description_with_backslash_async = __description_with_backslash.asyncio_detailed diff --git a/end_to_end_tests/golden-record/my_test_api_client/true_.py b/end_to_end_tests/golden-record/my_test_api_client/true_.py deleted file mode 100644 index 10e82e068..000000000 --- a/end_to_end_tests/golden-record/my_test_api_client/true_.py +++ /dev/null @@ -1,4 +0,0 @@ -from .api.true_ import false_ as __false_ - -false_ = __false_.sync_detailed -false__async = __false_.asyncio_detailed diff --git a/end_to_end_tests/test_custom_templates/client.py.jinja b/end_to_end_tests/test_custom_templates/client.py.jinja new file mode 100644 index 000000000..d60df5553 --- /dev/null +++ b/end_to_end_tests/test_custom_templates/client.py.jinja @@ -0,0 +1,60 @@ +import ssl +import threading +from typing import Dict, Union + + +class {{ client_name }}: + """A class for keeping track of data related to the API + + Attributes: + base_url: The base URL for the API, all requests are made to a relative path to this URL + cookies: A dictionary of cookies to be sent with every request + headers: A dictionary of headers to be sent with every request + timeout: The maximum amount of a time in seconds a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + verify_ssl: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. + follow_redirects: Whether or not to follow redirects. Default value is False. + """ + + def __init__( + self, + base_url: str, + cookies: Union[Dict[str, str], None] = None, + headers: Union[Dict[str, str], None] = None, + timeout: float = 5.0, + verify_ssl: Union[str, bool, ssl.SSLContext] = True, + raise_on_unexpected_status: bool = False, + follow_redirects: bool = False, + token: Union[str, None] = None, + prefix: str = "Bearer", + auth_header_name: str = "Authorization", + ): + cookies = cookies if cookies is not None else {} + headers = headers if headers is not None else {} + + self.base_url = base_url + self.cookies = cookies + self.headers = headers + self.timeout = timeout + self.verify_ssl = verify_ssl + self.raise_on_unexpected_status = raise_on_unexpected_status + self.follow_redirects = follow_redirects + self.token = token + self.prefix = prefix + self.auth_header_name = auth_header_name + + def get_headers(self) -> Dict[str, str]: + """Get headers to be used in all endpoints""" + if not self.token: + return {**self.headers} + auth_header_value = f"{self.prefix} {self.token}" if self.prefix else self.token + return {self.auth_header_name: auth_header_value, **self.headers} + + def get_cookies(self) -> Dict[str, str]: + return {**self.cookies} + + def get_timeout(self) -> float: + return self.timeout diff --git a/end_to_end_tests/test_end_to_end.py b/end_to_end_tests/test_end_to_end.py index 6ad49fcb9..db7daba94 100644 --- a/end_to_end_tests/test_end_to_end.py +++ b/end_to_end_tests/test_end_to_end.py @@ -97,6 +97,7 @@ def test_custom_templates(): expected_difference_paths = [ Path("README.md"), + Path("my_test_api_client").joinpath("client.py"), api_dir.joinpath("__init__.py"), ] diff --git a/openapi_python_client/__init__.py b/openapi_python_client/__init__.py index 04ea51f42..badc3010f 100644 --- a/openapi_python_client/__init__.py +++ b/openapi_python_client/__init__.py @@ -293,13 +293,13 @@ def _build_api(self) -> None: endpoint_template = self.env.get_template( "endpoint_module.py.jinja", globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"} ) - api_template = self.env.get_template( - "api.py.jinja", globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"} - ) api_doc_template = self.env.get_template( "api.md.jinja", globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"} ) for _, collection in endpoint_collections_by_tag.items(): + def module_name(endpoint): + return utils.PythonIdentifier(endpoint.name, self.config.field_prefix) + tag = collection.tag tag_dir = api_dir / tag.identifier_name tag_dir.mkdir() @@ -307,13 +307,10 @@ def _build_api(self) -> None: endpoint_init_path = tag_dir / "__init__.py" endpoint_init_template = self.env.get_template("endpoint_init.py.jinja") endpoint_init_path.write_text( - endpoint_init_template.render(endpoint_collection=collection), + endpoint_init_template.render(endpoint_collection=collection, module_name=module_name), encoding=self.file_encoding, ) - def module_name(endpoint): - return utils.PythonIdentifier(endpoint.name, self.config.field_prefix) - for endpoint in collection.endpoints: module_path = tag_dir / f"{module_name(endpoint)}.py" module_path.write_text( @@ -323,12 +320,6 @@ def module_name(endpoint): encoding=self.file_encoding, ) - api_path = self.package_dir / f"{tag.identifier_name}.py" - api_path.write_text( - api_template.render(endpoint_collection=collection, module_name=module_name), - encoding=self.file_encoding - ) - api_doc_path = docs_dir / f"{tag.class_name}.md" api_doc_path.write_text( api_doc_template.render(endpoint_collection=collection, module_name=module_name), diff --git a/openapi_python_client/templates/README.md.jinja b/openapi_python_client/templates/README.md.jinja index fcd9ba05e..10b1d3104 100644 --- a/openapi_python_client/templates/README.md.jinja +++ b/openapi_python_client/templates/README.md.jinja @@ -7,36 +7,29 @@ First, configure a client: ```python from {{ package_name }} import {{ client_name }} -{{ client_name }}.configure(base_url="https://api.example.com", token="SuperSecretToken") +client = {{ client_name }}(base_url="https://api.example.com", token="SuperSecretToken") ``` Now call your endpoint and use your models: ```python from {{ package_name }}.models import MyDataModel -from {{ package_name }}.my_tag import get_my_data_model -from {{ package_name }}.types import Response -my_data: MyDataModel = get_my_data_model() -# or if you need more info (e.g. status_code) -response: Response[MyDataModel] = get_my_data_model_detailed() +my_data: MyDataModel = client.my_tag.get_my_data_model() ``` Or do the same thing with an async version: ```python from {{ package_name }}.models import MyDataModel -from {{ package_name }}.my_tag import get_my_data_model -from {{ package_name }}.types import Response -my_data: MyDataModel = await get_my_data_model_async() -response: Response[MyDataModel] = await get_my_data_model_async_detailed() +my_data: MyDataModel = await client.get_my_data_model_async() ``` By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle. ```python -{{ client_name }}.configure( +client = {{ client_name }}( base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl="/path/to/certificate_bundle.pem", @@ -46,7 +39,7 @@ By default, when you're calling an HTTPS API it will attempt to verify that SSL You can also disable certificate validation altogether, but beware that **this is a security risk**. ```python -{{ client_name }}.configure( +client = {{ client_name }}( base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl=False @@ -56,11 +49,9 @@ You can also disable certificate validation altogether, but beware that **this i There are more settings on the generated `{{ client_name }}` class which let you control more runtime behavior, check out the docstring on that class for more info. Things to know: -1. Every path/method combo becomes provides you with four functions. For example: get_my_data_model has these methods: +1. Every path/method combo becomes provides you with two functions. For example: get_my_data_model has these methods: 1. `get_my_data_model`: Blocking request that returns parsed data (if successful) or `None` - 1. `get_my_data_model_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful. 1. `get_my_data_model_async`: Like `sync` but async instead of blocking - 1. `get_my_data_model_async_detailed`: Like `sync_detailed` but async instead of blocking 1. All path/query params, and bodies become method arguments. 1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above) diff --git a/openapi_python_client/templates/client.py.jinja b/openapi_python_client/templates/client.py.jinja index 0a0383ce5..48e2b8ca9 100644 --- a/openapi_python_client/templates/client.py.jinja +++ b/openapi_python_client/templates/client.py.jinja @@ -2,6 +2,10 @@ import ssl import threading from typing import Dict, Union +{% for collection in endpoint_collections_by_tag.values() %} +from .api.{{ collection.tag.identifier_name }} import {{ collection.tag.class_name }} +{% endfor %} + class {{ client_name }}: """A class for keeping track of data related to the API @@ -18,41 +22,6 @@ class {{ client_name }}: status code that was not documented in the source OpenAPI document. follow_redirects: Whether or not to follow redirects. Default value is False. """ - __lock__ = threading.RLock() - __instance__: Union["{{ client_name }}", None] = None - - @classmethod - def configure( - cls, - base_url: str = "http://localhost:8080", - cookies: Union[Dict[str, str], None] = None, - headers: Union[Dict[str, str], None] = None, - timeout: float = 5.0, - verify_ssl: Union[str, bool, ssl.SSLContext] = True, - raise_on_unexpected_status: bool = False, - follow_redirects: bool = False, - token: Union[str, None] = None, - prefix: str = "Bearer", - auth_header_name: str = "Authorization", - ) -> "{{ client_name }}": - cookies = cookies if cookies is not None else {} - headers = headers if headers is not None else {} - - with cls.__lock__: - cls.__instance__ = cls( - base_url=base_url, - cookies=cookies, - headers=headers, - timeout=timeout, - verify_ssl=verify_ssl, - raise_on_unexpected_status=raise_on_unexpected_status, - follow_redirects=follow_redirects, - token=token, - prefix=prefix, - auth_header_name=auth_header_name, - ) - - return cls.__instance__ def __init__( self, @@ -81,13 +50,10 @@ class {{ client_name }}: self.prefix = prefix self.auth_header_name = auth_header_name - @classmethod - def instance(cls) -> "{{ client_name }}": - if cls.__instance__ is None: - return cls.configure() - else: - return cls.__instance__ + {% for collection in endpoint_collections_by_tag.values() %} + self.{{ collection.tag.identifier_name }} = {{ collection.tag.class_name }}(client=self) + {% endfor %} def get_headers(self) -> Dict[str, str]: """Get headers to be used in all endpoints""" diff --git a/openapi_python_client/templates/endpoint_init.py.jinja b/openapi_python_client/templates/endpoint_init.py.jinja index e69de29bb..fb4f36d30 100644 --- a/openapi_python_client/templates/endpoint_init.py.jinja +++ b/openapi_python_client/templates/endpoint_init.py.jinja @@ -0,0 +1,48 @@ +from typing import Any, Optional, TYPE_CHECKING + +if TYPE_CHECKING: + from ...client import {{ client_name }} + +from . import ( +{% for endpoint in endpoint_collection.endpoints %} +{{ module_name(endpoint) }}, +{% endfor %} +) + +{% for endpoint in endpoint_collection.endpoints %} +{% for relative in endpoint.relative_imports %} +{{ relative }} +{% endfor %} +{% endfor %} + +{% from "endpoint_macros.py.jinja" import arguments, docstring, kwargs %} + +class {{ endpoint_collection.tag.class_name }}: + def __init__(self, client: "{{ client_name }}"): + self.__client = client + +{% for endpoint in endpoint_collection.endpoints %} +{% set return_string = endpoint.response_type() %} +{% set mod = module_name(endpoint) %} + + def {{ mod }}( + self, + {{ arguments(endpoint) | indent(4) }} + ) -> Optional[{{ return_string }}]: + {{ docstring(endpoint, return_string) | indent(8) }} + return {{ mod }}.sync( + client=self.__client, + {{ kwargs(endpoint, False) }} + ) + + async def {{ mod }}_async( + self, + {{ arguments(endpoint) | indent(4) }} + ) -> Optional[{{ return_string }}]: + {{ docstring(endpoint, return_string) | indent(8) }} + return await {{ mod }}.asyncio( + client=self.__client, + {{ kwargs(endpoint, False) }} + ) + +{% endfor %} diff --git a/openapi_python_client/templates/endpoint_macros.py.jinja b/openapi_python_client/templates/endpoint_macros.py.jinja index 7a3d339d8..20fbcaf63 100644 --- a/openapi_python_client/templates/endpoint_macros.py.jinja +++ b/openapi_python_client/templates/endpoint_macros.py.jinja @@ -83,7 +83,9 @@ params = {k: v for k, v in params.items() if v is not UNSET and v is not None} {% for parameter in endpoint.path_parameters.values() %} {{ parameter.to_string() }}, {% endfor %} +{% if endpoint.form_body or endpoint.multipart_body or endpoint.json_body or endpoint.query_parameters or endpoint.header_parameters or endpoint.cookie_parameters %} *, +{% endif %} {# Form data if any #} {% if endpoint.form_body %} form_data: {{ endpoint.form_body.get_type_string() }}, @@ -110,11 +112,13 @@ json_body: {{ endpoint.json_body.get_type_string() }}, {% endmacro %} {# Just lists all kwargs to endpoints as name=name for passing to other functions #} -{% macro kwargs(endpoint) %} +{% macro kwargs(endpoint, include_client=True) %} {% for parameter in endpoint.path_parameters.values() %} {{ parameter.python_name }}={{ parameter.python_name }}, {% endfor %} +{% if include_client %} client=client, +{% endif %} {% if endpoint.form_body %} form_data=form_data, {% endif %} diff --git a/openapi_python_client/templates/endpoint_module.py.jinja b/openapi_python_client/templates/endpoint_module.py.jinja index bc2ab479c..aa290a30f 100644 --- a/openapi_python_client/templates/endpoint_module.py.jinja +++ b/openapi_python_client/templates/endpoint_module.py.jinja @@ -1,10 +1,13 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union, cast +from typing import Any, Dict, List, Optional, Union, cast, TYPE_CHECKING + import httpx -from ...client import {{ client_name }} -from ...types import Response, UNSET, Unset +if TYPE_CHECKING: + from ...client import {{ client_name }} + +from ...types import Response, UNSET from ... import errors {% for relative in endpoint.relative_imports %} @@ -19,7 +22,7 @@ from ... import errors def _get_kwargs( {{ arguments(endpoint) | indent(4) }} - client: {{ client_name }} + client: "{{ client_name }}" ) -> Dict[str, Any]: url = "{}{{ endpoint.path }}".format( client.base_url @@ -61,7 +64,7 @@ def _get_kwargs( } -def _parse_response(*, client: {{ client_name }}, response: httpx.Response) -> Optional[{{ return_string }}]: +def _parse_response(*, client: "{{ client_name }}", response: httpx.Response) -> Optional[{{ return_string }}]: {% for response in endpoint.responses %} if response.status_code == HTTPStatus.{{ response.status_code.name }}: {% if parsed_responses %}{% import "property_templates/" + response.prop.template as prop_template %} @@ -81,7 +84,7 @@ def _parse_response(*, client: {{ client_name }}, response: httpx.Response) -> O return None -def _build_response(*, client: {{ client_name }}, response: httpx.Response) -> Response[{{ return_string }}]: +def _build_response(*, client: "{{ client_name }}", response: httpx.Response) -> Response[{{ return_string }}]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -92,11 +95,10 @@ def _build_response(*, client: {{ client_name }}, response: httpx.Response) -> R def sync_detailed( {{ arguments(endpoint) | indent(4) }} - client: Union[{{ client_name }}, Unset] = UNSET + client: "{{ client_name }}" ) -> Response[{{ return_string }}]: {{ docstring(endpoint, return_string) | indent(4) }} - client = client if not isinstance(client, Unset) else {{ client_name }}.instance() kwargs = _get_kwargs( {{ kwargs(endpoint) }} ) @@ -108,25 +110,22 @@ def sync_detailed( return _build_response(client=client, response=response) -{% if parsed_responses %} def sync( {{ arguments(endpoint) | indent(4) }} - client: Union[{{ client_name }}, Unset] = UNSET + client: "{{ client_name }}" ) -> Optional[{{ return_string }}]: {{ docstring(endpoint, return_string) | indent(4) }} return sync_detailed( {{ kwargs(endpoint) }} ).parsed -{% endif %} async def asyncio_detailed( {{ arguments(endpoint) | indent(4) }} - client: Union[{{ client_name }}, Unset] = UNSET + client: "{{ client_name }}" ) -> Response[{{ return_string }}]: {{ docstring(endpoint, return_string) | indent(4) }} - client = client if not isinstance(client, Unset) else {{ client_name }}.instance() kwargs = _get_kwargs( {{ kwargs(endpoint) }} ) @@ -138,14 +137,12 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -{% if parsed_responses %} async def asyncio( {{ arguments(endpoint) | indent(4) }} - client: Union[{{ client_name }}, Unset] = UNSET + client: "{{ client_name }}" ) -> Optional[{{ return_string }}]: {{ docstring(endpoint, return_string) | indent(4) }} return (await asyncio_detailed( {{ kwargs(endpoint) }} )).parsed -{% endif %} From df4618b576423a7078a9c8c680b837d101faa59e Mon Sep 17 00:00:00 2001 From: v1nvn Date: Fri, 28 Apr 2023 12:33:11 +0530 Subject: [PATCH 9/9] fix: error handling --- .../api/default/__init__.py | 18 +- .../api/default/get_common_parameters.py | 26 ++- .../api/default/post_common_parameters.py | 26 ++- .../api/location/__init__.py | 18 +- .../api/location/get_location_header_types.py | 24 +-- .../get_location_query_optionality.py | 26 ++- .../api/parameter_references/__init__.py | 10 +- .../get_parameter_references_path_param.py | 26 ++- .../api/parameters/__init__.py | 34 +-- ...lete_common_parameters_overriding_param.py | 28 ++- .../get_common_parameters_overriding_param.py | 26 +-- .../get_same_name_multiple_locations_param.py | 26 ++- .../parameters/multiple_path_parameters.py | 24 +-- .../api/responses/__init__.py | 10 +- ..._responses_unions_simple_before_complex.py | 21 +- .../my_test_api_client/api/tag1/__init__.py | 10 +- .../api/tag1/get_tag_with_number.py | 24 +-- .../my_test_api_client/api/tests/__init__.py | 194 +++++++++--------- .../api/tests/callback_test.py | 43 ++-- .../api/tests/defaults_tests_defaults_post.py | 43 ++-- .../api/tests/description_with_backslash.py | 24 +-- .../api/tests/get_basic_list_of_booleans.py | 21 +- .../api/tests/get_basic_list_of_floats.py | 21 +- .../api/tests/get_basic_list_of_integers.py | 21 +- .../api/tests/get_basic_list_of_strings.py | 21 +- .../api/tests/get_user_list.py | 41 ++-- .../api/tests/int_enum_tests_int_enum_post.py | 43 ++-- .../tests/json_body_tests_json_body_post.py | 43 ++-- .../no_response_tests_no_response_get.py | 24 +-- .../octet_stream_tests_octet_stream_get.py | 21 +- .../api/tests/post_form_data.py | 26 ++- .../api/tests/post_form_data_inline.py | 26 ++- .../api/tests/post_tests_json_body_string.py | 41 ++-- .../api/tests/test_inline_objects.py | 23 +-- ..._with_cookie_auth_token_with_cookie_get.py | 27 ++- ...d_content_tests_unsupported_content_get.py | 24 +-- .../tests/upload_file_tests_upload_post.py | 47 ++--- ...upload_multiple_files_tests_upload_post.py | 47 ++--- .../my_test_api_client/api/true_/__init__.py | 10 +- .../my_test_api_client/api/true_/false_.py | 24 +-- .../my_test_api_client/client.py | 6 +- .../my_test_api_client/docs/Tests.md | 16 +- .../my_test_api_client/errors.py | 10 +- .../golden-record/my_test_api_client/types.py | 2 +- openapi_python_client/parser/openapi.py | 5 +- openapi_python_client/parser/responses.py | 3 + openapi_python_client/templates/api.py.jinja | 21 -- .../templates/client.py.jinja | 6 +- .../templates/endpoint_init.py.jinja | 6 +- .../templates/endpoint_macros.py.jinja | 2 +- .../templates/endpoint_module.py.jinja | 21 +- .../templates/errors.py.jinja | 15 +- .../templates/types.py.jinja | 2 +- 53 files changed, 605 insertions(+), 742 deletions(-) delete mode 100644 openapi_python_client/templates/api.py.jinja diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/__init__.py index 4cb250f3f..26bf962e0 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/__init__.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Optional +from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from ...client import MyTestApiClient @@ -17,13 +17,13 @@ def get_common_parameters( self, *, common: Union[Unset, None, str] = UNSET, - ) -> Optional[Any]: + ) -> Any: """ Args: common (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -39,13 +39,13 @@ async def get_common_parameters_async( self, *, common: Union[Unset, None, str] = UNSET, - ) -> Optional[Any]: + ) -> Any: """ Args: common (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -61,13 +61,13 @@ def post_common_parameters( self, *, common: Union[Unset, None, str] = UNSET, - ) -> Optional[Any]: + ) -> Any: """ Args: common (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -83,13 +83,13 @@ async def post_common_parameters_async( self, *, common: Union[Unset, None, str] = UNSET, - ) -> Optional[Any]: + ) -> Any: """ Args: common (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py index 25a095c6d..d2e7a5981 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py @@ -1,12 +1,12 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Union import httpx if TYPE_CHECKING: from ...client import MyTestApiClient -from typing import Optional, Union +from typing import Union from ... import errors from ...types import UNSET, Response, Unset @@ -34,13 +34,11 @@ def _get_kwargs(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiCl } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = None + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -58,7 +56,7 @@ def sync_detailed(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApi common (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -78,13 +76,13 @@ def sync_detailed(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApi return _build_response(client=client, response=response) -def sync(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Optional[Any]: +def sync(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Any: """ Args: common (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -103,7 +101,7 @@ async def asyncio_detailed(*, common: Union[Unset, None, str] = UNSET, client: " common (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -121,13 +119,13 @@ async def asyncio_detailed(*, common: Union[Unset, None, str] = UNSET, client: " return _build_response(client=client, response=response) -async def asyncio(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Optional[Any]: +async def asyncio(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Any: """ Args: common (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py index c0107fd2e..f4a23e562 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py @@ -1,12 +1,12 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Union import httpx if TYPE_CHECKING: from ...client import MyTestApiClient -from typing import Optional, Union +from typing import Union from ... import errors from ...types import UNSET, Response, Unset @@ -34,13 +34,11 @@ def _get_kwargs(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiCl } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = None + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -58,7 +56,7 @@ def sync_detailed(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApi common (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -78,13 +76,13 @@ def sync_detailed(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApi return _build_response(client=client, response=response) -def sync(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Optional[Any]: +def sync(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Any: """ Args: common (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -103,7 +101,7 @@ async def asyncio_detailed(*, common: Union[Unset, None, str] = UNSET, client: " common (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -121,13 +119,13 @@ async def asyncio_detailed(*, common: Union[Unset, None, str] = UNSET, client: " return _build_response(client=client, response=response) -async def asyncio(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Optional[Any]: +async def asyncio(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Any: """ Args: common (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/__init__.py index 917a1483c..0ae83f7d5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/__init__.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Optional +from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from ...client import MyTestApiClient @@ -25,7 +25,7 @@ def get_location_query_optionality( null_required: Union[Unset, None, datetime.datetime] = UNSET, null_not_required: Union[Unset, None, datetime.datetime] = UNSET, not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, - ) -> Optional[Any]: + ) -> Any: """ Args: not_null_required (datetime.datetime): @@ -34,7 +34,7 @@ def get_location_query_optionality( not_null_not_required (Union[Unset, None, datetime.datetime]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -56,7 +56,7 @@ async def get_location_query_optionality_async( null_required: Union[Unset, None, datetime.datetime] = UNSET, null_not_required: Union[Unset, None, datetime.datetime] = UNSET, not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, - ) -> Optional[Any]: + ) -> Any: """ Args: not_null_required (datetime.datetime): @@ -65,7 +65,7 @@ async def get_location_query_optionality_async( not_null_not_required (Union[Unset, None, datetime.datetime]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -89,7 +89,7 @@ def get_location_header_types( integer_header: Union[Unset, int] = UNSET, int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, - ) -> Optional[Any]: + ) -> Any: """ Args: boolean_header (Union[Unset, bool]): @@ -100,7 +100,7 @@ def get_location_header_types( string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -126,7 +126,7 @@ async def get_location_header_types_async( integer_header: Union[Unset, int] = UNSET, int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, - ) -> Optional[Any]: + ) -> Any: """ Args: boolean_header (Union[Unset, bool]): @@ -137,7 +137,7 @@ async def get_location_header_types_async( string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py index c855556c8..b83c71db1 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Union import httpx @@ -57,13 +57,11 @@ def _get_kwargs( } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = None + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -95,7 +93,7 @@ def sync_detailed( string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -129,7 +127,7 @@ def sync( int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, client: "MyTestApiClient", -) -> Optional[Any]: +) -> Any: """ Args: boolean_header (Union[Unset, bool]): @@ -140,7 +138,7 @@ def sync( string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -178,7 +176,7 @@ async def asyncio_detailed( string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -210,7 +208,7 @@ async def asyncio( int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, client: "MyTestApiClient", -) -> Optional[Any]: +) -> Any: """ Args: boolean_header (Union[Unset, bool]): @@ -221,7 +219,7 @@ async def asyncio( string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py index 13b21cde8..d9447ac9f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Union import httpx @@ -7,7 +7,7 @@ from ...client import MyTestApiClient import datetime -from typing import Optional, Union +from typing import Union from ... import errors from ...types import UNSET, Response, Unset @@ -62,13 +62,11 @@ def _get_kwargs( } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = None + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -96,7 +94,7 @@ def sync_detailed( not_null_not_required (Union[Unset, None, datetime.datetime]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -126,7 +124,7 @@ def sync( null_not_required: Union[Unset, None, datetime.datetime] = UNSET, not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, client: "MyTestApiClient", -) -> Optional[Any]: +) -> Any: """ Args: not_null_required (datetime.datetime): @@ -135,7 +133,7 @@ def sync( not_null_not_required (Union[Unset, None, datetime.datetime]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -167,7 +165,7 @@ async def asyncio_detailed( not_null_not_required (Union[Unset, None, datetime.datetime]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -195,7 +193,7 @@ async def asyncio( null_not_required: Union[Unset, None, datetime.datetime] = UNSET, not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, client: "MyTestApiClient", -) -> Optional[Any]: +) -> Any: """ Args: not_null_required (datetime.datetime): @@ -204,7 +202,7 @@ async def asyncio( not_null_not_required (Union[Unset, None, datetime.datetime]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/__init__.py index a11e33354..138cf3f1b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/__init__.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Optional +from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from ...client import MyTestApiClient @@ -21,7 +21,7 @@ def get_parameter_references_path_param( integer_param: Union[Unset, None, int] = 0, header_param: Union[Unset, str] = UNSET, cookie_param: Union[Unset, str] = UNSET, - ) -> Optional[Any]: + ) -> Any: """Test different types of parameter references Args: @@ -32,7 +32,7 @@ def get_parameter_references_path_param( cookie_param (Union[Unset, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -56,7 +56,7 @@ async def get_parameter_references_path_param_async( integer_param: Union[Unset, None, int] = 0, header_param: Union[Unset, str] = UNSET, cookie_param: Union[Unset, str] = UNSET, - ) -> Optional[Any]: + ) -> Any: """Test different types of parameter references Args: @@ -67,7 +67,7 @@ async def get_parameter_references_path_param_async( cookie_param (Union[Unset, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py index 97de1a324..b19f9a3c5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py @@ -1,12 +1,12 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Union import httpx if TYPE_CHECKING: from ...client import MyTestApiClient -from typing import Optional, Union +from typing import Union from ... import errors from ...types import UNSET, Response, Unset @@ -50,13 +50,11 @@ def _get_kwargs( } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = None + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -87,7 +85,7 @@ def sync_detailed( cookie_param (Union[Unset, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -119,7 +117,7 @@ def sync( header_param: Union[Unset, str] = UNSET, cookie_param: Union[Unset, str] = UNSET, client: "MyTestApiClient", -) -> Optional[Any]: +) -> Any: """Test different types of parameter references Args: @@ -130,7 +128,7 @@ def sync( cookie_param (Union[Unset, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -166,7 +164,7 @@ async def asyncio_detailed( cookie_param (Union[Unset, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -196,7 +194,7 @@ async def asyncio( header_param: Union[Unset, str] = UNSET, cookie_param: Union[Unset, str] = UNSET, client: "MyTestApiClient", -) -> Optional[Any]: +) -> Any: """Test different types of parameter references Args: @@ -207,7 +205,7 @@ async def asyncio( cookie_param (Union[Unset, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/__init__.py index d5f335cb9..d87482e1a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/__init__.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Optional +from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from ...client import MyTestApiClient @@ -23,7 +23,7 @@ def get_common_parameters_overriding_param( param_path: str, *, param_query: str = "overridden_in_GET", - ) -> Optional[Any]: + ) -> Any: """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code Args: @@ -32,7 +32,7 @@ def get_common_parameters_overriding_param( 'overridden_in_GET'. Example: an example string. Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -50,7 +50,7 @@ async def get_common_parameters_overriding_param_async( param_path: str, *, param_query: str = "overridden_in_GET", - ) -> Optional[Any]: + ) -> Any: """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code Args: @@ -59,7 +59,7 @@ async def get_common_parameters_overriding_param_async( 'overridden_in_GET'. Example: an example string. Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -77,14 +77,14 @@ def delete_common_parameters_overriding_param( param_path: str, *, param_query: Union[Unset, None, str] = UNSET, - ) -> Optional[Any]: + ) -> Any: """ Args: param_path (str): param_query (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -102,14 +102,14 @@ async def delete_common_parameters_overriding_param_async( param_path: str, *, param_query: Union[Unset, None, str] = UNSET, - ) -> Optional[Any]: + ) -> Any: """ Args: param_path (str): param_query (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -129,7 +129,7 @@ def get_same_name_multiple_locations_param( param_query: Union[Unset, None, str] = UNSET, param_header: Union[Unset, str] = UNSET, param_cookie: Union[Unset, str] = UNSET, - ) -> Optional[Any]: + ) -> Any: """ Args: param_path (str): @@ -138,7 +138,7 @@ def get_same_name_multiple_locations_param( param_cookie (Union[Unset, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -160,7 +160,7 @@ async def get_same_name_multiple_locations_param_async( param_query: Union[Unset, None, str] = UNSET, param_header: Union[Unset, str] = UNSET, param_cookie: Union[Unset, str] = UNSET, - ) -> Optional[Any]: + ) -> Any: """ Args: param_path (str): @@ -169,7 +169,7 @@ async def get_same_name_multiple_locations_param_async( param_cookie (Union[Unset, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -190,7 +190,7 @@ def multiple_path_parameters( param2: int, param1: str, param3: int, - ) -> Optional[Any]: + ) -> Any: """ Args: param4 (str): @@ -199,7 +199,7 @@ def multiple_path_parameters( param3 (int): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -220,7 +220,7 @@ async def multiple_path_parameters_async( param2: int, param1: str, param3: int, - ) -> Optional[Any]: + ) -> Any: """ Args: param4 (str): @@ -229,7 +229,7 @@ async def multiple_path_parameters_async( param3 (int): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py index acc675adf..d93d45561 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py @@ -1,12 +1,12 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Union import httpx if TYPE_CHECKING: from ...client import MyTestApiClient -from typing import Optional, Union +from typing import Union from ... import errors from ...types import UNSET, Response, Unset @@ -36,13 +36,11 @@ def _get_kwargs( } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = None + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -63,7 +61,7 @@ def sync_detailed( param_query (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -84,14 +82,14 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync(param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Optional[Any]: +def sync(param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Any: """ Args: param_path (str): param_query (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -114,7 +112,7 @@ async def asyncio_detailed( param_query (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -133,16 +131,14 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: "MyTestApiClient" -) -> Optional[Any]: +async def asyncio(param_path: str, *, param_query: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Any: """ Args: param_path (str): param_query (Union[Unset, None, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py index 49aa4eed4..087114634 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict import httpx @@ -34,13 +34,11 @@ def _get_kwargs( } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = None + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -63,7 +61,7 @@ def sync_detailed( 'overridden_in_GET'. Example: an example string. Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -84,7 +82,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync(param_path: str, *, param_query: str = "overridden_in_GET", client: "MyTestApiClient") -> Optional[Any]: +def sync(param_path: str, *, param_query: str = "overridden_in_GET", client: "MyTestApiClient") -> Any: """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code Args: @@ -93,7 +91,7 @@ def sync(param_path: str, *, param_query: str = "overridden_in_GET", client: "My 'overridden_in_GET'. Example: an example string. Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -118,7 +116,7 @@ async def asyncio_detailed( 'overridden_in_GET'. Example: an example string. Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -137,9 +135,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - param_path: str, *, param_query: str = "overridden_in_GET", client: "MyTestApiClient" -) -> Optional[Any]: +async def asyncio(param_path: str, *, param_query: str = "overridden_in_GET", client: "MyTestApiClient") -> Any: """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code Args: @@ -148,7 +144,7 @@ async def asyncio( 'overridden_in_GET'. Example: an example string. Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py index da66aa023..220819afe 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py @@ -1,12 +1,12 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Union import httpx if TYPE_CHECKING: from ...client import MyTestApiClient -from typing import Optional, Union +from typing import Union from ... import errors from ...types import UNSET, Response, Unset @@ -47,13 +47,11 @@ def _get_kwargs( } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = None + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -81,7 +79,7 @@ def sync_detailed( param_cookie (Union[Unset, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -111,7 +109,7 @@ def sync( param_header: Union[Unset, str] = UNSET, param_cookie: Union[Unset, str] = UNSET, client: "MyTestApiClient", -) -> Optional[Any]: +) -> Any: """ Args: param_path (str): @@ -120,7 +118,7 @@ def sync( param_cookie (Union[Unset, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -152,7 +150,7 @@ async def asyncio_detailed( param_cookie (Union[Unset, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -180,7 +178,7 @@ async def asyncio( param_header: Union[Unset, str] = UNSET, param_cookie: Union[Unset, str] = UNSET, client: "MyTestApiClient", -) -> Optional[Any]: +) -> Any: """ Args: param_path (str): @@ -189,7 +187,7 @@ async def asyncio( param_cookie (Union[Unset, str]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py index ff27d19e7..bb1f59421 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict import httpx @@ -28,13 +28,11 @@ def _get_kwargs(param4: str, param2: int, param1: str, param3: int, client: "MyT } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = None + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -55,7 +53,7 @@ def sync_detailed(param4: str, param2: int, param1: str, param3: int, client: "M param3 (int): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -78,7 +76,7 @@ def sync_detailed(param4: str, param2: int, param1: str, param3: int, client: "M return _build_response(client=client, response=response) -def sync(param4: str, param2: int, param1: str, param3: int, client: "MyTestApiClient") -> Optional[Any]: +def sync(param4: str, param2: int, param1: str, param3: int, client: "MyTestApiClient") -> Any: """ Args: param4 (str): @@ -87,7 +85,7 @@ def sync(param4: str, param2: int, param1: str, param3: int, client: "MyTestApiC param3 (int): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -114,7 +112,7 @@ async def asyncio_detailed( param3 (int): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -135,7 +133,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio(param4: str, param2: int, param1: str, param3: int, client: "MyTestApiClient") -> Optional[Any]: +async def asyncio(param4: str, param2: int, param1: str, param3: int, client: "MyTestApiClient") -> Any: """ Args: param4 (str): @@ -144,7 +142,7 @@ async def asyncio(param4: str, param2: int, param1: str, param3: int, client: "M param3 (int): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/__init__.py index 472097eda..f128081a4 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/__init__.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Optional +from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from ...client import MyTestApiClient @@ -17,11 +17,11 @@ def __init__(self, client: "MyTestApiClient"): def post_responses_unions_simple_before_complex( self, - ) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: + ) -> PostResponsesUnionsSimpleBeforeComplexResponse200: """Regression test for #603 Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -34,11 +34,11 @@ def post_responses_unions_simple_before_complex( async def post_responses_unions_simple_before_complex_async( self, - ) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: + ) -> PostResponsesUnionsSimpleBeforeComplexResponse200: """Regression test for #603 Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py index 813311a0b..52a41d1f6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict import httpx @@ -33,15 +33,12 @@ def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: def _parse_response( *, client: "MyTestApiClient", response: httpx.Response -) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: +) -> PostResponsesUnionsSimpleBeforeComplexResponse200: if response.status_code == HTTPStatus.OK: response_200 = PostResponsesUnionsSimpleBeforeComplexResponse200.from_dict(response.json()) return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response( @@ -59,7 +56,7 @@ def sync_detailed(client: "MyTestApiClient") -> Response[PostResponsesUnionsSimp """Regression test for #603 Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -78,11 +75,11 @@ def sync_detailed(client: "MyTestApiClient") -> Response[PostResponsesUnionsSimp return _build_response(client=client, response=response) -def sync(client: "MyTestApiClient") -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: +def sync(client: "MyTestApiClient") -> PostResponsesUnionsSimpleBeforeComplexResponse200: """Regression test for #603 Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -98,7 +95,7 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[PostResponsesU """Regression test for #603 Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -115,11 +112,11 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[PostResponsesU return _build_response(client=client, response=response) -async def asyncio(client: "MyTestApiClient") -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: +async def asyncio(client: "MyTestApiClient") -> PostResponsesUnionsSimpleBeforeComplexResponse200: """Regression test for #603 Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/__init__.py index cab48e2fc..ae4d649d2 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/__init__.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Optional +from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from ...client import MyTestApiClient @@ -12,10 +12,10 @@ def __init__(self, client: "MyTestApiClient"): def get_tag_with_number( self, - ) -> Optional[Any]: + ) -> Any: """ Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -28,10 +28,10 @@ def get_tag_with_number( async def get_tag_with_number_async( self, - ) -> Optional[Any]: + ) -> Any: """ Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py index 9163bcc6b..a1106d25c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict import httpx @@ -26,13 +26,11 @@ def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = None + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -47,7 +45,7 @@ def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> R def sync_detailed(client: "MyTestApiClient") -> Response[Any]: """ Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -66,10 +64,10 @@ def sync_detailed(client: "MyTestApiClient") -> Response[Any]: return _build_response(client=client, response=response) -def sync(client: "MyTestApiClient") -> Optional[Any]: +def sync(client: "MyTestApiClient") -> Any: """ Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -84,7 +82,7 @@ def sync(client: "MyTestApiClient") -> Optional[Any]: async def asyncio_detailed(client: "MyTestApiClient") -> Response[Any]: """ Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -101,10 +99,10 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[Any]: return _build_response(client=client, response=response) -async def asyncio(client: "MyTestApiClient") -> Optional[Any]: +async def asyncio(client: "MyTestApiClient") -> Any: """ Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/__init__.py index 2292b1b2e..6645eb06a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/__init__.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Optional +from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from ...client import MyTestApiClient @@ -56,7 +56,7 @@ def get_user_list( an_enum_value_with_null: List[Optional[AnEnumWithNull]], an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], - ) -> Optional[Union[HTTPValidationError, List["AModel"]]]: + ) -> List["AModel"]: """Get List Get a list of things @@ -68,11 +68,11 @@ def get_user_list( some_date (Union[datetime.date, datetime.datetime]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, List['AModel']]] + Response[List['AModel']] """ return get_user_list.sync( @@ -90,7 +90,7 @@ async def get_user_list_async( an_enum_value_with_null: List[Optional[AnEnumWithNull]], an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], - ) -> Optional[Union[HTTPValidationError, List["AModel"]]]: + ) -> List["AModel"]: """Get List Get a list of things @@ -102,11 +102,11 @@ async def get_user_list_async( some_date (Union[datetime.date, datetime.datetime]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, List['AModel']]] + Response[List['AModel']] """ return await get_user_list.asyncio( @@ -119,13 +119,13 @@ async def get_user_list_async( def get_basic_list_of_strings( self, - ) -> Optional[List[str]]: + ) -> List[str]: """Get Basic List Of Strings Get a list of strings Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -138,13 +138,13 @@ def get_basic_list_of_strings( async def get_basic_list_of_strings_async( self, - ) -> Optional[List[str]]: + ) -> List[str]: """Get Basic List Of Strings Get a list of strings Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -157,13 +157,13 @@ async def get_basic_list_of_strings_async( def get_basic_list_of_integers( self, - ) -> Optional[List[int]]: + ) -> List[int]: """Get Basic List Of Integers Get a list of integers Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -176,13 +176,13 @@ def get_basic_list_of_integers( async def get_basic_list_of_integers_async( self, - ) -> Optional[List[int]]: + ) -> List[int]: """Get Basic List Of Integers Get a list of integers Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -195,13 +195,13 @@ async def get_basic_list_of_integers_async( def get_basic_list_of_floats( self, - ) -> Optional[List[float]]: + ) -> List[float]: """Get Basic List Of Floats Get a list of floats Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -214,13 +214,13 @@ def get_basic_list_of_floats( async def get_basic_list_of_floats_async( self, - ) -> Optional[List[float]]: + ) -> List[float]: """Get Basic List Of Floats Get a list of floats Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -233,13 +233,13 @@ async def get_basic_list_of_floats_async( def get_basic_list_of_booleans( self, - ) -> Optional[List[bool]]: + ) -> List[bool]: """Get Basic List Of Booleans Get a list of booleans Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -252,13 +252,13 @@ def get_basic_list_of_booleans( async def get_basic_list_of_booleans_async( self, - ) -> Optional[List[bool]]: + ) -> List[bool]: """Get Basic List Of Booleans Get a list of booleans Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -273,13 +273,13 @@ def post_form_data( self, *, form_data: AFormData, - ) -> Optional[Any]: + ) -> Any: """Post form data Post form data Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -295,13 +295,13 @@ async def post_form_data_async( self, *, form_data: AFormData, - ) -> Optional[Any]: + ) -> Any: """Post form data Post form data Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -317,13 +317,13 @@ def post_form_data_inline( self, *, form_data: PostFormDataInlineData, - ) -> Optional[Any]: + ) -> Any: """Post form data (inline schema) Post form data (inline schema) Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -339,13 +339,13 @@ async def post_form_data_inline_async( self, *, form_data: PostFormDataInlineData, - ) -> Optional[Any]: + ) -> Any: """Post form data (inline schema) Post form data (inline schema) Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -361,7 +361,7 @@ def upload_file_tests_upload_post( self, *, multipart_data: BodyUploadFileTestsUploadPost, - ) -> Optional[Union[Any, HTTPValidationError]]: + ) -> Any: """Upload File Upload a file @@ -370,11 +370,11 @@ def upload_file_tests_upload_post( multipart_data (BodyUploadFileTestsUploadPost): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return upload_file_tests_upload_post.sync( @@ -386,7 +386,7 @@ async def upload_file_tests_upload_post_async( self, *, multipart_data: BodyUploadFileTestsUploadPost, - ) -> Optional[Union[Any, HTTPValidationError]]: + ) -> Any: """Upload File Upload a file @@ -395,11 +395,11 @@ async def upload_file_tests_upload_post_async( multipart_data (BodyUploadFileTestsUploadPost): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return await upload_file_tests_upload_post.asyncio( @@ -411,7 +411,7 @@ def upload_multiple_files_tests_upload_post( self, *, multipart_data: List[File], - ) -> Optional[Union[Any, HTTPValidationError]]: + ) -> Any: """Upload multiple files Upload several files in the same request @@ -420,11 +420,11 @@ def upload_multiple_files_tests_upload_post( multipart_data (List[File]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return upload_multiple_files_tests_upload_post.sync( @@ -436,7 +436,7 @@ async def upload_multiple_files_tests_upload_post_async( self, *, multipart_data: List[File], - ) -> Optional[Union[Any, HTTPValidationError]]: + ) -> Any: """Upload multiple files Upload several files in the same request @@ -445,11 +445,11 @@ async def upload_multiple_files_tests_upload_post_async( multipart_data (List[File]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return await upload_multiple_files_tests_upload_post.asyncio( @@ -461,7 +461,7 @@ def json_body_tests_json_body_post( self, *, json_body: AModel, - ) -> Optional[Union[Any, HTTPValidationError]]: + ) -> Any: """Json Body Try sending a JSON body @@ -470,11 +470,11 @@ def json_body_tests_json_body_post( json_body (AModel): A Model for testing all the ways custom objects can be used Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return json_body_tests_json_body_post.sync( @@ -486,7 +486,7 @@ async def json_body_tests_json_body_post_async( self, *, json_body: AModel, - ) -> Optional[Union[Any, HTTPValidationError]]: + ) -> Any: """Json Body Try sending a JSON body @@ -495,11 +495,11 @@ async def json_body_tests_json_body_post_async( json_body (AModel): A Model for testing all the ways custom objects can be used Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return await json_body_tests_json_body_post.asyncio( @@ -511,18 +511,18 @@ def post_tests_json_body_string( self, *, json_body: str, - ) -> Optional[Union[HTTPValidationError, str]]: + ) -> str: """Json Body Which is String Args: json_body (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, str]] + Response[str] """ return post_tests_json_body_string.sync( @@ -534,18 +534,18 @@ async def post_tests_json_body_string_async( self, *, json_body: str, - ) -> Optional[Union[HTTPValidationError, str]]: + ) -> str: """Json Body Which is String Args: json_body (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, str]] + Response[str] """ return await post_tests_json_body_string.asyncio( @@ -567,7 +567,7 @@ def defaults_tests_defaults_post( enum_prop: AnEnum, model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", - ) -> Optional[Union[Any, HTTPValidationError]]: + ) -> Any: """Defaults Args: @@ -584,11 +584,11 @@ def defaults_tests_defaults_post( required_model_prop (ModelWithUnionProperty): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return defaults_tests_defaults_post.sync( @@ -620,7 +620,7 @@ async def defaults_tests_defaults_post_async( enum_prop: AnEnum, model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", - ) -> Optional[Union[Any, HTTPValidationError]]: + ) -> Any: """Defaults Args: @@ -637,11 +637,11 @@ async def defaults_tests_defaults_post_async( required_model_prop (ModelWithUnionProperty): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return await defaults_tests_defaults_post.asyncio( @@ -661,11 +661,11 @@ async def defaults_tests_defaults_post_async( def octet_stream_tests_octet_stream_get( self, - ) -> Optional[File]: + ) -> File: """Octet Stream Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -678,11 +678,11 @@ def octet_stream_tests_octet_stream_get( async def octet_stream_tests_octet_stream_get_async( self, - ) -> Optional[File]: + ) -> File: """Octet Stream Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -695,11 +695,11 @@ async def octet_stream_tests_octet_stream_get_async( def no_response_tests_no_response_get( self, - ) -> Optional[Any]: + ) -> Any: """No Response Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -712,11 +712,11 @@ def no_response_tests_no_response_get( async def no_response_tests_no_response_get_async( self, - ) -> Optional[Any]: + ) -> Any: """No Response Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -729,11 +729,11 @@ async def no_response_tests_no_response_get_async( def unsupported_content_tests_unsupported_content_get( self, - ) -> Optional[Any]: + ) -> Any: """Unsupported Content Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -746,11 +746,11 @@ def unsupported_content_tests_unsupported_content_get( async def unsupported_content_tests_unsupported_content_get_async( self, - ) -> Optional[Any]: + ) -> Any: """Unsupported Content Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -765,18 +765,18 @@ def int_enum_tests_int_enum_post( self, *, int_enum: AnIntEnum, - ) -> Optional[Union[Any, HTTPValidationError]]: + ) -> Any: """Int Enum Args: int_enum (AnIntEnum): An enumeration. Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return int_enum_tests_int_enum_post.sync( @@ -788,18 +788,18 @@ async def int_enum_tests_int_enum_post_async( self, *, int_enum: AnIntEnum, - ) -> Optional[Union[Any, HTTPValidationError]]: + ) -> Any: """Int Enum Args: int_enum (AnIntEnum): An enumeration. Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return await int_enum_tests_int_enum_post.asyncio( @@ -811,14 +811,14 @@ def test_inline_objects( self, *, json_body: TestInlineObjectsJsonBody, - ) -> Optional[TestInlineObjectsResponse200]: + ) -> TestInlineObjectsResponse200: """Test Inline Objects Args: json_body (TestInlineObjectsJsonBody): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -834,14 +834,14 @@ async def test_inline_objects_async( self, *, json_body: TestInlineObjectsJsonBody, - ) -> Optional[TestInlineObjectsResponse200]: + ) -> TestInlineObjectsResponse200: """Test Inline Objects Args: json_body (TestInlineObjectsJsonBody): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -857,7 +857,7 @@ def token_with_cookie_auth_token_with_cookie_get( self, *, my_token: str, - ) -> Optional[Any]: + ) -> Any: """TOKEN_WITH_COOKIE Test optional cookie parameters @@ -866,7 +866,7 @@ def token_with_cookie_auth_token_with_cookie_get( my_token (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -882,7 +882,7 @@ async def token_with_cookie_auth_token_with_cookie_get_async( self, *, my_token: str, - ) -> Optional[Any]: + ) -> Any: """TOKEN_WITH_COOKIE Test optional cookie parameters @@ -891,7 +891,7 @@ async def token_with_cookie_auth_token_with_cookie_get_async( my_token (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -907,7 +907,7 @@ def callback_test( self, *, json_body: AModel, - ) -> Optional[Union[Any, HTTPValidationError]]: + ) -> Any: """Path with callback Try sending a request related to a callback @@ -916,11 +916,11 @@ def callback_test( json_body (AModel): A Model for testing all the ways custom objects can be used Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return callback_test.sync( @@ -932,7 +932,7 @@ async def callback_test_async( self, *, json_body: AModel, - ) -> Optional[Union[Any, HTTPValidationError]]: + ) -> Any: """Path with callback Try sending a request related to a callback @@ -941,11 +941,11 @@ async def callback_test_async( json_body (AModel): A Model for testing all the ways custom objects can be used Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return await callback_test.asyncio( @@ -955,13 +955,13 @@ async def callback_test_async( def description_with_backslash( self, - ) -> Optional[Any]: + ) -> Any: r""" Test description with \ Test description with \ Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -974,13 +974,13 @@ def description_with_backslash( async def description_with_backslash_async( self, - ) -> Optional[Any]: + ) -> Any: r""" Test description with \ Test description with \ Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py index f1bd23aa2..30c13dfa3 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, cast import httpx @@ -33,25 +33,18 @@ def _get_kwargs(*, json_body: AModel, client: "MyTestApiClient") -> Dict[str, An } -def _parse_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: response_422 = HTTPValidationError.from_dict(response.json()) - return response_422 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content, response_422) + raise errors.UnexpectedStatus(response.status_code, response.content) -def _build_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -60,7 +53,7 @@ def _build_response( ) -def sync_detailed(*, json_body: AModel, client: "MyTestApiClient") -> Response[Union[Any, HTTPValidationError]]: +def sync_detailed(*, json_body: AModel, client: "MyTestApiClient") -> Response[Any]: """Path with callback Try sending a request related to a callback @@ -69,11 +62,11 @@ def sync_detailed(*, json_body: AModel, client: "MyTestApiClient") -> Response[U json_body (AModel): A Model for testing all the ways custom objects can be used Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ kwargs = _get_kwargs( @@ -89,7 +82,7 @@ def sync_detailed(*, json_body: AModel, client: "MyTestApiClient") -> Response[U return _build_response(client=client, response=response) -def sync(*, json_body: AModel, client: "MyTestApiClient") -> Optional[Union[Any, HTTPValidationError]]: +def sync(*, json_body: AModel, client: "MyTestApiClient") -> Any: """Path with callback Try sending a request related to a callback @@ -98,11 +91,11 @@ def sync(*, json_body: AModel, client: "MyTestApiClient") -> Optional[Union[Any, json_body (AModel): A Model for testing all the ways custom objects can be used Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return sync_detailed( @@ -111,9 +104,7 @@ def sync(*, json_body: AModel, client: "MyTestApiClient") -> Optional[Union[Any, ).parsed -async def asyncio_detailed( - *, json_body: AModel, client: "MyTestApiClient" -) -> Response[Union[Any, HTTPValidationError]]: +async def asyncio_detailed(*, json_body: AModel, client: "MyTestApiClient") -> Response[Any]: """Path with callback Try sending a request related to a callback @@ -122,11 +113,11 @@ async def asyncio_detailed( json_body (AModel): A Model for testing all the ways custom objects can be used Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ kwargs = _get_kwargs( @@ -140,7 +131,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio(*, json_body: AModel, client: "MyTestApiClient") -> Optional[Union[Any, HTTPValidationError]]: +async def asyncio(*, json_body: AModel, client: "MyTestApiClient") -> Any: """Path with callback Try sending a request related to a callback @@ -149,11 +140,11 @@ async def asyncio(*, json_body: AModel, client: "MyTestApiClient") -> Optional[U json_body (AModel): A Model for testing all the ways custom objects can be used Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py index 99af81bfd..e8f8c37d2 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, List, Union, cast import httpx @@ -7,7 +7,7 @@ from ...client import MyTestApiClient import datetime -from typing import Dict, List, Optional, Union, cast +from typing import Dict, List, Union, cast from dateutil.parser import isoparse @@ -105,25 +105,18 @@ def _get_kwargs( } -def _parse_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: response_422 = HTTPValidationError.from_dict(response.json()) - return response_422 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content, response_422) + raise errors.UnexpectedStatus(response.status_code, response.content) -def _build_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -146,7 +139,7 @@ def sync_detailed( model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", client: "MyTestApiClient", -) -> Response[Union[Any, HTTPValidationError]]: +) -> Response[Any]: """Defaults Args: @@ -163,11 +156,11 @@ def sync_detailed( required_model_prop (ModelWithUnionProperty): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ kwargs = _get_kwargs( @@ -207,7 +200,7 @@ def sync( model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", client: "MyTestApiClient", -) -> Optional[Union[Any, HTTPValidationError]]: +) -> Any: """Defaults Args: @@ -224,11 +217,11 @@ def sync( required_model_prop (ModelWithUnionProperty): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return sync_detailed( @@ -261,7 +254,7 @@ async def asyncio_detailed( model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", client: "MyTestApiClient", -) -> Response[Union[Any, HTTPValidationError]]: +) -> Response[Any]: """Defaults Args: @@ -278,11 +271,11 @@ async def asyncio_detailed( required_model_prop (ModelWithUnionProperty): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ kwargs = _get_kwargs( @@ -320,7 +313,7 @@ async def asyncio( model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", client: "MyTestApiClient", -) -> Optional[Union[Any, HTTPValidationError]]: +) -> Any: """Defaults Args: @@ -337,11 +330,11 @@ async def asyncio( required_model_prop (ModelWithUnionProperty): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py index 002402fc6..b11d9e940 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict import httpx @@ -26,13 +26,11 @@ def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = None + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -50,7 +48,7 @@ def sync_detailed(client: "MyTestApiClient") -> Response[Any]: Test description with \ Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -69,13 +67,13 @@ def sync_detailed(client: "MyTestApiClient") -> Response[Any]: return _build_response(client=client, response=response) -def sync(client: "MyTestApiClient") -> Optional[Any]: +def sync(client: "MyTestApiClient") -> Any: r""" Test description with \ Test description with \ Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -93,7 +91,7 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[Any]: Test description with \ Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -110,13 +108,13 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[Any]: return _build_response(client=client, response=response) -async def asyncio(client: "MyTestApiClient") -> Optional[Any]: +async def asyncio(client: "MyTestApiClient") -> Any: r""" Test description with \ Test description with \ Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py index ce0726bc2..37e1f9bd2 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast +from typing import TYPE_CHECKING, Any, Dict, List, cast import httpx @@ -28,15 +28,12 @@ def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[List[bool]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> List[bool]: if response.status_code == HTTPStatus.OK: response_200 = cast(List[bool], response.json()) return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[List[bool]]: @@ -54,7 +51,7 @@ def sync_detailed(client: "MyTestApiClient") -> Response[List[bool]]: Get a list of booleans Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -73,13 +70,13 @@ def sync_detailed(client: "MyTestApiClient") -> Response[List[bool]]: return _build_response(client=client, response=response) -def sync(client: "MyTestApiClient") -> Optional[List[bool]]: +def sync(client: "MyTestApiClient") -> List[bool]: """Get Basic List Of Booleans Get a list of booleans Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -97,7 +94,7 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[List[bool]]: Get a list of booleans Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -114,13 +111,13 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[List[bool]]: return _build_response(client=client, response=response) -async def asyncio(client: "MyTestApiClient") -> Optional[List[bool]]: +async def asyncio(client: "MyTestApiClient") -> List[bool]: """Get Basic List Of Booleans Get a list of booleans Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py index 897f674fb..667c23285 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast +from typing import TYPE_CHECKING, Any, Dict, List, cast import httpx @@ -28,15 +28,12 @@ def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[List[float]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> List[float]: if response.status_code == HTTPStatus.OK: response_200 = cast(List[float], response.json()) return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[List[float]]: @@ -54,7 +51,7 @@ def sync_detailed(client: "MyTestApiClient") -> Response[List[float]]: Get a list of floats Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -73,13 +70,13 @@ def sync_detailed(client: "MyTestApiClient") -> Response[List[float]]: return _build_response(client=client, response=response) -def sync(client: "MyTestApiClient") -> Optional[List[float]]: +def sync(client: "MyTestApiClient") -> List[float]: """Get Basic List Of Floats Get a list of floats Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -97,7 +94,7 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[List[float]]: Get a list of floats Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -114,13 +111,13 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[List[float]]: return _build_response(client=client, response=response) -async def asyncio(client: "MyTestApiClient") -> Optional[List[float]]: +async def asyncio(client: "MyTestApiClient") -> List[float]: """Get Basic List Of Floats Get a list of floats Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py index 86146196b..40774c965 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast +from typing import TYPE_CHECKING, Any, Dict, List, cast import httpx @@ -28,15 +28,12 @@ def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[List[int]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> List[int]: if response.status_code == HTTPStatus.OK: response_200 = cast(List[int], response.json()) return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[List[int]]: @@ -54,7 +51,7 @@ def sync_detailed(client: "MyTestApiClient") -> Response[List[int]]: Get a list of integers Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -73,13 +70,13 @@ def sync_detailed(client: "MyTestApiClient") -> Response[List[int]]: return _build_response(client=client, response=response) -def sync(client: "MyTestApiClient") -> Optional[List[int]]: +def sync(client: "MyTestApiClient") -> List[int]: """Get Basic List Of Integers Get a list of integers Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -97,7 +94,7 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[List[int]]: Get a list of integers Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -114,13 +111,13 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[List[int]]: return _build_response(client=client, response=response) -async def asyncio(client: "MyTestApiClient") -> Optional[List[int]]: +async def asyncio(client: "MyTestApiClient") -> List[int]: """Get Basic List Of Integers Get a list of integers Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py index 0589fc529..2150b5271 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast +from typing import TYPE_CHECKING, Any, Dict, List, cast import httpx @@ -28,15 +28,12 @@ def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[List[str]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> List[str]: if response.status_code == HTTPStatus.OK: response_200 = cast(List[str], response.json()) return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[List[str]]: @@ -54,7 +51,7 @@ def sync_detailed(client: "MyTestApiClient") -> Response[List[str]]: Get a list of strings Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -73,13 +70,13 @@ def sync_detailed(client: "MyTestApiClient") -> Response[List[str]]: return _build_response(client=client, response=response) -def sync(client: "MyTestApiClient") -> Optional[List[str]]: +def sync(client: "MyTestApiClient") -> List[str]: """Get Basic List Of Strings Get a list of strings Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -97,7 +94,7 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[List[str]]: Get a list of strings Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -114,13 +111,13 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[List[str]]: return _build_response(client=client, response=response) -async def asyncio(client: "MyTestApiClient") -> Optional[List[str]]: +async def asyncio(client: "MyTestApiClient") -> List[str]: """Get Basic List Of Strings Get a list of strings Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py index 11bb58b58..57a3064d6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py @@ -75,9 +75,7 @@ def _get_kwargs( } -def _parse_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Optional[Union[HTTPValidationError, List["AModel"]]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> List["AModel"]: if response.status_code == HTTPStatus.OK: response_200 = [] _response_200 = response.json() @@ -90,20 +88,15 @@ def _parse_response( if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: response_422 = HTTPValidationError.from_dict(response.json()) - return response_422 + raise errors.UnexpectedStatus(response.status_code, response.content, response_422) if response.status_code == HTTPStatus.LOCKED: response_423 = HTTPValidationError.from_dict(response.json()) - return response_423 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content, response_423) + raise errors.UnexpectedStatus(response.status_code, response.content) -def _build_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Response[Union[HTTPValidationError, List["AModel"]]]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[List["AModel"]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -119,7 +112,7 @@ def sync_detailed( an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], client: "MyTestApiClient", -) -> Response[Union[HTTPValidationError, List["AModel"]]]: +) -> Response[List["AModel"]]: """Get List Get a list of things @@ -131,11 +124,11 @@ def sync_detailed( some_date (Union[datetime.date, datetime.datetime]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, List['AModel']]] + Response[List['AModel']] """ kwargs = _get_kwargs( @@ -161,7 +154,7 @@ def sync( an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], client: "MyTestApiClient", -) -> Optional[Union[HTTPValidationError, List["AModel"]]]: +) -> List["AModel"]: """Get List Get a list of things @@ -173,11 +166,11 @@ def sync( some_date (Union[datetime.date, datetime.datetime]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, List['AModel']]] + Response[List['AModel']] """ return sync_detailed( @@ -196,7 +189,7 @@ async def asyncio_detailed( an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], client: "MyTestApiClient", -) -> Response[Union[HTTPValidationError, List["AModel"]]]: +) -> Response[List["AModel"]]: """Get List Get a list of things @@ -208,11 +201,11 @@ async def asyncio_detailed( some_date (Union[datetime.date, datetime.datetime]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, List['AModel']]] + Response[List['AModel']] """ kwargs = _get_kwargs( @@ -236,7 +229,7 @@ async def asyncio( an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], client: "MyTestApiClient", -) -> Optional[Union[HTTPValidationError, List["AModel"]]]: +) -> List["AModel"]: """Get List Get a list of things @@ -248,11 +241,11 @@ async def asyncio( some_date (Union[datetime.date, datetime.datetime]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, List['AModel']]] + Response[List['AModel']] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py index e0b2a336b..368dcbcfd 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, cast import httpx @@ -38,25 +38,18 @@ def _get_kwargs(*, int_enum: AnIntEnum, client: "MyTestApiClient") -> Dict[str, } -def _parse_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: response_422 = HTTPValidationError.from_dict(response.json()) - return response_422 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content, response_422) + raise errors.UnexpectedStatus(response.status_code, response.content) -def _build_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -65,18 +58,18 @@ def _build_response( ) -def sync_detailed(*, int_enum: AnIntEnum, client: "MyTestApiClient") -> Response[Union[Any, HTTPValidationError]]: +def sync_detailed(*, int_enum: AnIntEnum, client: "MyTestApiClient") -> Response[Any]: """Int Enum Args: int_enum (AnIntEnum): An enumeration. Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ kwargs = _get_kwargs( @@ -92,18 +85,18 @@ def sync_detailed(*, int_enum: AnIntEnum, client: "MyTestApiClient") -> Response return _build_response(client=client, response=response) -def sync(*, int_enum: AnIntEnum, client: "MyTestApiClient") -> Optional[Union[Any, HTTPValidationError]]: +def sync(*, int_enum: AnIntEnum, client: "MyTestApiClient") -> Any: """Int Enum Args: int_enum (AnIntEnum): An enumeration. Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return sync_detailed( @@ -112,20 +105,18 @@ def sync(*, int_enum: AnIntEnum, client: "MyTestApiClient") -> Optional[Union[An ).parsed -async def asyncio_detailed( - *, int_enum: AnIntEnum, client: "MyTestApiClient" -) -> Response[Union[Any, HTTPValidationError]]: +async def asyncio_detailed(*, int_enum: AnIntEnum, client: "MyTestApiClient") -> Response[Any]: """Int Enum Args: int_enum (AnIntEnum): An enumeration. Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ kwargs = _get_kwargs( @@ -139,18 +130,18 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio(*, int_enum: AnIntEnum, client: "MyTestApiClient") -> Optional[Union[Any, HTTPValidationError]]: +async def asyncio(*, int_enum: AnIntEnum, client: "MyTestApiClient") -> Any: """Int Enum Args: int_enum (AnIntEnum): An enumeration. Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py index e69224747..1b0d6565b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, cast import httpx @@ -33,25 +33,18 @@ def _get_kwargs(*, json_body: AModel, client: "MyTestApiClient") -> Dict[str, An } -def _parse_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: response_422 = HTTPValidationError.from_dict(response.json()) - return response_422 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content, response_422) + raise errors.UnexpectedStatus(response.status_code, response.content) -def _build_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -60,7 +53,7 @@ def _build_response( ) -def sync_detailed(*, json_body: AModel, client: "MyTestApiClient") -> Response[Union[Any, HTTPValidationError]]: +def sync_detailed(*, json_body: AModel, client: "MyTestApiClient") -> Response[Any]: """Json Body Try sending a JSON body @@ -69,11 +62,11 @@ def sync_detailed(*, json_body: AModel, client: "MyTestApiClient") -> Response[U json_body (AModel): A Model for testing all the ways custom objects can be used Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ kwargs = _get_kwargs( @@ -89,7 +82,7 @@ def sync_detailed(*, json_body: AModel, client: "MyTestApiClient") -> Response[U return _build_response(client=client, response=response) -def sync(*, json_body: AModel, client: "MyTestApiClient") -> Optional[Union[Any, HTTPValidationError]]: +def sync(*, json_body: AModel, client: "MyTestApiClient") -> Any: """Json Body Try sending a JSON body @@ -98,11 +91,11 @@ def sync(*, json_body: AModel, client: "MyTestApiClient") -> Optional[Union[Any, json_body (AModel): A Model for testing all the ways custom objects can be used Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return sync_detailed( @@ -111,9 +104,7 @@ def sync(*, json_body: AModel, client: "MyTestApiClient") -> Optional[Union[Any, ).parsed -async def asyncio_detailed( - *, json_body: AModel, client: "MyTestApiClient" -) -> Response[Union[Any, HTTPValidationError]]: +async def asyncio_detailed(*, json_body: AModel, client: "MyTestApiClient") -> Response[Any]: """Json Body Try sending a JSON body @@ -122,11 +113,11 @@ async def asyncio_detailed( json_body (AModel): A Model for testing all the ways custom objects can be used Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ kwargs = _get_kwargs( @@ -140,7 +131,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio(*, json_body: AModel, client: "MyTestApiClient") -> Optional[Union[Any, HTTPValidationError]]: +async def asyncio(*, json_body: AModel, client: "MyTestApiClient") -> Any: """Json Body Try sending a JSON body @@ -149,11 +140,11 @@ async def asyncio(*, json_body: AModel, client: "MyTestApiClient") -> Optional[U json_body (AModel): A Model for testing all the ways custom objects can be used Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py index a5f679dd3..b69098c75 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict, cast import httpx @@ -26,13 +26,11 @@ def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = cast(Any, response.json()) + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -48,7 +46,7 @@ def sync_detailed(client: "MyTestApiClient") -> Response[Any]: """No Response Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -67,11 +65,11 @@ def sync_detailed(client: "MyTestApiClient") -> Response[Any]: return _build_response(client=client, response=response) -def sync(client: "MyTestApiClient") -> Optional[Any]: +def sync(client: "MyTestApiClient") -> Any: """No Response Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -87,7 +85,7 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[Any]: """No Response Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -104,11 +102,11 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[Any]: return _build_response(client=client, response=response) -async def asyncio(client: "MyTestApiClient") -> Optional[Any]: +async def asyncio(client: "MyTestApiClient") -> Any: """No Response Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py index 77165c017..1f12fbc71 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict import httpx @@ -28,15 +28,12 @@ def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[File]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> File: if response.status_code == HTTPStatus.OK: response_200 = File(payload=BytesIO(response.content)) return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[File]: @@ -52,7 +49,7 @@ def sync_detailed(client: "MyTestApiClient") -> Response[File]: """Octet Stream Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -71,11 +68,11 @@ def sync_detailed(client: "MyTestApiClient") -> Response[File]: return _build_response(client=client, response=response) -def sync(client: "MyTestApiClient") -> Optional[File]: +def sync(client: "MyTestApiClient") -> File: """Octet Stream Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -91,7 +88,7 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[File]: """Octet Stream Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -108,11 +105,11 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[File]: return _build_response(client=client, response=response) -async def asyncio(client: "MyTestApiClient") -> Optional[File]: +async def asyncio(client: "MyTestApiClient") -> File: """Octet Stream Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py index 0d65faadd..dc4dbeb4f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py @@ -1,12 +1,12 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict, cast import httpx if TYPE_CHECKING: from ...client import MyTestApiClient -from typing import Dict +from typing import Dict, cast from ... import errors from ...models.a_form_data import AFormData @@ -30,13 +30,11 @@ def _get_kwargs(*, form_data: AFormData, client: "MyTestApiClient") -> Dict[str, } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = cast(Any, response.json()) + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -54,7 +52,7 @@ def sync_detailed(*, form_data: AFormData, client: "MyTestApiClient") -> Respons Post form data Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -74,13 +72,13 @@ def sync_detailed(*, form_data: AFormData, client: "MyTestApiClient") -> Respons return _build_response(client=client, response=response) -def sync(*, form_data: AFormData, client: "MyTestApiClient") -> Optional[Any]: +def sync(*, form_data: AFormData, client: "MyTestApiClient") -> Any: """Post form data Post form data Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -99,7 +97,7 @@ async def asyncio_detailed(*, form_data: AFormData, client: "MyTestApiClient") - Post form data Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -117,13 +115,13 @@ async def asyncio_detailed(*, form_data: AFormData, client: "MyTestApiClient") - return _build_response(client=client, response=response) -async def asyncio(*, form_data: AFormData, client: "MyTestApiClient") -> Optional[Any]: +async def asyncio(*, form_data: AFormData, client: "MyTestApiClient") -> Any: """Post form data Post form data Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py index 09465045a..6e35fece0 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py @@ -1,12 +1,12 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict, cast import httpx if TYPE_CHECKING: from ...client import MyTestApiClient -from typing import Dict +from typing import Dict, cast from ... import errors from ...models.post_form_data_inline_data import PostFormDataInlineData @@ -30,13 +30,11 @@ def _get_kwargs(*, form_data: PostFormDataInlineData, client: "MyTestApiClient") } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = cast(Any, response.json()) + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -54,7 +52,7 @@ def sync_detailed(*, form_data: PostFormDataInlineData, client: "MyTestApiClient Post form data (inline schema) Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -74,13 +72,13 @@ def sync_detailed(*, form_data: PostFormDataInlineData, client: "MyTestApiClient return _build_response(client=client, response=response) -def sync(*, form_data: PostFormDataInlineData, client: "MyTestApiClient") -> Optional[Any]: +def sync(*, form_data: PostFormDataInlineData, client: "MyTestApiClient") -> Any: """Post form data (inline schema) Post form data (inline schema) Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -99,7 +97,7 @@ async def asyncio_detailed(*, form_data: PostFormDataInlineData, client: "MyTest Post form data (inline schema) Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -117,13 +115,13 @@ async def asyncio_detailed(*, form_data: PostFormDataInlineData, client: "MyTest return _build_response(client=client, response=response) -async def asyncio(*, form_data: PostFormDataInlineData, client: "MyTestApiClient") -> Optional[Any]: +async def asyncio(*, form_data: PostFormDataInlineData, client: "MyTestApiClient") -> Any: """Post form data (inline schema) Post form data (inline schema) Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py index 7a8510341..c823d9f5e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, cast import httpx @@ -32,25 +32,18 @@ def _get_kwargs(*, json_body: str, client: "MyTestApiClient") -> Dict[str, Any]: } -def _parse_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Optional[Union[HTTPValidationError, str]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> str: if response.status_code == HTTPStatus.OK: response_200 = cast(str, response.json()) return response_200 if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: response_422 = HTTPValidationError.from_dict(response.json()) - return response_422 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content, response_422) + raise errors.UnexpectedStatus(response.status_code, response.content) -def _build_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Response[Union[HTTPValidationError, str]]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[str]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -59,18 +52,18 @@ def _build_response( ) -def sync_detailed(*, json_body: str, client: "MyTestApiClient") -> Response[Union[HTTPValidationError, str]]: +def sync_detailed(*, json_body: str, client: "MyTestApiClient") -> Response[str]: """Json Body Which is String Args: json_body (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, str]] + Response[str] """ kwargs = _get_kwargs( @@ -86,18 +79,18 @@ def sync_detailed(*, json_body: str, client: "MyTestApiClient") -> Response[Unio return _build_response(client=client, response=response) -def sync(*, json_body: str, client: "MyTestApiClient") -> Optional[Union[HTTPValidationError, str]]: +def sync(*, json_body: str, client: "MyTestApiClient") -> str: """Json Body Which is String Args: json_body (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, str]] + Response[str] """ return sync_detailed( @@ -106,18 +99,18 @@ def sync(*, json_body: str, client: "MyTestApiClient") -> Optional[Union[HTTPVal ).parsed -async def asyncio_detailed(*, json_body: str, client: "MyTestApiClient") -> Response[Union[HTTPValidationError, str]]: +async def asyncio_detailed(*, json_body: str, client: "MyTestApiClient") -> Response[str]: """Json Body Which is String Args: json_body (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, str]] + Response[str] """ kwargs = _get_kwargs( @@ -131,18 +124,18 @@ async def asyncio_detailed(*, json_body: str, client: "MyTestApiClient") -> Resp return _build_response(client=client, response=response) -async def asyncio(*, json_body: str, client: "MyTestApiClient") -> Optional[Union[HTTPValidationError, str]]: +async def asyncio(*, json_body: str, client: "MyTestApiClient") -> str: """Json Body Which is String Args: json_body (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, str]] + Response[str] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py index cfba3cb23..53f17f429 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict import httpx @@ -33,15 +33,12 @@ def _get_kwargs(*, json_body: TestInlineObjectsJsonBody, client: "MyTestApiClien } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[TestInlineObjectsResponse200]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> TestInlineObjectsResponse200: if response.status_code == HTTPStatus.OK: response_200 = TestInlineObjectsResponse200.from_dict(response.json()) return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[TestInlineObjectsResponse200]: @@ -62,7 +59,7 @@ def sync_detailed( json_body (TestInlineObjectsJsonBody): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -82,14 +79,14 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync(*, json_body: TestInlineObjectsJsonBody, client: "MyTestApiClient") -> Optional[TestInlineObjectsResponse200]: +def sync(*, json_body: TestInlineObjectsJsonBody, client: "MyTestApiClient") -> TestInlineObjectsResponse200: """Test Inline Objects Args: json_body (TestInlineObjectsJsonBody): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -111,7 +108,7 @@ async def asyncio_detailed( json_body (TestInlineObjectsJsonBody): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -129,16 +126,14 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - *, json_body: TestInlineObjectsJsonBody, client: "MyTestApiClient" -) -> Optional[TestInlineObjectsResponse200]: +async def asyncio(*, json_body: TestInlineObjectsJsonBody, client: "MyTestApiClient") -> TestInlineObjectsResponse200: """Test Inline Objects Args: json_body (TestInlineObjectsJsonBody): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py index 928a3a1ad..e1e79c187 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict, cast import httpx @@ -28,15 +28,14 @@ def _get_kwargs(*, my_token: str, client: "MyTestApiClient") -> Dict[str, Any]: } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None + response_200 = cast(Any, response.json()) + return response_200 if response.status_code == HTTPStatus.UNAUTHORIZED: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_401 = None + raise errors.UnexpectedStatus(response.status_code, response.content, response_401) + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -57,7 +56,7 @@ def sync_detailed(*, my_token: str, client: "MyTestApiClient") -> Response[Any]: my_token (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -77,7 +76,7 @@ def sync_detailed(*, my_token: str, client: "MyTestApiClient") -> Response[Any]: return _build_response(client=client, response=response) -def sync(*, my_token: str, client: "MyTestApiClient") -> Optional[Any]: +def sync(*, my_token: str, client: "MyTestApiClient") -> Any: """TOKEN_WITH_COOKIE Test optional cookie parameters @@ -86,7 +85,7 @@ def sync(*, my_token: str, client: "MyTestApiClient") -> Optional[Any]: my_token (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -108,7 +107,7 @@ async def asyncio_detailed(*, my_token: str, client: "MyTestApiClient") -> Respo my_token (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -126,7 +125,7 @@ async def asyncio_detailed(*, my_token: str, client: "MyTestApiClient") -> Respo return _build_response(client=client, response=response) -async def asyncio(*, my_token: str, client: "MyTestApiClient") -> Optional[Any]: +async def asyncio(*, my_token: str, client: "MyTestApiClient") -> Any: """TOKEN_WITH_COOKIE Test optional cookie parameters @@ -135,7 +134,7 @@ async def asyncio(*, my_token: str, client: "MyTestApiClient") -> Optional[Any]: my_token (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py index 3eb796123..53f5d8d53 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict, cast import httpx @@ -26,13 +26,11 @@ def _get_kwargs(client: "MyTestApiClient") -> Dict[str, Any]: } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = cast(Any, response.json()) + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -48,7 +46,7 @@ def sync_detailed(client: "MyTestApiClient") -> Response[Any]: """Unsupported Content Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -67,11 +65,11 @@ def sync_detailed(client: "MyTestApiClient") -> Response[Any]: return _build_response(client=client, response=response) -def sync(client: "MyTestApiClient") -> Optional[Any]: +def sync(client: "MyTestApiClient") -> Any: """Unsupported Content Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -87,7 +85,7 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[Any]: """Unsupported Content Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -104,11 +102,11 @@ async def asyncio_detailed(client: "MyTestApiClient") -> Response[Any]: return _build_response(client=client, response=response) -async def asyncio(client: "MyTestApiClient") -> Optional[Any]: +async def asyncio(client: "MyTestApiClient") -> Any: """Unsupported Content Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py index 37662cade..9ba30e662 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, cast import httpx @@ -33,25 +33,18 @@ def _get_kwargs(*, multipart_data: BodyUploadFileTestsUploadPost, client: "MyTes } -def _parse_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: response_422 = HTTPValidationError.from_dict(response.json()) - return response_422 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content, response_422) + raise errors.UnexpectedStatus(response.status_code, response.content) -def _build_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -60,9 +53,7 @@ def _build_response( ) -def sync_detailed( - *, multipart_data: BodyUploadFileTestsUploadPost, client: "MyTestApiClient" -) -> Response[Union[Any, HTTPValidationError]]: +def sync_detailed(*, multipart_data: BodyUploadFileTestsUploadPost, client: "MyTestApiClient") -> Response[Any]: """Upload File Upload a file @@ -71,11 +62,11 @@ def sync_detailed( multipart_data (BodyUploadFileTestsUploadPost): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ kwargs = _get_kwargs( @@ -91,9 +82,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync( - *, multipart_data: BodyUploadFileTestsUploadPost, client: "MyTestApiClient" -) -> Optional[Union[Any, HTTPValidationError]]: +def sync(*, multipart_data: BodyUploadFileTestsUploadPost, client: "MyTestApiClient") -> Any: """Upload File Upload a file @@ -102,11 +91,11 @@ def sync( multipart_data (BodyUploadFileTestsUploadPost): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return sync_detailed( @@ -117,7 +106,7 @@ def sync( async def asyncio_detailed( *, multipart_data: BodyUploadFileTestsUploadPost, client: "MyTestApiClient" -) -> Response[Union[Any, HTTPValidationError]]: +) -> Response[Any]: """Upload File Upload a file @@ -126,11 +115,11 @@ async def asyncio_detailed( multipart_data (BodyUploadFileTestsUploadPost): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ kwargs = _get_kwargs( @@ -144,9 +133,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - *, multipart_data: BodyUploadFileTestsUploadPost, client: "MyTestApiClient" -) -> Optional[Union[Any, HTTPValidationError]]: +async def asyncio(*, multipart_data: BodyUploadFileTestsUploadPost, client: "MyTestApiClient") -> Any: """Upload File Upload a file @@ -155,11 +142,11 @@ async def asyncio( multipart_data (BodyUploadFileTestsUploadPost): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py index 5814d8d9e..57c149e04 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, List, cast import httpx @@ -36,25 +36,18 @@ def _get_kwargs(*, multipart_data: List[File], client: "MyTestApiClient") -> Dic } -def _parse_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: response_422 = HTTPValidationError.from_dict(response.json()) - return response_422 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.UnexpectedStatus(response.status_code, response.content, response_422) + raise errors.UnexpectedStatus(response.status_code, response.content) -def _build_response( - *, client: "MyTestApiClient", response: httpx.Response -) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -63,9 +56,7 @@ def _build_response( ) -def sync_detailed( - *, multipart_data: List[File], client: "MyTestApiClient" -) -> Response[Union[Any, HTTPValidationError]]: +def sync_detailed(*, multipart_data: List[File], client: "MyTestApiClient") -> Response[Any]: """Upload multiple files Upload several files in the same request @@ -74,11 +65,11 @@ def sync_detailed( multipart_data (List[File]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ kwargs = _get_kwargs( @@ -94,7 +85,7 @@ def sync_detailed( return _build_response(client=client, response=response) -def sync(*, multipart_data: List[File], client: "MyTestApiClient") -> Optional[Union[Any, HTTPValidationError]]: +def sync(*, multipart_data: List[File], client: "MyTestApiClient") -> Any: """Upload multiple files Upload several files in the same request @@ -103,11 +94,11 @@ def sync(*, multipart_data: List[File], client: "MyTestApiClient") -> Optional[U multipart_data (List[File]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return sync_detailed( @@ -116,9 +107,7 @@ def sync(*, multipart_data: List[File], client: "MyTestApiClient") -> Optional[U ).parsed -async def asyncio_detailed( - *, multipart_data: List[File], client: "MyTestApiClient" -) -> Response[Union[Any, HTTPValidationError]]: +async def asyncio_detailed(*, multipart_data: List[File], client: "MyTestApiClient") -> Response[Any]: """Upload multiple files Upload several files in the same request @@ -127,11 +116,11 @@ async def asyncio_detailed( multipart_data (List[File]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ kwargs = _get_kwargs( @@ -145,9 +134,7 @@ async def asyncio_detailed( return _build_response(client=client, response=response) -async def asyncio( - *, multipart_data: List[File], client: "MyTestApiClient" -) -> Optional[Union[Any, HTTPValidationError]]: +async def asyncio(*, multipart_data: List[File], client: "MyTestApiClient") -> Any: """Upload multiple files Upload several files in the same request @@ -156,11 +143,11 @@ async def asyncio( multipart_data (List[File]): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Any] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/true_/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/api/true_/__init__.py index 1fca75837..80c4de474 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/true_/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/true_/__init__.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Optional +from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from ...client import MyTestApiClient @@ -14,13 +14,13 @@ def false_( self, *, import_: str, - ) -> Optional[Any]: + ) -> Any: """ Args: import_ (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -36,13 +36,13 @@ async def false__async( self, *, import_: str, - ) -> Optional[Any]: + ) -> Any: """ Args: import_ (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py b/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py index d67b71c88..5f28d963d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict import httpx @@ -32,13 +32,11 @@ def _get_kwargs(*, import_: str, client: "MyTestApiClient") -> Dict[str, Any]: } -def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]: +def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any: if response.status_code == HTTPStatus.OK: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + response_200 = None + return response_200 + raise errors.UnexpectedStatus(response.status_code, response.content) def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]: @@ -56,7 +54,7 @@ def sync_detailed(*, import_: str, client: "MyTestApiClient") -> Response[Any]: import_ (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -76,13 +74,13 @@ def sync_detailed(*, import_: str, client: "MyTestApiClient") -> Response[Any]: return _build_response(client=client, response=response) -def sync(*, import_: str, client: "MyTestApiClient") -> Optional[Any]: +def sync(*, import_: str, client: "MyTestApiClient") -> Any: """ Args: import_ (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -101,7 +99,7 @@ async def asyncio_detailed(*, import_: str, client: "MyTestApiClient") -> Respon import_ (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: @@ -119,13 +117,13 @@ async def asyncio_detailed(*, import_: str, client: "MyTestApiClient") -> Respon return _build_response(client=client, response=response) -async def asyncio(*, import_: str, client: "MyTestApiClient") -> Optional[Any]: +async def asyncio(*, import_: str, client: "MyTestApiClient") -> Any: """ Args: import_ (str): Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.UnexpectedStatus: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/end_to_end_tests/golden-record/my_test_api_client/client.py b/end_to_end_tests/golden-record/my_test_api_client/client.py index 5b8009f11..5b33e3699 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/client.py +++ b/end_to_end_tests/golden-record/my_test_api_client/client.py @@ -24,7 +24,7 @@ class MyTestApiClient: but can be set to False for testing purposes. raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a status code that was not documented in the source OpenAPI document. - follow_redirects: Whether or not to follow redirects. Default value is False. + follow_redirects: Whether or not to follow redirects. Default value is True. """ def __init__( @@ -34,8 +34,7 @@ def __init__( headers: Union[Dict[str, str], None] = None, timeout: float = 5.0, verify_ssl: Union[str, bool, ssl.SSLContext] = True, - raise_on_unexpected_status: bool = False, - follow_redirects: bool = False, + follow_redirects: bool = True, token: Union[str, None] = None, prefix: str = "Bearer", auth_header_name: str = "Authorization", @@ -48,7 +47,6 @@ def __init__( self.headers = headers self.timeout = timeout self.verify_ssl = verify_ssl - self.raise_on_unexpected_status = raise_on_unexpected_status self.follow_redirects = follow_redirects self.token = token self.prefix = prefix diff --git a/end_to_end_tests/golden-record/my_test_api_client/docs/Tests.md b/end_to_end_tests/golden-record/my_test_api_client/docs/Tests.md index 0f221433b..e6d545f4d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/docs/Tests.md +++ b/end_to_end_tests/golden-record/my_test_api_client/docs/Tests.md @@ -42,7 +42,7 @@ some_date | [Union[datetime.date, datetime.datetime]](Union[datetime.date, datet ### Response Type -Union[HTTPValidationError, List['AModel']] +List['AModel'] # **get_basic_list_of_strings** @@ -124,7 +124,7 @@ multipart_data | [BodyUploadFileTestsUploadPost](BodyUploadFileTestsUploadPost) ### Response Type -Union[Any, HTTPValidationError] +Any # **upload_multiple_files_tests_upload_post** @@ -140,7 +140,7 @@ multipart_data | [List[File]](List[File]) | None ### Response Type -Union[Any, HTTPValidationError] +Any # **json_body_tests_json_body_post** @@ -156,7 +156,7 @@ json_body | [AModel](AModel) | A Model for testing all the ways custom objects c ### Response Type -Union[Any, HTTPValidationError] +Any # **post_tests_json_body_string** @@ -170,7 +170,7 @@ json_body | str | None ### Response Type -Union[HTTPValidationError, str] +str # **defaults_tests_defaults_post** @@ -194,7 +194,7 @@ required_model_prop | [ModelWithUnionProperty](ModelWithUnionProperty) | ### Response Type -Union[Any, HTTPValidationError] +Any # **octet_stream_tests_octet_stream_get** @@ -235,7 +235,7 @@ int_enum | AnIntEnum | An enumeration. ### Response Type -Union[Any, HTTPValidationError] +Any # **test_inline_objects** @@ -281,7 +281,7 @@ json_body | [AModel](AModel) | A Model for testing all the ways custom objects c ### Response Type -Union[Any, HTTPValidationError] +Any # **description_with_backslash** diff --git a/end_to_end_tests/golden-record/my_test_api_client/errors.py b/end_to_end_tests/golden-record/my_test_api_client/errors.py index 426f8a2ed..24d933312 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/errors.py +++ b/end_to_end_tests/golden-record/my_test_api_client/errors.py @@ -1,12 +1,18 @@ """ Contains shared errors types that can be raised from API functions """ -class UnexpectedStatus(Exception): +from typing import Generic, Optional, TypeVar + +T = TypeVar("T") + + +class UnexpectedStatus(Exception, Generic[T]): """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True""" - def __init__(self, status_code: int, content: bytes): + def __init__(self, status_code: int, content: bytes, parsed: Optional[T]): self.status_code = status_code self.content = content + self.parsed = parsed super().__init__(f"Unexpected status code: {status_code}") diff --git a/end_to_end_tests/golden-record/my_test_api_client/types.py b/end_to_end_tests/golden-record/my_test_api_client/types.py index 230efea92..2e9f7b08c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/types.py +++ b/end_to_end_tests/golden-record/my_test_api_client/types.py @@ -38,7 +38,7 @@ class Response(Generic[T]): status_code: HTTPStatus content: bytes headers: MutableMapping[str, str] - parsed: Optional[T] + parsed: T __all__ = ["File", "Response", "FileJsonType"] diff --git a/openapi_python_client/parser/openapi.py b/openapi_python_client/parser/openapi.py index 35e01223a..56aaaa186 100644 --- a/openapi_python_client/parser/openapi.py +++ b/openapi_python_client/parser/openapi.py @@ -514,8 +514,9 @@ def from_data( return result, schemas, parameters def response_type(self) -> str: - """Get the Python type of any response from this endpoint""" - types = sorted({response.prop.get_type_string(quoted=False) for response in self.responses}) + """Get the Python type of success responses from this endpoint""" + success_responses = [response for response in self.responses if response.is_success] + types = sorted({response.prop.get_type_string(quoted=False) for response in success_responses }) if len(types) == 0: return "Any" if len(types) == 1: diff --git a/openapi_python_client/parser/responses.py b/openapi_python_client/parser/responses.py index e1f2cb49a..bb6cac596 100644 --- a/openapi_python_client/parser/responses.py +++ b/openapi_python_client/parser/responses.py @@ -20,6 +20,9 @@ class Response: prop: Property source: str + @property + def is_success(self): + return self.status_code >= 200 and self.status_code <= 299 def _source_by_content_type(content_type: str) -> Optional[str]: known_content_types = { diff --git a/openapi_python_client/templates/api.py.jinja b/openapi_python_client/templates/api.py.jinja deleted file mode 100644 index 1b6fb37a2..000000000 --- a/openapi_python_client/templates/api.py.jinja +++ /dev/null @@ -1,21 +0,0 @@ -from .api.{{ endpoint_collection.tag.identifier_name }} import ( -{% for endpoint in endpoint_collection.endpoints %} -{{ module_name(endpoint) }} as __{{ module_name(endpoint) }}, -{% endfor %} -) - - -{% for endpoint in endpoint_collection.endpoints %} -{% set mod = module_name(endpoint) %} - -{% if (endpoint.responses | length > 0) and endpoint.response_type() != "Any" %} -{{ mod }} = __{{ mod }}.sync -{{ mod }}_detailed = __{{ mod }}.sync_detailed -{{ mod }}_async = __{{ mod }}.asyncio -{{ mod }}_async_detailed = __{{ mod }}.asyncio_detailed -{% else %} -{{ mod }} = __{{ mod }}.sync_detailed -{{ mod }}_async = __{{ mod }}.asyncio_detailed -{% endif %} - -{% endfor %} diff --git a/openapi_python_client/templates/client.py.jinja b/openapi_python_client/templates/client.py.jinja index 48e2b8ca9..1ec7fff7f 100644 --- a/openapi_python_client/templates/client.py.jinja +++ b/openapi_python_client/templates/client.py.jinja @@ -20,7 +20,7 @@ class {{ client_name }}: but can be set to False for testing purposes. raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a status code that was not documented in the source OpenAPI document. - follow_redirects: Whether or not to follow redirects. Default value is False. + follow_redirects: Whether or not to follow redirects. Default value is True. """ def __init__( @@ -30,8 +30,7 @@ class {{ client_name }}: headers: Union[Dict[str, str], None] = None, timeout: float = 5.0, verify_ssl: Union[str, bool, ssl.SSLContext] = True, - raise_on_unexpected_status: bool = False, - follow_redirects: bool = False, + follow_redirects: bool = True, token: Union[str, None] = None, prefix: str = "Bearer", auth_header_name: str = "Authorization", @@ -44,7 +43,6 @@ class {{ client_name }}: self.headers = headers self.timeout = timeout self.verify_ssl = verify_ssl - self.raise_on_unexpected_status = raise_on_unexpected_status self.follow_redirects = follow_redirects self.token = token self.prefix = prefix diff --git a/openapi_python_client/templates/endpoint_init.py.jinja b/openapi_python_client/templates/endpoint_init.py.jinja index fb4f36d30..da98288c6 100644 --- a/openapi_python_client/templates/endpoint_init.py.jinja +++ b/openapi_python_client/templates/endpoint_init.py.jinja @@ -1,4 +1,4 @@ -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING if TYPE_CHECKING: from ...client import {{ client_name }} @@ -28,7 +28,7 @@ class {{ endpoint_collection.tag.class_name }}: def {{ mod }}( self, {{ arguments(endpoint) | indent(4) }} - ) -> Optional[{{ return_string }}]: + ) -> {{ return_string }}: {{ docstring(endpoint, return_string) | indent(8) }} return {{ mod }}.sync( client=self.__client, @@ -38,7 +38,7 @@ class {{ endpoint_collection.tag.class_name }}: async def {{ mod }}_async( self, {{ arguments(endpoint) | indent(4) }} - ) -> Optional[{{ return_string }}]: + ) -> {{ return_string }}: {{ docstring(endpoint, return_string) | indent(8) }} return await {{ mod }}.asyncio( client=self.__client, diff --git a/openapi_python_client/templates/endpoint_macros.py.jinja b/openapi_python_client/templates/endpoint_macros.py.jinja index 20fbcaf63..64e27f4c1 100644 --- a/openapi_python_client/templates/endpoint_macros.py.jinja +++ b/openapi_python_client/templates/endpoint_macros.py.jinja @@ -159,7 +159,7 @@ Args: {% endif %} Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + errors.{{ client_name }}Error: If the server returns a non 2xx status code. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: diff --git a/openapi_python_client/templates/endpoint_module.py.jinja b/openapi_python_client/templates/endpoint_module.py.jinja index aa290a30f..fb51038fe 100644 --- a/openapi_python_client/templates/endpoint_module.py.jinja +++ b/openapi_python_client/templates/endpoint_module.py.jinja @@ -18,7 +18,7 @@ from ... import errors arguments, client, kwargs, parse_response, docstring %} {% set return_string = endpoint.response_type() %} -{% set parsed_responses = (endpoint.responses | length > 0) and return_string != "Any" %} +{% set parsed_responses = endpoint.responses | length > 0 %} def _get_kwargs( {{ arguments(endpoint) | indent(4) }} @@ -64,24 +64,29 @@ def _get_kwargs( } -def _parse_response(*, client: "{{ client_name }}", response: httpx.Response) -> Optional[{{ return_string }}]: +def _parse_response(*, client: "{{ client_name }}", response: httpx.Response) -> {{ return_string }}: {% for response in endpoint.responses %} if response.status_code == HTTPStatus.{{ response.status_code.name }}: {% if parsed_responses %}{% import "property_templates/" + response.prop.template as prop_template %} {% if prop_template.construct %} {{ prop_template.construct(response.prop, response.source) | indent(8) }} + {% elif response.source == "None" %} + {{ response.prop.python_name }} = None {% else %} {{ response.prop.python_name }} = cast({{ response.prop.get_type_string() }}, {{ response.source }}) {% endif %} + {% if response.is_success %} return {{ response.prop.python_name }} {% else %} + raise errors.{{ client_name }}Error(response.status_code, response.content, {{ response.prop.python_name }}) + {% endif %} + {% else %} + {% if response.is_success %} return None {% endif %} + {% endif %} {% endfor %} - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None + raise errors.{{ client_name }}Error(response.status_code, response.content) def _build_response(*, client: "{{ client_name }}", response: httpx.Response) -> Response[{{ return_string }}]: @@ -113,7 +118,7 @@ def sync_detailed( def sync( {{ arguments(endpoint) | indent(4) }} client: "{{ client_name }}" -) -> Optional[{{ return_string }}]: +) -> {{ return_string }}: {{ docstring(endpoint, return_string) | indent(4) }} return sync_detailed( @@ -140,7 +145,7 @@ async def asyncio_detailed( async def asyncio( {{ arguments(endpoint) | indent(4) }} client: "{{ client_name }}" -) -> Optional[{{ return_string }}]: +) -> {{ return_string }}: {{ docstring(endpoint, return_string) | indent(4) }} return (await asyncio_detailed( diff --git a/openapi_python_client/templates/errors.py.jinja b/openapi_python_client/templates/errors.py.jinja index 514d3c1b9..1a5da2bcf 100644 --- a/openapi_python_client/templates/errors.py.jinja +++ b/openapi_python_client/templates/errors.py.jinja @@ -1,12 +1,19 @@ """ Contains shared errors types that can be raised from API functions """ -class UnexpectedStatus(Exception): - """ Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True """ - def __init__(self, status_code: int, content: bytes): +from typing import Generic, Optional, TypeVar + +T = TypeVar("T") + +class {{ client_name }}Error(Exception, Generic[T]): + """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True""" + + def __init__(self, status_code: int, content: bytes, parsed: Optional[T]): self.status_code = status_code self.content = content + self.parsed = parsed super().__init__(f"Unexpected status code: {status_code}") -__all__ = ["UnexpectedStatus"] + +__all__ = ["{{ client_name }}Error"] \ No newline at end of file diff --git a/openapi_python_client/templates/types.py.jinja b/openapi_python_client/templates/types.py.jinja index c746db6e1..82a522c6f 100644 --- a/openapi_python_client/templates/types.py.jinja +++ b/openapi_python_client/templates/types.py.jinja @@ -39,7 +39,7 @@ class Response(Generic[T]): status_code: HTTPStatus content: bytes headers: MutableMapping[str, str] - parsed: Optional[T] + parsed: T __all__ = ["File", "Response", "FileJsonType"]