diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py index 9e43e738a..b092e529d 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 @@ -91,7 +91,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[PostResponsesUnionsSimpleBeforeComplexResponse200] + PostResponsesUnionsSimpleBeforeComplexResponse200 """ return sync_detailed( @@ -134,7 +134,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[PostResponsesUnionsSimpleBeforeComplexResponse200] + PostResponsesUnionsSimpleBeforeComplexResponse200 """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py index c68e64be7..34a238b2d 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 @@ -106,7 +106,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -163,7 +163,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py index 1e1e4beb1..414542116 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py @@ -219,7 +219,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -332,7 +332,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py index f36aa9a9a..266e5eb41 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 @@ -88,7 +88,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[bool]] + List[bool] """ return sync_detailed( @@ -135,7 +135,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[bool]] + List[bool] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py index cfc9fec4d..a1101a547 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 @@ -88,7 +88,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[float]] + List[float] """ return sync_detailed( @@ -135,7 +135,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[float]] + List[float] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py index ab31821b5..29627228c 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 @@ -88,7 +88,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[int]] + List[int] """ return sync_detailed( @@ -135,7 +135,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[int]] + List[int] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py index 4c62d518b..2c52de82b 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 @@ -88,7 +88,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[str]] + List[str] """ return sync_detailed( @@ -135,7 +135,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[str]] + List[str] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py index cf0c1c375..cef38f2ff 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 @@ -173,7 +173,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, List['AModel']]] + Union[HTTPValidationError, List['AModel']] """ return sync_detailed( @@ -248,7 +248,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, List['AModel']]] + Union[HTTPValidationError, List['AModel']] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py index d6777f84c..5a3ee4c7b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py @@ -107,7 +107,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -160,7 +160,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py index d977511d4..d482d0e3c 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 @@ -106,7 +106,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -163,7 +163,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py index a10ad95a7..68e0a7fd5 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 @@ -85,7 +85,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[File] + File """ return sync_detailed( @@ -128,7 +128,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[File] + File """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py index 7bd2c3b16..289eac03c 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 @@ -101,7 +101,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, str]] + Union[HTTPValidationError, str] """ return sync_detailed( @@ -154,7 +154,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, str]] + Union[HTTPValidationError, str] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py index 7e3baf769..f7ce0eda3 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 @@ -99,7 +99,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[TestInlineObjectsResponse200] + TestInlineObjectsResponse200 """ return sync_detailed( @@ -152,7 +152,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[TestInlineObjectsResponse200] + TestInlineObjectsResponse200 """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py index 8a49818fb..61f28a42e 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 @@ -106,7 +106,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -163,7 +163,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py index ff5d5132d..58c459a1d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py @@ -109,7 +109,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -166,7 +166,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( 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 0ef598a9d..9aaf6c388 100644 --- a/integration-tests/integration_tests/api/body/post_body_multipart.py +++ b/integration-tests/integration_tests/api/body/post_body_multipart.py @@ -106,7 +106,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[PostBodyMultipartResponse200, PublicError]] + Union[PostBodyMultipartResponse200, PublicError] """ return sync_detailed( @@ -157,7 +157,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[PostBodyMultipartResponse200, PublicError]] + Union[PostBodyMultipartResponse200, PublicError] """ return ( 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 04c1c93a3..4d881bd0f 100644 --- a/integration-tests/integration_tests/api/parameters/post_parameters_header.py +++ b/integration-tests/integration_tests/api/parameters/post_parameters_header.py @@ -128,7 +128,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[PostParametersHeaderResponse200, PublicError]] + Union[PostParametersHeaderResponse200, PublicError] """ return sync_detailed( @@ -197,7 +197,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[PostParametersHeaderResponse200, PublicError]] + Union[PostParametersHeaderResponse200, PublicError] """ return ( diff --git a/openapi_python_client/templates/endpoint_macros.py.jinja b/openapi_python_client/templates/endpoint_macros.py.jinja index fde2e018a..090796537 100644 --- a/openapi_python_client/templates/endpoint_macros.py.jinja +++ b/openapi_python_client/templates/endpoint_macros.py.jinja @@ -141,7 +141,7 @@ json_body=json_body, {% endfor %} {% endmacro %} -{% macro docstring_content(endpoint, return_string) %} +{% macro docstring_content(endpoint, return_string, is_detailed) %} {% if endpoint.summary %}{{ endpoint.summary | wordwrap(100)}} {% endif -%} @@ -165,9 +165,13 @@ Raises: httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: +{% if is_detailed %} Response[{{ return_string }}] +{% else %} + {{ return_string }} +{% endif %} {% endmacro %} -{% macro docstring(endpoint, return_string) %} -{{ safe_docstring(docstring_content(endpoint, return_string)) }} +{% macro docstring(endpoint, return_string, is_detailed) %} +{{ safe_docstring(docstring_content(endpoint, return_string, is_detailed)) }} {% endmacro %} diff --git a/openapi_python_client/templates/endpoint_module.py.jinja b/openapi_python_client/templates/endpoint_module.py.jinja index 3ea8991fb..a94c6f025 100644 --- a/openapi_python_client/templates/endpoint_module.py.jinja +++ b/openapi_python_client/templates/endpoint_module.py.jinja @@ -92,7 +92,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[{{ def sync_detailed( {{ arguments(endpoint) | indent(4) }} ) -> Response[{{ return_string }}]: - {{ docstring(endpoint, return_string) | indent(4) }} + {{ docstring(endpoint, return_string, is_detailed=true) | indent(4) }} kwargs = _get_kwargs( {{ kwargs(endpoint) }} @@ -109,7 +109,7 @@ def sync_detailed( def sync( {{ arguments(endpoint) | indent(4) }} ) -> Optional[{{ return_string }}]: - {{ docstring(endpoint, return_string) | indent(4) }} + {{ docstring(endpoint, return_string, is_detailed=false) | indent(4) }} return sync_detailed( {{ kwargs(endpoint) }} @@ -119,7 +119,7 @@ def sync( async def asyncio_detailed( {{ arguments(endpoint) | indent(4) }} ) -> Response[{{ return_string }}]: - {{ docstring(endpoint, return_string) | indent(4) }} + {{ docstring(endpoint, return_string, is_detailed=true) | indent(4) }} kwargs = _get_kwargs( {{ kwargs(endpoint) }} @@ -136,7 +136,7 @@ async def asyncio_detailed( async def asyncio( {{ arguments(endpoint) | indent(4) }} ) -> Optional[{{ return_string }}]: - {{ docstring(endpoint, return_string) | indent(4) }} + {{ docstring(endpoint, return_string, is_detailed=false) | indent(4) }} return (await asyncio_detailed( {{ kwargs(endpoint) }}