From ae2797f7b7cca7a9fe11bbbd28057bed5d40f673 Mon Sep 17 00:00:00 2001 From: Ykrej Date: Thu, 26 Feb 2026 21:35:43 -0800 Subject: [PATCH 1/8] feat: added support for non standard http status codes --- openapi_python_client/__init__.py | 1 + openapi_python_client/parser/responses.py | 6 +++++- .../templates/endpoint_module.py.jinja | 14 ++++++++++---- openapi_python_client/templates/types.py.jinja | 5 +++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/openapi_python_client/__init__.py b/openapi_python_client/__init__.py index 52d34b4fc..2d698f1cb 100644 --- a/openapi_python_client/__init__.py +++ b/openapi_python_client/__init__.py @@ -31,6 +31,7 @@ "kebabcase": utils.kebab_case, "pascalcase": utils.pascal_case, "any": any, + "all": all, } diff --git a/openapi_python_client/parser/responses.py b/openapi_python_client/parser/responses.py index f05fbce75..bb7ad84e5 100644 --- a/openapi_python_client/parser/responses.py +++ b/openapi_python_client/parser/responses.py @@ -1,6 +1,6 @@ __all__ = ["HTTPStatusPattern", "Response", "Responses", "response_from_data"] - from collections.abc import Iterator +from http import HTTPStatus from typing import TypedDict from attrs import define @@ -53,11 +53,15 @@ class HTTPStatusPattern: pattern: str range: tuple[int, int] | None + is_official: bool def __init__(self, *, pattern: str, code_range: tuple[int, int] | None): """Initialize with a range of status codes or None for the default case.""" self.pattern = pattern self.range = code_range + self.is_official = self.range is None or all( + code in HTTPStatus for code in range(self.range[0], self.range[1] + 1) + ) @staticmethod def parse(pattern: str) -> "HTTPStatusPattern | ParseError": diff --git a/openapi_python_client/templates/endpoint_module.py.jinja b/openapi_python_client/templates/endpoint_module.py.jinja index 23fd2a40d..156a6e8a8 100644 --- a/openapi_python_client/templates/endpoint_module.py.jinja +++ b/openapi_python_client/templates/endpoint_module.py.jinja @@ -1,4 +1,3 @@ -from http import HTTPStatus from typing import Any, cast from urllib.parse import quote @@ -12,6 +11,13 @@ from ... import errors {{ relative }} {% endfor %} +{% if endpoint.responses|list|length == 0 or endpoint.responses|map(attribute="status_code")|map(attribute="is_official")|all %} +import http +HTTPStatus = http.HTTPStatus +{% else %} +HTTPStatus = int +{% endif %} + {% from "endpoint_macros.py.jinja" import header_params, cookie_params, query_params, arguments, client, kwargs, parse_response, docstring, body_to_kwarg %} @@ -92,7 +98,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res {% endif %} -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[{{ return_string }}]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[{{ return_string }}, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -103,7 +109,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( {{ arguments(endpoint) | indent(4) }} -) -> Response[{{ return_string }}]: +) -> Response[{{ return_string }}, HTTPStatus]: {{ docstring(endpoint, return_string, is_detailed=true) | indent(4) }} kwargs = _get_kwargs( @@ -129,7 +135,7 @@ def sync( async def asyncio_detailed( {{ arguments(endpoint) | indent(4) }} -) -> Response[{{ return_string }}]: +) -> Response[{{ return_string }}, HTTPStatus]: {{ docstring(endpoint, return_string, is_detailed=true) | indent(4) }} kwargs = _get_kwargs( diff --git a/openapi_python_client/templates/types.py.jinja b/openapi_python_client/templates/types.py.jinja index f74db0ad7..4d1a362d0 100644 --- a/openapi_python_client/templates/types.py.jinja +++ b/openapi_python_client/templates/types.py.jinja @@ -38,13 +38,14 @@ class File: T = TypeVar("T") +S = TypeVar("S", bound=HTTPStatus | int) @define -class Response(Generic[T]): +class Response(Generic[T, S]): """ A response from an endpoint """ - status_code: HTTPStatus + status_code: S content: bytes headers: MutableMapping[str, str] parsed: T | None From d401b516c350f9a2d1bdf6e08fa2612673b03a24 Mon Sep 17 00:00:00 2001 From: Ykrej Date: Thu, 26 Feb 2026 21:36:04 -0800 Subject: [PATCH 2/8] test: updated tests for non standard http status codes change --- .../my_test_api_client/types.py | 5 +++-- .../my_test_api_client/api/bodies/json_like.py | 10 ++++++---- .../api/bodies/optional_body.py | 10 ++++++---- .../api/bodies/post_bodies_multiple.py | 10 ++++++---- .../my_test_api_client/api/bodies/refs.py | 10 ++++++---- .../api/config/content_type_override.py | 10 ++++++---- .../api/default/get_common_parameters.py | 10 ++++++---- .../api/default/get_models_allof.py | 10 ++++++---- .../get_models_oneof_with_required_const.py | 16 ++++++++++++---- .../api/default/post_common_parameters.py | 10 ++++++---- .../default/post_types_unions_duplicate_types.py | 10 ++++++---- .../api/default/reserved_parameters.py | 10 ++++++---- .../api/defaults/defaults_tests_defaults_post.py | 10 ++++++---- .../api/enums/bool_enum_tests_bool_enum_post.py | 10 ++++++---- .../api/enums/int_enum_tests_int_enum_post.py | 10 ++++++---- .../api/location/get_location_header_types.py | 10 ++++++---- .../location/get_location_query_optionality.py | 10 ++++++---- .../api/naming/hyphen_in_path.py | 10 ++++++---- .../my_test_api_client/api/naming/mixed_case.py | 10 ++++++---- .../post_naming_property_conflict_with_import.py | 10 ++++++---- .../get_parameter_references_path_param.py | 10 ++++++---- .../delete_common_parameters_overriding_param.py | 10 ++++++---- .../get_common_parameters_overriding_param.py | 10 ++++++---- .../get_same_name_multiple_locations_param.py | 10 ++++++---- .../api/parameters/multiple_path_parameters.py | 10 ++++++---- .../api/responses/default_status_code.py | 10 ++++++---- ...ost_responses_unions_simple_before_complex.py | 10 ++++++---- .../api/responses/reference_response.py | 10 ++++++---- .../api/responses/status_code_patterns.py | 9 +++++---- .../api/responses/status_code_precedence.py | 9 +++++---- .../api/responses/text_response.py | 10 ++++++---- .../api/tag1/get_tag_with_number.py | 10 ++++++---- .../api/tag2/get_tag_with_number.py | 10 ++++++---- .../api/tests/callback_test.py | 10 ++++++---- .../api/tests/description_with_backslash.py | 10 ++++++---- .../api/tests/get_basic_list_of_booleans.py | 12 ++++++++---- .../api/tests/get_basic_list_of_floats.py | 12 ++++++++---- .../api/tests/get_basic_list_of_integers.py | 12 ++++++++---- .../api/tests/get_basic_list_of_strings.py | 12 ++++++++---- .../api/tests/get_user_list.py | 10 ++++++---- .../api/tests/json_body_tests_json_body_post.py | 10 ++++++---- .../tests/no_response_tests_no_response_get.py | 10 ++++++---- .../tests/octet_stream_tests_octet_stream_get.py | 10 ++++++---- .../octet_stream_tests_octet_stream_post.py | 10 ++++++---- .../api/tests/post_form_data.py | 10 ++++++---- .../api/tests/post_form_data_inline.py | 10 ++++++---- .../api/tests/post_tests_json_body_string.py | 10 ++++++---- .../api/tests/test_inline_objects.py | 10 ++++++---- ...ken_with_cookie_auth_token_with_cookie_get.py | 10 ++++++---- ...rted_content_tests_unsupported_content_get.py | 10 ++++++---- .../api/tests/upload_file_tests_upload_post.py | 10 ++++++---- .../my_test_api_client/api/true_/false_.py | 10 ++++++---- .../golden-record/my_test_api_client/types.py | 5 +++-- .../api/enums/bool_enum_tests_bool_enum_post.py | 10 ++++++---- .../api/enums/int_enum_tests_int_enum_post.py | 10 ++++++---- .../api/tests/get_user_list.py | 16 +++++++++------- .../api/tests/post_user_list.py | 12 ++++++++---- .../my_enum_api_client/types.py | 5 +++-- .../api/const/post_const_path.py | 10 ++++++---- .../api/prefix_items/post_prefix_items.py | 10 ++++++---- .../test_3_1_features_client/types.py | 5 +++-- .../api/body/post_body_multipart.py | 10 ++++++---- .../api/parameters/post_parameters_header.py | 10 ++++++---- integration-tests/integration_tests/types.py | 5 +++-- .../test_body/test_post_body_multipart.py | 3 ++- 65 files changed, 388 insertions(+), 250 deletions(-) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/types.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/types.py index b64af0952..02e376a68 100644 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/types.py +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/types.py @@ -39,13 +39,14 @@ def to_tuple(self) -> FileTypes: T = TypeVar("T") +S = TypeVar("S", bound=HTTPStatus | int) @define -class Response(Generic[T]): +class Response(Generic[T, S]): """A response from an endpoint""" - status_code: HTTPStatus + status_code: S content: bytes headers: MutableMapping[str, str] parsed: T | None diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py index 1a4fc2fd9..e5beee4f8 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -8,6 +8,8 @@ from ...models.json_like_body import JsonLikeBody from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -39,7 +41,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,7 +54,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: JsonLikeBody | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """A content type that works like json but isn't application/json Args: @@ -81,7 +83,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: JsonLikeBody | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """A content type that works like json but isn't application/json Args: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/optional_body.py b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/optional_body.py index 8402cf086..881bde3f4 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/optional_body.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/optional_body.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -8,6 +8,8 @@ from ...models.optional_body_body import OptionalBodyBody from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -39,7 +41,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,7 +54,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: OptionalBodyBody | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Test optional request body Args: @@ -81,7 +83,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: OptionalBodyBody | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Test optional request body Args: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py index ca740ee45..ae9f8f62c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -10,6 +10,8 @@ from ...models.post_bodies_multiple_json_body import PostBodiesMultipleJsonBody from ...types import UNSET, File, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -57,7 +59,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -70,7 +72,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: PostBodiesMultipleJsonBody | File | PostBodiesMultipleDataBody | PostBodiesMultipleFilesBody | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Test multiple bodies Args: @@ -102,7 +104,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: PostBodiesMultipleJsonBody | File | PostBodiesMultipleDataBody | PostBodiesMultipleFilesBody | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Test multiple bodies Args: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/refs.py b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/refs.py index 2e224bc8c..bdc169af9 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/refs.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/refs.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -8,6 +8,8 @@ from ...models.a_model import AModel from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -39,7 +41,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,7 +54,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: AModel | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Test request body defined via ref Args: @@ -81,7 +83,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: AModel | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Test request body defined via ref Args: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/config/content_type_override.py b/end_to_end_tests/golden-record/my_test_api_client/api/config/content_type_override.py index be06459be..84e90a748 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/config/content_type_override.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/config/content_type_override.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any, cast import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -39,7 +41,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[str]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[str, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,7 +54,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: str | Unset = UNSET, -) -> Response[str]: +) -> Response[str, HTTPStatus]: """Content Type Override Args: @@ -105,7 +107,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: str | Unset = UNSET, -) -> Response[str]: +) -> Response[str, HTTPStatus]: """Content Type Override Args: 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 1fe9e78a0..e93def95c 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -37,7 +39,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -50,7 +52,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, common: str | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: common (str | Unset): @@ -78,7 +80,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, common: str | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: common (str | Unset): diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_allof.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_allof.py index 073ce1e6b..57408ddeb 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_allof.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_allof.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -8,6 +8,8 @@ from ...models.get_models_allof_response_200 import GetModelsAllofResponse200 from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -34,7 +36,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[GetModelsAllofResponse200]: +) -> Response[GetModelsAllofResponse200, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -46,7 +48,7 @@ def _build_response( def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[GetModelsAllofResponse200]: +) -> Response[GetModelsAllofResponse200, HTTPStatus]: """ Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -86,7 +88,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[GetModelsAllofResponse200]: +) -> Response[GetModelsAllofResponse200, HTTPStatus]: """ Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py index 3401cf323..73195a17a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -13,6 +13,8 @@ ) from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -57,7 +59,9 @@ def _parse_response_200( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[GetModelsOneofWithRequiredConstResponse200Type0 | GetModelsOneofWithRequiredConstResponse200Type1]: +) -> Response[ + GetModelsOneofWithRequiredConstResponse200Type0 | GetModelsOneofWithRequiredConstResponse200Type1, HTTPStatus +]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -69,7 +73,9 @@ def _build_response( def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[GetModelsOneofWithRequiredConstResponse200Type0 | GetModelsOneofWithRequiredConstResponse200Type1]: +) -> Response[ + GetModelsOneofWithRequiredConstResponse200Type0 | GetModelsOneofWithRequiredConstResponse200Type1, HTTPStatus +]: """ Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -109,7 +115,9 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[GetModelsOneofWithRequiredConstResponse200Type0 | GetModelsOneofWithRequiredConstResponse200Type1]: +) -> Response[ + GetModelsOneofWithRequiredConstResponse200Type0 | GetModelsOneofWithRequiredConstResponse200Type1, HTTPStatus +]: """ Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. 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 14bab0778..c236fee61 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -37,7 +39,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -50,7 +52,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, common: str | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: common (str | Unset): @@ -78,7 +80,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, common: str | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: common (str | Unset): diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_types_unions_duplicate_types.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_types_unions_duplicate_types.py index f6eabc4a7..847a7d9cb 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_types_unions_duplicate_types.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_types_unions_duplicate_types.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -8,6 +8,8 @@ from ...models.a_model import AModel from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -49,7 +51,7 @@ def _parse_response_200(data: object) -> AModel: return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[AModel]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[AModel, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -62,7 +64,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: AModel | Unset = UNSET, -) -> Response[AModel]: +) -> Response[AModel, HTTPStatus]: """ Args: body (AModel | Unset): @@ -113,7 +115,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: AModel | Unset = UNSET, -) -> Response[AModel]: +) -> Response[AModel, HTTPStatus]: """ Args: body (AModel | Unset): diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/reserved_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/reserved_parameters.py index 990c945b0..d4a8b16d7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/reserved_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/reserved_parameters.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import UNSET, Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -40,7 +42,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -54,7 +56,7 @@ def sync_detailed( client: AuthenticatedClient | Client, client_query: str, url_query: str, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: client_query (str): @@ -85,7 +87,7 @@ async def asyncio_detailed( client: AuthenticatedClient | Client, client_query: str, url_query: str, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: client_query (str): diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py index 6cadc465a..8683102b3 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py @@ -1,5 +1,5 @@ import datetime -from http import HTTPStatus +import http from typing import Any import httpx @@ -12,6 +12,8 @@ from ...models.model_with_union_property import ModelWithUnionProperty from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -106,7 +108,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[Any | HTTPValidationError]: +) -> Response[Any | HTTPValidationError, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -131,7 +133,7 @@ def sync_detailed( enum_prop: AnEnum, model_prop: ModelWithUnionProperty, required_model_prop: ModelWithUnionProperty, -) -> Response[Any | HTTPValidationError]: +) -> Response[Any | HTTPValidationError, HTTPStatus]: """Defaults Args: @@ -256,7 +258,7 @@ async def asyncio_detailed( enum_prop: AnEnum, model_prop: ModelWithUnionProperty, required_model_prop: ModelWithUnionProperty, -) -> Response[Any | HTTPValidationError]: +) -> Response[Any | HTTPValidationError, HTTPStatus]: """Defaults Args: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py index 4ed5ff6ee..4270b5178 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import UNSET, Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -37,7 +39,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -50,7 +52,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, bool_enum: bool, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Bool Enum Args: @@ -79,7 +81,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, bool_enum: bool, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Bool Enum Args: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py index 8ebc2b95f..b918d583f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -8,6 +8,8 @@ from ...models.an_int_enum import AnIntEnum from ...types import UNSET, Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -39,7 +41,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,7 +54,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, int_enum: AnIntEnum, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Int Enum Args: @@ -81,7 +83,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, int_enum: AnIntEnum, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Int Enum Args: 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 20c2db527..62a86269f 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -9,6 +9,8 @@ from ...models.get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -57,7 +59,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -75,7 +77,7 @@ def sync_detailed( integer_header: int | Unset = UNSET, int_enum_header: GetLocationHeaderTypesIntEnumHeader | Unset = UNSET, string_enum_header: GetLocationHeaderTypesStringEnumHeader | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: boolean_header (bool | Unset): @@ -118,7 +120,7 @@ async def asyncio_detailed( integer_header: int | Unset = UNSET, int_enum_header: GetLocationHeaderTypesIntEnumHeader | Unset = UNSET, string_enum_header: GetLocationHeaderTypesStringEnumHeader | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: boolean_header (bool | Unset): 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 e454a50a9..2e9587e67 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 @@ import datetime -from http import HTTPStatus +import http from typing import Any import httpx @@ -8,6 +8,8 @@ from ...client import AuthenticatedClient, Client from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -63,7 +65,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -79,7 +81,7 @@ def sync_detailed( null_required: datetime.datetime | None, null_not_required: datetime.datetime | None | Unset = UNSET, not_null_not_required: datetime.datetime | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: not_null_required (datetime.datetime): @@ -116,7 +118,7 @@ async def asyncio_detailed( null_required: datetime.datetime | None, null_not_required: datetime.datetime | None | Unset = UNSET, not_null_not_required: datetime.datetime | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: not_null_required (datetime.datetime): diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/naming/hyphen_in_path.py b/end_to_end_tests/golden-record/my_test_api_client/api/naming/hyphen_in_path.py index a31e2e093..abd3aaf05 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/naming/hyphen_in_path.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/naming/hyphen_in_path.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any from urllib.parse import quote @@ -8,6 +8,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( hyphen_in_path: str, @@ -32,7 +34,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -45,7 +47,7 @@ def sync_detailed( hyphen_in_path: str, *, client: AuthenticatedClient | Client, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: hyphen_in_path (str): @@ -73,7 +75,7 @@ async def asyncio_detailed( hyphen_in_path: str, *, client: AuthenticatedClient | Client, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: hyphen_in_path (str): diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/naming/mixed_case.py b/end_to_end_tests/golden-record/my_test_api_client/api/naming/mixed_case.py index 78c119a3b..0d670cbd7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/naming/mixed_case.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/naming/mixed_case.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -8,6 +8,8 @@ from ...models.mixed_case_response_200 import MixedCaseResponse200 from ...types import UNSET, Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -45,7 +47,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[MixedCaseResponse200]: +) -> Response[MixedCaseResponse200, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -59,7 +61,7 @@ def sync_detailed( client: AuthenticatedClient | Client, mixed_case: str, mixedCase: str, -) -> Response[MixedCaseResponse200]: +) -> Response[MixedCaseResponse200, HTTPStatus]: """ Args: mixed_case (str): @@ -116,7 +118,7 @@ async def asyncio_detailed( client: AuthenticatedClient | Client, mixed_case: str, mixedCase: str, -) -> Response[MixedCaseResponse200]: +) -> Response[MixedCaseResponse200, HTTPStatus]: """ Args: mixed_case (str): diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py b/end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py index 9e848f7af..8a2705184 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -11,6 +11,8 @@ ) from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -48,7 +50,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[PostNamingPropertyConflictWithImportResponse200]: +) -> Response[PostNamingPropertyConflictWithImportResponse200, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -61,7 +63,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: PostNamingPropertyConflictWithImportBody | Unset = UNSET, -) -> Response[PostNamingPropertyConflictWithImportResponse200]: +) -> Response[PostNamingPropertyConflictWithImportResponse200, HTTPStatus]: """ Args: body (PostNamingPropertyConflictWithImportBody | Unset): @@ -112,7 +114,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: PostNamingPropertyConflictWithImportBody | Unset = UNSET, -) -> Response[PostNamingPropertyConflictWithImportResponse200]: +) -> Response[PostNamingPropertyConflictWithImportResponse200, HTTPStatus]: """ Args: body (PostNamingPropertyConflictWithImportBody | Unset): 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 801929db9..5e904db64 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any from urllib.parse import quote @@ -8,6 +8,8 @@ from ...client import AuthenticatedClient, Client from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( path_param: str, @@ -56,7 +58,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -73,7 +75,7 @@ def sync_detailed( integer_param: int | Unset = 0, header_param: None | str | Unset = UNSET, cookie_param: str | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Test different types of parameter references Args: @@ -114,7 +116,7 @@ async def asyncio_detailed( integer_param: int | Unset = 0, header_param: None | str | Unset = UNSET, cookie_param: str | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Test different types of parameter references Args: 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 1415a8cb4..626f2e5dc 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any from urllib.parse import quote @@ -8,6 +8,8 @@ from ...client import AuthenticatedClient, Client from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( param_path: str, @@ -41,7 +43,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -55,7 +57,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, param_query: str | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: param_path (str): @@ -86,7 +88,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, param_query: str | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: param_path (str): 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 4f2c5056f..dd0932061 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any from urllib.parse import quote @@ -8,6 +8,8 @@ from ...client import AuthenticatedClient, Client from ...types import UNSET, Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( param_path: str, @@ -41,7 +43,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -55,7 +57,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, param_query: str = "overridden_in_GET", -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code Args: @@ -88,7 +90,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, param_query: str = "overridden_in_GET", -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code Args: 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 dd11f68ca..98f5f7ed5 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any from urllib.parse import quote @@ -8,6 +8,8 @@ from ...client import AuthenticatedClient, Client from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( param_path: str, @@ -53,7 +55,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -69,7 +71,7 @@ def sync_detailed( param_query: str | Unset = UNSET, param_header: str | Unset = UNSET, param_cookie: str | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: param_path (str): @@ -106,7 +108,7 @@ async def asyncio_detailed( param_query: str | Unset = UNSET, param_header: str | Unset = UNSET, param_cookie: str | Unset = UNSET, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: param_path (str): 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 3b11674f5..d0cfa17ea 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any from urllib.parse import quote @@ -8,6 +8,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( param4: str, @@ -38,7 +40,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -54,7 +56,7 @@ def sync_detailed( param3: int, *, client: AuthenticatedClient | Client, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: param4 (str): @@ -91,7 +93,7 @@ async def asyncio_detailed( param3: int, *, client: AuthenticatedClient | Client, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: param4 (str): diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/default_status_code.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/default_status_code.py index f2af5e3b3..f38a91b2d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/default_status_code.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/default_status_code.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -6,6 +6,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -21,7 +23,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return response_default -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[str]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[str, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -33,7 +35,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[str]: +) -> Response[str, HTTPStatus]: """Default Status Code Only Raises: @@ -75,7 +77,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[str]: +) -> Response[str, HTTPStatus]: """Default Status Code Only Raises: 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 1b098950e..6bf9abb52 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -10,6 +10,8 @@ ) from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -36,7 +38,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: +) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -48,7 +50,7 @@ def _build_response( def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: +) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200, HTTPStatus]: """Regression test for #603 Raises: @@ -90,7 +92,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: +) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200, HTTPStatus]: """Regression test for #603 Raises: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/reference_response.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/reference_response.py index 4e96030ae..c564002bc 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/reference_response.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/reference_response.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -8,6 +8,8 @@ from ...models.a_model import AModel from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -30,7 +32,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[AModel]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[AModel, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -42,7 +44,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[AModel]: +) -> Response[AModel, HTTPStatus]: """Endpoint using predefined response Raises: @@ -84,7 +86,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[AModel]: +) -> Response[AModel, HTTPStatus]: """Endpoint using predefined response Raises: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/status_code_patterns.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/status_code_patterns.py index 4e3d501d4..7f902c937 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/status_code_patterns.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/status_code_patterns.py @@ -1,4 +1,3 @@ -from http import HTTPStatus from typing import Any import httpx @@ -9,6 +8,8 @@ from ...models.status_code_patterns_response_4xx import StatusCodePatternsResponse4XX from ...types import Response +HTTPStatus = int + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -40,7 +41,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[StatusCodePatternsResponse2XX | StatusCodePatternsResponse4XX]: +) -> Response[StatusCodePatternsResponse2XX | StatusCodePatternsResponse4XX, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,7 +53,7 @@ def _build_response( def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[StatusCodePatternsResponse2XX | StatusCodePatternsResponse4XX]: +) -> Response[StatusCodePatternsResponse2XX | StatusCodePatternsResponse4XX, HTTPStatus]: """Status Code Patterns Raises: @@ -94,7 +95,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[StatusCodePatternsResponse2XX | StatusCodePatternsResponse4XX]: +) -> Response[StatusCodePatternsResponse2XX | StatusCodePatternsResponse4XX, HTTPStatus]: """Status Code Patterns Raises: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/status_code_precedence.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/status_code_precedence.py index 9f86c2997..5f8cc2817 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/status_code_precedence.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/status_code_precedence.py @@ -1,4 +1,3 @@ -from http import HTTPStatus from typing import Any import httpx @@ -6,6 +5,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = int + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -33,7 +34,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return response_default -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[str]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[str, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -45,7 +46,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[str]: +) -> Response[str, HTTPStatus]: """Status Codes Precedence Verify that specific status codes are always checked first, then ranges, then default @@ -91,7 +92,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[str]: +) -> Response[str, HTTPStatus]: """Status Codes Precedence Verify that specific status codes are always checked first, then ranges, then default diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/text_response.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/text_response.py index 978ad84d1..788a7e378 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/text_response.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/text_response.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -28,7 +30,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[str]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[str, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -40,7 +42,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[str]: +) -> Response[str, HTTPStatus]: """Text Response Raises: @@ -82,7 +84,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[str]: +) -> Response[str, HTTPStatus]: """Text Response Raises: 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 f2c767fa3..a98af7c40 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -27,7 +29,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -39,7 +41,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -61,7 +63,7 @@ def sync_detailed( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tag2/get_tag_with_number.py b/end_to_end_tests/golden-record/my_test_api_client/api/tag2/get_tag_with_number.py index f2c767fa3..a98af7c40 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tag2/get_tag_with_number.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tag2/get_tag_with_number.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -27,7 +29,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -39,7 +41,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -61,7 +63,7 @@ def sync_detailed( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. 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 e806fe60c..b02ed8146 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -9,6 +9,8 @@ from ...models.http_validation_error import HTTPValidationError from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -49,7 +51,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[Any | HTTPValidationError]: +) -> Response[Any | HTTPValidationError, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -62,7 +64,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: AModel, -) -> Response[Any | HTTPValidationError]: +) -> Response[Any | HTTPValidationError, HTTPStatus]: """Path with callback Try sending a request related to a callback @@ -119,7 +121,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: AModel, -) -> Response[Any | HTTPValidationError]: +) -> Response[Any | HTTPValidationError, HTTPStatus]: """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/description_with_backslash.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py index f33456e97..805fb149f 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -27,7 +29,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -39,7 +41,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: r""" Test description with \ Test description with \ @@ -64,7 +66,7 @@ def sync_detailed( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: r""" Test description with \ Test description with \ 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 08ddea77d..f9b9cd44c 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any, cast import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -29,7 +31,9 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[bool]]: +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[bool], HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -41,7 +45,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[list[bool]]: +) -> Response[list[bool], HTTPStatus]: """Get Basic List Of Booleans Get a list of booleans @@ -87,7 +91,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[list[bool]]: +) -> Response[list[bool], HTTPStatus]: """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 35310a218..a03f37376 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any, cast import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -29,7 +31,9 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[float]]: +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[float], HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -41,7 +45,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[list[float]]: +) -> Response[list[float], HTTPStatus]: """Get Basic List Of Floats Get a list of floats @@ -87,7 +91,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[list[float]]: +) -> Response[list[float], HTTPStatus]: """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 2f0526e41..aa1e23d7e 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any, cast import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -29,7 +31,9 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[int]]: +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[int], HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -41,7 +45,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[list[int]]: +) -> Response[list[int], HTTPStatus]: """Get Basic List Of Integers Get a list of integers @@ -87,7 +91,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[list[int]]: +) -> Response[list[int], HTTPStatus]: """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 a4b401eb2..3864855de 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any, cast import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -29,7 +31,9 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[str]]: +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[str], HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -41,7 +45,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[list[str]]: +) -> Response[list[str], HTTPStatus]: """Get Basic List Of Strings Get a list of strings @@ -87,7 +91,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[list[str]]: +) -> Response[list[str], HTTPStatus]: """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 5d027ecd7..14618bfd7 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,5 +1,5 @@ import datetime -from http import HTTPStatus +import http from typing import Any import httpx @@ -12,6 +12,8 @@ from ...models.http_validation_error import HTTPValidationError from ...types import UNSET, Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -94,7 +96,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | list[AModel]]: +) -> Response[HTTPValidationError | list[AModel], HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -110,7 +112,7 @@ def sync_detailed( an_enum_value_with_null: list[AnEnumWithNull | None], an_enum_value_with_only_null: list[None], some_date: datetime.date | datetime.datetime, -) -> Response[HTTPValidationError | list[AModel]]: +) -> Response[HTTPValidationError | list[AModel], HTTPStatus]: """Get List Get a list of things @@ -185,7 +187,7 @@ async def asyncio_detailed( an_enum_value_with_null: list[AnEnumWithNull | None], an_enum_value_with_only_null: list[None], some_date: datetime.date | datetime.datetime, -) -> Response[HTTPValidationError | list[AModel]]: +) -> Response[HTTPValidationError | list[AModel], HTTPStatus]: """Get List Get a list of things 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 5be950c77..317b4be1d 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -9,6 +9,8 @@ from ...models.http_validation_error import HTTPValidationError from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -49,7 +51,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[Any | HTTPValidationError]: +) -> Response[Any | HTTPValidationError, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -62,7 +64,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: AModel, -) -> Response[Any | HTTPValidationError]: +) -> Response[Any | HTTPValidationError, HTTPStatus]: """Json Body Try sending a JSON body @@ -119,7 +121,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: AModel, -) -> Response[Any | HTTPValidationError]: +) -> Response[Any | HTTPValidationError, HTTPStatus]: """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 59c746613..8def40ce2 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -27,7 +29,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -39,7 +41,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """No Response Raises: @@ -62,7 +64,7 @@ def sync_detailed( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """No Response Raises: 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 36fab061c..0b55aae3c 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,4 +1,4 @@ -from http import HTTPStatus +import http from io import BytesIO from typing import Any @@ -8,6 +8,8 @@ from ...client import AuthenticatedClient, Client from ...types import File, Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -30,7 +32,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[File]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[File, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -42,7 +44,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[File]: +) -> Response[File, HTTPStatus]: """Octet Stream Raises: @@ -84,7 +86,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[File]: +) -> Response[File, HTTPStatus]: """Octet Stream Raises: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py index 0d140359d..6714eaf38 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -9,6 +9,8 @@ from ...models.octet_stream_tests_octet_stream_post_response_200 import OctetStreamTestsOctetStreamPostResponse200 from ...types import UNSET, File, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -51,7 +53,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | OctetStreamTestsOctetStreamPostResponse200]: +) -> Response[HTTPValidationError | OctetStreamTestsOctetStreamPostResponse200, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -64,7 +66,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: File | Unset = UNSET, -) -> Response[HTTPValidationError | OctetStreamTestsOctetStreamPostResponse200]: +) -> Response[HTTPValidationError | OctetStreamTestsOctetStreamPostResponse200, HTTPStatus]: """Binary (octet stream) request body Args: @@ -117,7 +119,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: File | Unset = UNSET, -) -> Response[HTTPValidationError | OctetStreamTestsOctetStreamPostResponse200]: +) -> Response[HTTPValidationError | OctetStreamTestsOctetStreamPostResponse200, HTTPStatus]: """Binary (octet stream) request body Args: 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 82f464276..6de4ac510 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -8,6 +8,8 @@ from ...models.a_form_data import AFormData from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -38,7 +40,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -51,7 +53,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: AFormData, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Post form data Post form data @@ -82,7 +84,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: AFormData, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Post form data Post 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 e15881947..efa29301d 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -8,6 +8,8 @@ from ...models.post_form_data_inline_body import PostFormDataInlineBody from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -38,7 +40,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -51,7 +53,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: PostFormDataInlineBody, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Post form data (inline schema) Post form data (inline schema) @@ -82,7 +84,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: PostFormDataInlineBody, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Post form data (inline schema) Post form data (inline schema) 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 498d0572e..8d3f9813f 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any, cast import httpx @@ -8,6 +8,8 @@ from ...models.http_validation_error import HTTPValidationError from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -48,7 +50,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | str]: +) -> Response[HTTPValidationError | str, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -61,7 +63,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: str, -) -> Response[HTTPValidationError | str]: +) -> Response[HTTPValidationError | str, HTTPStatus]: """Json Body Which is String Args: @@ -114,7 +116,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: str, -) -> Response[HTTPValidationError | str]: +) -> Response[HTTPValidationError | str, HTTPStatus]: """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 ea2e45c94..7e670c881 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -9,6 +9,8 @@ from ...models.test_inline_objects_response_200 import TestInlineObjectsResponse200 from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -45,7 +47,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[TestInlineObjectsResponse200]: +) -> Response[TestInlineObjectsResponse200, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -58,7 +60,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: TestInlineObjectsBody, -) -> Response[TestInlineObjectsResponse200]: +) -> Response[TestInlineObjectsResponse200, HTTPStatus]: """Test Inline Objects Args: @@ -111,7 +113,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: TestInlineObjectsBody, -) -> Response[TestInlineObjectsResponse200]: +) -> Response[TestInlineObjectsResponse200, HTTPStatus]: """Test Inline Objects Args: 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 0c7f73b45..52572f23a 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -37,7 +39,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -50,7 +52,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, my_token: str, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """TOKEN_WITH_COOKIE Test optional cookie parameters @@ -81,7 +83,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, my_token: str, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """TOKEN_WITH_COOKIE Test optional cookie parameters 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 794c38b98..f2ae33498 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -27,7 +29,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -39,7 +41,7 @@ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Res def sync_detailed( *, client: AuthenticatedClient | Client, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Unsupported Content Raises: @@ -62,7 +64,7 @@ def sync_detailed( async def asyncio_detailed( *, client: AuthenticatedClient | Client, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Unsupported Content Raises: 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 7498e9aee..abd778d1e 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -9,6 +9,8 @@ from ...models.http_validation_error import HTTPValidationError from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -47,7 +49,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[Any | HTTPValidationError]: +) -> Response[Any | HTTPValidationError, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -60,7 +62,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: BodyUploadFileTestsUploadPost, -) -> Response[Any | HTTPValidationError]: +) -> Response[Any | HTTPValidationError, HTTPStatus]: """Upload File Upload a file @@ -117,7 +119,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: BodyUploadFileTestsUploadPost, -) -> Response[Any | HTTPValidationError]: +) -> Response[Any | HTTPValidationError, HTTPStatus]: """Upload File Upload a file 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 825672fbd..76fa611b8 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,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import UNSET, Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -37,7 +39,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -50,7 +52,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, import_: str, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: import_ (str): @@ -78,7 +80,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, import_: str, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """ Args: import_ (str): 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 b64af0952..02e376a68 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 @@ -39,13 +39,14 @@ def to_tuple(self) -> FileTypes: T = TypeVar("T") +S = TypeVar("S", bound=HTTPStatus | int) @define -class Response(Generic[T]): +class Response(Generic[T, S]): """A response from an endpoint""" - status_code: HTTPStatus + status_code: S content: bytes headers: MutableMapping[str, str] parsed: T | None diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/bool_enum_tests_bool_enum_post.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/bool_enum_tests_bool_enum_post.py index 4ed5ff6ee..4270b5178 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/bool_enum_tests_bool_enum_post.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/bool_enum_tests_bool_enum_post.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -7,6 +7,8 @@ from ...client import AuthenticatedClient, Client from ...types import UNSET, Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -37,7 +39,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -50,7 +52,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, bool_enum: bool, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Bool Enum Args: @@ -79,7 +81,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, bool_enum: bool, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Bool Enum Args: diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/int_enum_tests_int_enum_post.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/int_enum_tests_int_enum_post.py index bdec57bf1..88cdd679c 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/int_enum_tests_int_enum_post.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/int_enum_tests_int_enum_post.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -8,6 +8,8 @@ from ...models.an_int_enum import AnIntEnum from ...types import UNSET, Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -39,7 +41,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,7 +54,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, int_enum: AnIntEnum, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Int Enum Args: @@ -81,7 +83,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, int_enum: AnIntEnum, -) -> Response[Any]: +) -> Response[Any, HTTPStatus]: """Int Enum Args: diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/get_user_list.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/get_user_list.py index 15b821528..4dc0a53ac 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/get_user_list.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/get_user_list.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -9,11 +9,11 @@ from ...models.an_enum import AnEnum from ...models.an_enum_with_null import AnEnumWithNull from ...models.get_user_list_int_enum_header import GetUserListIntEnumHeader -from ...models.get_user_list_string_enum_header import ( - GetUserListStringEnumHeader, -) +from ...models.get_user_list_string_enum_header import GetUserListStringEnumHeader from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -83,7 +83,9 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[AModel]]: +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[AModel], HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -100,7 +102,7 @@ def sync_detailed( an_enum_value_with_only_null: list[None], int_enum_header: GetUserListIntEnumHeader | Unset = UNSET, string_enum_header: GetUserListStringEnumHeader | Unset = UNSET, -) -> Response[list[AModel]]: +) -> Response[list[AModel], HTTPStatus]: """Get List Get a list of things @@ -181,7 +183,7 @@ async def asyncio_detailed( an_enum_value_with_only_null: list[None], int_enum_header: GetUserListIntEnumHeader | Unset = UNSET, string_enum_header: GetUserListStringEnumHeader | Unset = UNSET, -) -> Response[list[AModel]]: +) -> Response[list[AModel], HTTPStatus]: """Get List Get a list of things diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/post_user_list.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/post_user_list.py index 920c35f78..53c7f6b7a 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/post_user_list.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/post_user_list.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -9,6 +9,8 @@ from ...models.post_user_list_body import PostUserListBody from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -45,7 +47,9 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[AModel]]: +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[AModel], HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -58,7 +62,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: PostUserListBody | Unset = UNSET, -) -> Response[list[AModel]]: +) -> Response[list[AModel], HTTPStatus]: """Post List Post a list of things @@ -115,7 +119,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: PostUserListBody | Unset = UNSET, -) -> Response[list[AModel]]: +) -> Response[list[AModel], HTTPStatus]: """Post List Post a list of things diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/types.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/types.py index b64af0952..02e376a68 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/types.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/types.py @@ -39,13 +39,14 @@ def to_tuple(self) -> FileTypes: T = TypeVar("T") +S = TypeVar("S", bound=HTTPStatus | int) @define -class Response(Generic[T]): +class Response(Generic[T, S]): """A response from an endpoint""" - status_code: HTTPStatus + status_code: S content: bytes headers: MutableMapping[str, str] parsed: T | None diff --git a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/const/post_const_path.py b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/const/post_const_path.py index bf3472121..7d51b8055 100644 --- a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/const/post_const_path.py +++ b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/const/post_const_path.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any, Literal, cast from urllib.parse import quote @@ -9,6 +9,8 @@ from ...models.post_const_path_body import PostConstPathBody from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( path: Literal["this goes in the path"], @@ -62,7 +64,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[Literal["Why have a fixed response? I dunno"]]: +) -> Response[Literal["Why have a fixed response? I dunno"], HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -78,7 +80,7 @@ def sync_detailed( body: PostConstPathBody, required_query: Literal["this always goes in the query"], optional_query: Literal["this sometimes goes in the query"] | Unset = UNSET, -) -> Response[Literal["Why have a fixed response? I dunno"]]: +) -> Response[Literal["Why have a fixed response? I dunno"], HTTPStatus]: """ Args: path (Literal['this goes in the path']): @@ -147,7 +149,7 @@ async def asyncio_detailed( body: PostConstPathBody, required_query: Literal["this always goes in the query"], optional_query: Literal["this sometimes goes in the query"] | Unset = UNSET, -) -> Response[Literal["Why have a fixed response? I dunno"]]: +) -> Response[Literal["Why have a fixed response? I dunno"], HTTPStatus]: """ Args: path (Literal['this goes in the path']): diff --git a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/prefix_items/post_prefix_items.py b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/prefix_items/post_prefix_items.py index 5b114873e..ee4ef6eb7 100644 --- a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/prefix_items/post_prefix_items.py +++ b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/prefix_items/post_prefix_items.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any, cast import httpx @@ -8,6 +8,8 @@ from ...models.post_prefix_items_body import PostPrefixItemsBody from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -39,7 +41,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[str]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[str, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,7 +54,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: PostPrefixItemsBody, -) -> Response[str]: +) -> Response[str, HTTPStatus]: """ Args: body (PostPrefixItemsBody): @@ -103,7 +105,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: PostPrefixItemsBody, -) -> Response[str]: +) -> Response[str, HTTPStatus]: """ Args: body (PostPrefixItemsBody): diff --git a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/types.py b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/types.py index b64af0952..02e376a68 100644 --- a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/types.py +++ b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/types.py @@ -39,13 +39,14 @@ def to_tuple(self) -> FileTypes: T = TypeVar("T") +S = TypeVar("S", bound=HTTPStatus | int) @define -class Response(Generic[T]): +class Response(Generic[T, S]): """A response from an endpoint""" - status_code: HTTPStatus + status_code: S content: bytes headers: MutableMapping[str, str] parsed: T | None diff --git a/integration-tests/integration_tests/api/body/post_body_multipart.py b/integration-tests/integration_tests/api/body/post_body_multipart.py index 58c217231..4337eee8b 100644 --- a/integration-tests/integration_tests/api/body/post_body_multipart.py +++ b/integration-tests/integration_tests/api/body/post_body_multipart.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -10,6 +10,8 @@ from ...models.public_error import PublicError from ...types import UNSET, Response, Unset +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -50,7 +52,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[PostBodyMultipartResponse200 | PublicError]: +) -> Response[PostBodyMultipartResponse200 | PublicError, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -63,7 +65,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: PostBodyMultipartBody | Unset = UNSET, -) -> Response[PostBodyMultipartResponse200 | PublicError]: +) -> Response[PostBodyMultipartResponse200 | PublicError, HTTPStatus]: """ Args: body (PostBodyMultipartBody | Unset): @@ -114,7 +116,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: PostBodyMultipartBody | Unset = UNSET, -) -> Response[PostBodyMultipartResponse200 | PublicError]: +) -> Response[PostBodyMultipartResponse200 | PublicError, HTTPStatus]: """ Args: body (PostBodyMultipartBody | Unset): diff --git a/integration-tests/integration_tests/api/parameters/post_parameters_header.py b/integration-tests/integration_tests/api/parameters/post_parameters_header.py index 190b7efe0..b6b09565d 100644 --- a/integration-tests/integration_tests/api/parameters/post_parameters_header.py +++ b/integration-tests/integration_tests/api/parameters/post_parameters_header.py @@ -1,4 +1,4 @@ -from http import HTTPStatus +import http from typing import Any import httpx @@ -9,6 +9,8 @@ from ...models.public_error import PublicError from ...types import Response +HTTPStatus = http.HTTPStatus + def _get_kwargs( *, @@ -56,7 +58,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[PostParametersHeaderResponse200 | PublicError]: +) -> Response[PostParametersHeaderResponse200 | PublicError, HTTPStatus]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -72,7 +74,7 @@ def sync_detailed( string_header: str, number_header: float, integer_header: int, -) -> Response[PostParametersHeaderResponse200 | PublicError]: +) -> Response[PostParametersHeaderResponse200 | PublicError, HTTPStatus]: """ Args: boolean_header (bool): @@ -141,7 +143,7 @@ async def asyncio_detailed( string_header: str, number_header: float, integer_header: int, -) -> Response[PostParametersHeaderResponse200 | PublicError]: +) -> Response[PostParametersHeaderResponse200 | PublicError, HTTPStatus]: """ Args: boolean_header (bool): diff --git a/integration-tests/integration_tests/types.py b/integration-tests/integration_tests/types.py index b64af0952..02e376a68 100644 --- a/integration-tests/integration_tests/types.py +++ b/integration-tests/integration_tests/types.py @@ -39,13 +39,14 @@ def to_tuple(self) -> FileTypes: T = TypeVar("T") +S = TypeVar("S", bound=HTTPStatus | int) @define -class Response(Generic[T]): +class Response(Generic[T, S]): """A response from an endpoint""" - status_code: HTTPStatus + status_code: S content: bytes headers: MutableMapping[str, str] parsed: T | None diff --git a/integration-tests/tests/test_api/test_body/test_post_body_multipart.py b/integration-tests/tests/test_api/test_body/test_post_body_multipart.py index d6c211daf..653ebbf07 100644 --- a/integration-tests/tests/test_api/test_body/test_post_body_multipart.py +++ b/integration-tests/tests/test_api/test_body/test_post_body_multipart.py @@ -1,4 +1,5 @@ from datetime import datetime, timedelta, timezone +from http import HTTPStatus from io import BytesIO from typing import Any @@ -40,7 +41,7 @@ ) -def check_response(response: Response[PostBodyMultipartResponse200 | PublicError]) -> None: +def check_response(response: Response[PostBodyMultipartResponse200 | PublicError, HTTPStatus]) -> None: content = response.parsed if not isinstance(content, PostBodyMultipartResponse200): raise AssertionError(f"Received status {response.status_code} from test server with payload: {content!r}") From e74ca6dd8d2bee5717a150f14e4b8a47b97b3f70 Mon Sep 17 00:00:00 2001 From: Ykrej Date: Thu, 26 Feb 2026 21:42:27 -0800 Subject: [PATCH 3/8] test: added non standard exit code e2e test --- end_to_end_tests/baseline_openapi_3.0.json | 21 +++++ end_to_end_tests/baseline_openapi_3.1.yaml | 21 +++++ .../my_test_api_client/api/tests/__init__.py | 8 ++ .../api/tests/nonstandard_response_code.py | 91 +++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 end_to_end_tests/golden-record/my_test_api_client/api/tests/nonstandard_response_code.py diff --git a/end_to_end_tests/baseline_openapi_3.0.json b/end_to_end_tests/baseline_openapi_3.0.json index c47048218..e075c1b00 100644 --- a/end_to_end_tests/baseline_openapi_3.0.json +++ b/end_to_end_tests/baseline_openapi_3.0.json @@ -1736,6 +1736,27 @@ } } }, + "/tests/nonstandard-response-code": { + "get": { + "tags": [ + "tests" + ], + "summary": "Test nonstandard response code", + "description": "Test endpoint with nonstandard response code", + "operationId": "nonstandard_response_code", + "responses": { + "200": { + "description": "Successful response" + }, + "499": { + "description": "Nonstandard response code" + }, + "99999": { + "description": "Nonstandard response code" + } + } + } + }, "/config/content-type-override": { "post": { "tags": [ diff --git a/end_to_end_tests/baseline_openapi_3.1.yaml b/end_to_end_tests/baseline_openapi_3.1.yaml index 295e6818a..11b5a307b 100644 --- a/end_to_end_tests/baseline_openapi_3.1.yaml +++ b/end_to_end_tests/baseline_openapi_3.1.yaml @@ -1706,6 +1706,27 @@ info: } } }, + "/tests/nonstandard-response-code": { + "get": { + "tags": [ + "tests" + ], + "summary": "Test nonstandard response code", + "description": "Test endpoint with nonstandard response code", + "operationId": "nonstandard_response_code", + "responses": { + "200": { + "description": "Successful response" + }, + "499": { + "description": "Nonstandard response code" + }, + "99999": { + "description": "Nonstandard response code" + } + } + } + }, "/config/content-type-override": { "post": { "tags": [ 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/api/tests/__init__.py index d7ef5cd7c..af0d9cc00 100644 --- 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/api/tests/__init__.py @@ -12,6 +12,7 @@ get_user_list, json_body_tests_json_body_post, no_response_tests_no_response_get, + nonstandard_response_code, octet_stream_tests_octet_stream_get, octet_stream_tests_octet_stream_post, post_form_data, @@ -150,3 +151,10 @@ def description_with_backslash(cls) -> types.ModuleType: Test description with \ """ return description_with_backslash + + @classmethod + def nonstandard_response_code(cls) -> types.ModuleType: + """ + Test endpoint with nonstandard response code + """ + return nonstandard_response_code diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/nonstandard_response_code.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/nonstandard_response_code.py new file mode 100644 index 000000000..013d6f2d8 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/nonstandard_response_code.py @@ -0,0 +1,91 @@ +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + +HTTPStatus = int + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/tests/nonstandard-response-code", + } + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | None: + if response.status_code == 200: + return None + + if response.status_code == 499: + return None + + if response.status_code == 99999: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[Any, HTTPStatus]: + """Test nonstandard response code + + Test endpoint with nonstandard response code + + 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] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[Any, HTTPStatus]: + """Test nonstandard response code + + Test endpoint with nonstandard response code + + 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] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) From 0f6409dda26760e71973ea85777495b7b4ef3e61 Mon Sep 17 00:00:00 2001 From: Ykrej Date: Thu, 26 Feb 2026 21:53:56 -0800 Subject: [PATCH 4/8] test: added unit test for HTTPStatusPattern.is_official --- tests/test_parser/test_responses.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_parser/test_responses.py b/tests/test_parser/test_responses.py index 6c0f60e2c..06d02f195 100644 --- a/tests/test_parser/test_responses.py +++ b/tests/test_parser/test_responses.py @@ -1,3 +1,4 @@ +from http import HTTPStatus from unittest.mock import MagicMock import pytest @@ -289,3 +290,21 @@ def test_http_status_pattern_lt(pattern1: str, pattern2: str, result: bool) -> N assert isinstance(first, HTTPStatusPattern) assert isinstance(second, HTTPStatusPattern) assert (first < second) == result + + +@pytest.mark.parametrize( + "pattern,result", + [ + (str(HTTPStatus.OK), True), + (str(HTTPStatus.NOT_FOUND), True), + (str(HTTPStatus.CONFLICT), True), + (str(HTTPStatus.INTERNAL_SERVER_ERROR), True), + ("2XX", False), + ("1", False), + ("99999", False), + ], +) +def test_http_status_pattern_is_official(pattern: str, result: bool) -> None: + parsed = HTTPStatusPattern.parse(pattern) + assert isinstance(parsed, HTTPStatusPattern) + assert parsed.is_official == result From 501a6e1d7bb6636b3d105343fea024ba96702d12 Mon Sep 17 00:00:00 2001 From: Ykrej Date: Thu, 26 Feb 2026 22:43:34 -0800 Subject: [PATCH 5/8] fix: disable nonstandard response code handling by default --- openapi_python_client/config.py | 3 +++ openapi_python_client/templates/endpoint_module.py.jinja | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/openapi_python_client/config.py b/openapi_python_client/config.py index 0cba32599..63c48d76b 100644 --- a/openapi_python_client/config.py +++ b/openapi_python_client/config.py @@ -46,6 +46,7 @@ class ConfigFile(BaseModel): generate_all_tags: bool = False http_timeout: int = 5 literal_enums: bool = False + allow_int_response_codes: bool = False @staticmethod def load_from_path(path: Path) -> "ConfigFile": @@ -81,6 +82,7 @@ class Config: content_type_overrides: dict[str, str] overwrite: bool output_path: Path | None + allow_int_response_codes: bool @staticmethod def from_sources( @@ -122,5 +124,6 @@ def from_sources( file_encoding=file_encoding, overwrite=overwrite, output_path=output_path, + allow_int_response_codes=config_file.allow_int_response_codes ) return config diff --git a/openapi_python_client/templates/endpoint_module.py.jinja b/openapi_python_client/templates/endpoint_module.py.jinja index 156a6e8a8..d60f69108 100644 --- a/openapi_python_client/templates/endpoint_module.py.jinja +++ b/openapi_python_client/templates/endpoint_module.py.jinja @@ -11,11 +11,12 @@ from ... import errors {{ relative }} {% endfor %} -{% if endpoint.responses|list|length == 0 or endpoint.responses|map(attribute="status_code")|map(attribute="is_official")|all %} +{% set all_standard_response_codes = endpoint.responses|map(attribute="status_code")|map(attribute="is_official")|all %} +{% if config.allow_int_response_codes and not all_standard_response_codes %} +HTTPStatus = int +{% else %} import http HTTPStatus = http.HTTPStatus -{% else %} -HTTPStatus = int {% endif %} {% from "endpoint_macros.py.jinja" import header_params, cookie_params, query_params, From 5e4d168f0d736d153e5f8044f7e299dcfac8b199 Mon Sep 17 00:00:00 2001 From: Ykrej Date: Thu, 26 Feb 2026 22:43:55 -0800 Subject: [PATCH 6/8] test: added enable nonstandard response code handling to e2e tests --- end_to_end_tests/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/end_to_end_tests/config.yml b/end_to_end_tests/config.yml index a813deddd..d445b9392 100644 --- a/end_to_end_tests/config.yml +++ b/end_to_end_tests/config.yml @@ -12,3 +12,4 @@ field_prefix: attr_ content_type_overrides: openapi/python/client: application/json generate_all_tags: true +allow_int_response_codes: true From c39b0eb2c45c61af0680ac17fcf7183e12ad58d3 Mon Sep 17 00:00:00 2001 From: Ykrej Date: Thu, 26 Feb 2026 22:56:30 -0800 Subject: [PATCH 7/8] docs: added .changeset --- .changeset/support_non_standard_http_codes.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .changeset/support_non_standard_http_codes.md diff --git a/.changeset/support_non_standard_http_codes.md b/.changeset/support_non_standard_http_codes.md new file mode 100644 index 000000000..0bb650151 --- /dev/null +++ b/.changeset/support_non_standard_http_codes.md @@ -0,0 +1,11 @@ +# Summary + +Added support for responses with non-standard HTTP Status Codes. Off by default, enabled with `allow_int_response_codes`. + +# Problem + +Currently if a response with a status code that does not exist in `http.HTTPStatusCode` a `ValueError` is raised. For example: `ValueError: 490 is not a valid HTTPStatus`. + +# Edge Case + +If a non-standard status code is received from an endpoint that doesn't define any responses with non-standard status codes the old behavior will appear. From eca78b1e970016afe37af22bcd2bcbb0591323af Mon Sep 17 00:00:00 2001 From: Ykrej Date: Thu, 26 Feb 2026 22:58:10 -0800 Subject: [PATCH 8/8] docs: added change type --- .changeset/support_non_standard_http_codes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.changeset/support_non_standard_http_codes.md b/.changeset/support_non_standard_http_codes.md index 0bb650151..4c7434863 100644 --- a/.changeset/support_non_standard_http_codes.md +++ b/.changeset/support_non_standard_http_codes.md @@ -1,3 +1,7 @@ +--- +default: minor +--- + # Summary Added support for responses with non-standard HTTP Status Codes. Off by default, enabled with `allow_int_response_codes`.