From 79d7e432d6e6cc44506cec9572af566848bc2878 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Wed, 15 Jul 2026 09:54:39 +0200 Subject: [PATCH 1/4] Support "default" responses in python client Update examples --- .../src/main/resources/python/api_client.mustache | 4 ++++ .../src/main/resources/python/partial_api.mustache | 3 +++ .../openapi_client/api_client.py | 4 ++++ .../echo_api/python/openapi_client/api_client.py | 4 ++++ .../legacy_model_dict_client/api_client.py | 4 ++++ .../python-aiohttp/petstore_api/api/default_api.py | 3 +++ .../python-aiohttp/petstore_api/api/user_api.py | 12 ++++++++++++ .../python-aiohttp/petstore_api/api_client.py | 4 ++++ .../petstore_api/api/default_api.py | 3 +++ .../python-httpx-sync/petstore_api/api/user_api.py | 12 ++++++++++++ .../python-httpx-sync/petstore_api/api_client.py | 4 ++++ .../python-httpx/petstore_api/api/default_api.py | 3 +++ .../python-httpx/petstore_api/api/user_api.py | 12 ++++++++++++ .../petstore/python-httpx/petstore_api/api_client.py | 4 ++++ .../petstore_api/api/default_api.py | 3 +++ .../python-lazyImports/petstore_api/api/user_api.py | 12 ++++++++++++ .../python-lazyImports/petstore_api/api_client.py | 4 ++++ .../petstore/python/petstore_api/api/default_api.py | 3 +++ .../petstore/python/petstore_api/api/user_api.py | 12 ++++++++++++ .../petstore/python/petstore_api/api_client.py | 4 ++++ 20 files changed, 114 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/python/api_client.mustache b/modules/openapi-generator/src/main/resources/python/api_client.mustache index a8c78e70e8db..2324d5650d62 100644 --- a/modules/openapi-generator/src/main/resources/python/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_client.mustache @@ -345,6 +345,10 @@ class ApiClient: # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + if not response_type and 'default' in response_types_map: + response_type = response_types_map['default'] + # deserialize response data response_text = None return_data = None diff --git a/modules/openapi-generator/src/main/resources/python/partial_api.mustache b/modules/openapi-generator/src/main/resources/python/partial_api.mustache index dd3a9a1fa12b..ce8b51b78f9b 100644 --- a/modules/openapi-generator/src/main/resources/python/partial_api.mustache +++ b/modules/openapi-generator/src/main/resources/python/partial_api.mustache @@ -48,5 +48,8 @@ {{^isWildcard}} '{{code}}': {{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}}, {{/isWildcard}} + {{#isWildcard}} + 'default': {{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}}, + {{/isWildcard}} {{/responses}} } \ No newline at end of file diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api_client.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api_client.py index 08e47e909630..0e966d4c93ae 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api_client.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api_client.py @@ -303,6 +303,10 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + if not response_type and 'default' in response_types_map: + response_type = response_types_map['default'] + # deserialize response data response_text = None return_data = None diff --git a/samples/client/echo_api/python/openapi_client/api_client.py b/samples/client/echo_api/python/openapi_client/api_client.py index 08e47e909630..0e966d4c93ae 100644 --- a/samples/client/echo_api/python/openapi_client/api_client.py +++ b/samples/client/echo_api/python/openapi_client/api_client.py @@ -303,6 +303,10 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + if not response_type and 'default' in response_types_map: + response_type = response_types_map['default'] + # deserialize response data response_text = None return_data = None diff --git a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/api_client.py b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/api_client.py index 9244ab41c5dd..b1222b7deb33 100644 --- a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/api_client.py +++ b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/api_client.py @@ -333,6 +333,10 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + if not response_type and 'default' in response_types_map: + response_type = response_types_map['default'] + # deserialize response data response_text = None return_data = None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py index 3210594cbd92..de0a0e9d83f5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py @@ -103,6 +103,7 @@ async def foo_get( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = await self.api_client.call_api( *_param, @@ -164,6 +165,7 @@ async def foo_get_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = await self.api_client.call_api( *_param, @@ -225,6 +227,7 @@ async def foo_get_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py index 1246baedd369..de9826704474 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py @@ -111,6 +111,7 @@ async def create_user( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -177,6 +178,7 @@ async def create_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -243,6 +245,7 @@ async def create_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -380,6 +383,7 @@ async def create_users_with_array_input( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -446,6 +450,7 @@ async def create_users_with_array_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -512,6 +517,7 @@ async def create_users_with_array_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -644,6 +650,7 @@ async def create_users_with_list_input( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -710,6 +717,7 @@ async def create_users_with_list_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -776,6 +784,7 @@ async def create_users_with_list_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -1710,6 +1719,7 @@ async def logout_user( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -1772,6 +1782,7 @@ async def logout_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -1834,6 +1845,7 @@ async def logout_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py index b6d774214042..6d91a5157b14 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py @@ -302,6 +302,10 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + if not response_type and 'default' in response_types_map: + response_type = response_types_map['default'] + # deserialize response data response_text = None return_data = None diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/default_api.py index cd63beb3a8cf..227cb6c9bf89 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/default_api.py @@ -85,6 +85,7 @@ async def foo_get( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = await self.api_client.call_api( *_param, @@ -146,6 +147,7 @@ async def foo_get_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = await self.api_client.call_api( *_param, @@ -207,6 +209,7 @@ async def foo_get_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/user_api.py index 85d34b6ebb62..9966f14783de 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/user_api.py @@ -93,6 +93,7 @@ async def create_user( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -159,6 +160,7 @@ async def create_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -225,6 +227,7 @@ async def create_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -464,6 +467,7 @@ async def create_users_with_array_input( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -530,6 +534,7 @@ async def create_users_with_array_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -596,6 +601,7 @@ async def create_users_with_array_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -830,6 +836,7 @@ async def create_users_with_list_input( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -896,6 +903,7 @@ async def create_users_with_list_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -962,6 +970,7 @@ async def create_users_with_list_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -2310,6 +2319,7 @@ async def logout_user( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -2372,6 +2382,7 @@ async def logout_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -2434,6 +2445,7 @@ async def logout_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api_client.py index e2d924bfae3b..cc30486f31af 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api_client.py @@ -305,6 +305,10 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + if not response_type and 'default' in response_types_map: + response_type = response_types_map['default'] + # deserialize response data response_text = None return_data = None diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/api/default_api.py index 13aec70c14ed..dc264f69428e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/api/default_api.py @@ -84,6 +84,7 @@ async def foo_get( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = await self.api_client.call_api( *_param, @@ -145,6 +146,7 @@ async def foo_get_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = await self.api_client.call_api( *_param, @@ -206,6 +208,7 @@ async def foo_get_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/api/user_api.py index 9e4ff6771db8..991c6540464c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/api/user_api.py @@ -92,6 +92,7 @@ async def create_user( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -158,6 +159,7 @@ async def create_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -224,6 +226,7 @@ async def create_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -361,6 +364,7 @@ async def create_users_with_array_input( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -427,6 +431,7 @@ async def create_users_with_array_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -493,6 +498,7 @@ async def create_users_with_array_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -625,6 +631,7 @@ async def create_users_with_list_input( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -691,6 +698,7 @@ async def create_users_with_list_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -757,6 +765,7 @@ async def create_users_with_list_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -1691,6 +1700,7 @@ async def logout_user( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -1753,6 +1763,7 @@ async def logout_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -1815,6 +1826,7 @@ async def logout_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/api_client.py index e2d924bfae3b..cc30486f31af 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/api_client.py @@ -305,6 +305,10 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + if not response_type and 'default' in response_types_map: + response_type = response_types_map['default'] + # deserialize response data response_text = None return_data = None diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/default_api.py index 5397a1872f14..25a038d2c23d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/default_api.py @@ -104,6 +104,7 @@ def foo_get( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = self.api_client.call_api( *_param, @@ -165,6 +166,7 @@ def foo_get_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = self.api_client.call_api( *_param, @@ -226,6 +228,7 @@ def foo_get_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/user_api.py index 59ce49f2f797..db19a3d35904 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/user_api.py @@ -112,6 +112,7 @@ def create_user( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -178,6 +179,7 @@ def create_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -244,6 +246,7 @@ def create_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -381,6 +384,7 @@ def create_users_with_array_input( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -447,6 +451,7 @@ def create_users_with_array_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -513,6 +518,7 @@ def create_users_with_array_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -645,6 +651,7 @@ def create_users_with_list_input( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -711,6 +718,7 @@ def create_users_with_list_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -777,6 +785,7 @@ def create_users_with_list_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -1711,6 +1720,7 @@ def logout_user( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -1773,6 +1783,7 @@ def logout_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -1835,6 +1846,7 @@ def logout_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api_client.py index ed93e2a2b472..562705363f79 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api_client.py @@ -302,6 +302,10 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + if not response_type and 'default' in response_types_map: + response_type = response_types_map['default'] + # deserialize response data response_text = None return_data = None diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py index 2d007b2f26d3..ce4db6893d28 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py @@ -84,6 +84,7 @@ def foo_get( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = self.api_client.call_api( *_param, @@ -145,6 +146,7 @@ def foo_get_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = self.api_client.call_api( *_param, @@ -206,6 +208,7 @@ def foo_get_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': "FooGetDefaultResponse", } response_data = self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py index be61d536e31c..d22c692a8c2c 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py @@ -92,6 +92,7 @@ def create_user( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -158,6 +159,7 @@ def create_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -224,6 +226,7 @@ def create_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -361,6 +364,7 @@ def create_users_with_array_input( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -427,6 +431,7 @@ def create_users_with_array_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -493,6 +498,7 @@ def create_users_with_array_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -625,6 +631,7 @@ def create_users_with_list_input( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -691,6 +698,7 @@ def create_users_with_list_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -757,6 +765,7 @@ def create_users_with_list_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -1691,6 +1700,7 @@ def logout_user( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -1753,6 +1763,7 @@ def logout_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, @@ -1815,6 +1826,7 @@ def logout_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { + 'default': None, } response_data = self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python/petstore_api/api_client.py b/samples/openapi3/client/petstore/python/petstore_api/api_client.py index 30c054f2f194..e4a196281c82 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api_client.py @@ -302,6 +302,10 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + if not response_type and 'default' in response_types_map: + response_type = response_types_map['default'] + # deserialize response data response_text = None return_data = None From edf2f1419ef189a743c0a6fb356dc0eae2406c51 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Wed, 15 Jul 2026 10:27:41 +0200 Subject: [PATCH 2/4] Address initial review comments --- .../src/main/resources/python/api_client.mustache | 5 +++-- .../src/main/resources/python/partial_api.mustache | 2 ++ .../openapi_client/api_client.py | 5 +++-- .../echo_api/python/openapi_client/api_client.py | 5 +++-- .../legacy_model_dict_client/api_client.py | 5 +++-- .../python-aiohttp/petstore_api/api/user_api.py | 12 ------------ .../python-aiohttp/petstore_api/api_client.py | 5 +++-- .../python-httpx-sync/petstore_api/api/user_api.py | 12 ------------ .../python-httpx-sync/petstore_api/api_client.py | 5 +++-- .../python-httpx/petstore_api/api/user_api.py | 12 ------------ .../petstore/python-httpx/petstore_api/api_client.py | 5 +++-- .../python-lazyImports/petstore_api/api/user_api.py | 12 ------------ .../python-lazyImports/petstore_api/api_client.py | 5 +++-- .../petstore/python/petstore_api/api/user_api.py | 12 ------------ .../petstore/python/petstore_api/api_client.py | 5 +++-- 15 files changed, 29 insertions(+), 78 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/api_client.mustache b/modules/openapi-generator/src/main/resources/python/api_client.mustache index 2324d5650d62..c4d44dec0c19 100644 --- a/modules/openapi-generator/src/main/resources/python/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_client.mustache @@ -345,8 +345,9 @@ class ApiClient: # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - - if not response_type and 'default' in response_types_map: + if response_type is None and str(response_data.status) not in response_types_map \ + and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ + and 'default' in response_types_map: response_type = response_types_map['default'] # deserialize response data diff --git a/modules/openapi-generator/src/main/resources/python/partial_api.mustache b/modules/openapi-generator/src/main/resources/python/partial_api.mustache index ce8b51b78f9b..6cc063eaedce 100644 --- a/modules/openapi-generator/src/main/resources/python/partial_api.mustache +++ b/modules/openapi-generator/src/main/resources/python/partial_api.mustache @@ -49,7 +49,9 @@ '{{code}}': {{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}}, {{/isWildcard}} {{#isWildcard}} + {{#dataType}} 'default': {{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}}, + {{/dataType}} {{/isWildcard}} {{/responses}} } \ No newline at end of file diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api_client.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api_client.py index 0e966d4c93ae..e9b124baddcc 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api_client.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api_client.py @@ -303,8 +303,9 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - - if not response_type and 'default' in response_types_map: + if response_type is None and str(response_data.status) not in response_types_map \ + and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ + and 'default' in response_types_map: response_type = response_types_map['default'] # deserialize response data diff --git a/samples/client/echo_api/python/openapi_client/api_client.py b/samples/client/echo_api/python/openapi_client/api_client.py index 0e966d4c93ae..e9b124baddcc 100644 --- a/samples/client/echo_api/python/openapi_client/api_client.py +++ b/samples/client/echo_api/python/openapi_client/api_client.py @@ -303,8 +303,9 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - - if not response_type and 'default' in response_types_map: + if response_type is None and str(response_data.status) not in response_types_map \ + and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ + and 'default' in response_types_map: response_type = response_types_map['default'] # deserialize response data diff --git a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/api_client.py b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/api_client.py index b1222b7deb33..89689d22cf4b 100644 --- a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/api_client.py +++ b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/api_client.py @@ -333,8 +333,9 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - - if not response_type and 'default' in response_types_map: + if response_type is None and str(response_data.status) not in response_types_map \ + and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ + and 'default' in response_types_map: response_type = response_types_map['default'] # deserialize response data diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py index de9826704474..1246baedd369 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py @@ -111,7 +111,6 @@ async def create_user( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -178,7 +177,6 @@ async def create_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -245,7 +243,6 @@ async def create_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -383,7 +380,6 @@ async def create_users_with_array_input( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -450,7 +446,6 @@ async def create_users_with_array_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -517,7 +512,6 @@ async def create_users_with_array_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -650,7 +644,6 @@ async def create_users_with_list_input( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -717,7 +710,6 @@ async def create_users_with_list_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -784,7 +776,6 @@ async def create_users_with_list_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -1719,7 +1710,6 @@ async def logout_user( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -1782,7 +1772,6 @@ async def logout_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -1845,7 +1834,6 @@ async def logout_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py index 6d91a5157b14..c586cb71d636 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py @@ -302,8 +302,9 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - - if not response_type and 'default' in response_types_map: + if response_type is None and str(response_data.status) not in response_types_map \ + and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ + and 'default' in response_types_map: response_type = response_types_map['default'] # deserialize response data diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/user_api.py index 9966f14783de..85d34b6ebb62 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/user_api.py @@ -93,7 +93,6 @@ async def create_user( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -160,7 +159,6 @@ async def create_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -227,7 +225,6 @@ async def create_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -467,7 +464,6 @@ async def create_users_with_array_input( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -534,7 +530,6 @@ async def create_users_with_array_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -601,7 +596,6 @@ async def create_users_with_array_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -836,7 +830,6 @@ async def create_users_with_list_input( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -903,7 +896,6 @@ async def create_users_with_list_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -970,7 +962,6 @@ async def create_users_with_list_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -2319,7 +2310,6 @@ async def logout_user( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -2382,7 +2372,6 @@ async def logout_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -2445,7 +2434,6 @@ async def logout_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api_client.py index cc30486f31af..335263ab7fcd 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api_client.py @@ -305,8 +305,9 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - - if not response_type and 'default' in response_types_map: + if response_type is None and str(response_data.status) not in response_types_map \ + and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ + and 'default' in response_types_map: response_type = response_types_map['default'] # deserialize response data diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/api/user_api.py index 991c6540464c..9e4ff6771db8 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/api/user_api.py @@ -92,7 +92,6 @@ async def create_user( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -159,7 +158,6 @@ async def create_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -226,7 +224,6 @@ async def create_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -364,7 +361,6 @@ async def create_users_with_array_input( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -431,7 +427,6 @@ async def create_users_with_array_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -498,7 +493,6 @@ async def create_users_with_array_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -631,7 +625,6 @@ async def create_users_with_list_input( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -698,7 +691,6 @@ async def create_users_with_list_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -765,7 +757,6 @@ async def create_users_with_list_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -1700,7 +1691,6 @@ async def logout_user( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -1763,7 +1753,6 @@ async def logout_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, @@ -1826,7 +1815,6 @@ async def logout_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/api_client.py index cc30486f31af..335263ab7fcd 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/api_client.py @@ -305,8 +305,9 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - - if not response_type and 'default' in response_types_map: + if response_type is None and str(response_data.status) not in response_types_map \ + and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ + and 'default' in response_types_map: response_type = response_types_map['default'] # deserialize response data diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/user_api.py index db19a3d35904..59ce49f2f797 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/user_api.py @@ -112,7 +112,6 @@ def create_user( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -179,7 +178,6 @@ def create_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -246,7 +244,6 @@ def create_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -384,7 +381,6 @@ def create_users_with_array_input( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -451,7 +447,6 @@ def create_users_with_array_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -518,7 +513,6 @@ def create_users_with_array_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -651,7 +645,6 @@ def create_users_with_list_input( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -718,7 +711,6 @@ def create_users_with_list_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -785,7 +777,6 @@ def create_users_with_list_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -1720,7 +1711,6 @@ def logout_user( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -1783,7 +1773,6 @@ def logout_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -1846,7 +1835,6 @@ def logout_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api_client.py index 562705363f79..87d778c8e4da 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api_client.py @@ -302,8 +302,9 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - - if not response_type and 'default' in response_types_map: + if response_type is None and str(response_data.status) not in response_types_map \ + and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ + and 'default' in response_types_map: response_type = response_types_map['default'] # deserialize response data diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py index d22c692a8c2c..be61d536e31c 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py @@ -92,7 +92,6 @@ def create_user( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -159,7 +158,6 @@ def create_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -226,7 +224,6 @@ def create_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -364,7 +361,6 @@ def create_users_with_array_input( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -431,7 +427,6 @@ def create_users_with_array_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -498,7 +493,6 @@ def create_users_with_array_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -631,7 +625,6 @@ def create_users_with_list_input( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -698,7 +691,6 @@ def create_users_with_list_input_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -765,7 +757,6 @@ def create_users_with_list_input_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -1700,7 +1691,6 @@ def logout_user( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -1763,7 +1753,6 @@ def logout_user_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, @@ -1826,7 +1815,6 @@ def logout_user_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - 'default': None, } response_data = self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python/petstore_api/api_client.py b/samples/openapi3/client/petstore/python/petstore_api/api_client.py index e4a196281c82..40bf44bceece 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api_client.py @@ -302,8 +302,9 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - - if not response_type and 'default' in response_types_map: + if response_type is None and str(response_data.status) not in response_types_map \ + and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ + and 'default' in response_types_map: response_type = response_types_map['default'] # deserialize response data From 7e7f07d71d14a1cde36d92d670356ab79606ac2d Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Thu, 16 Jul 2026 15:50:34 +0200 Subject: [PATCH 3/4] Clarified condition --- .../src/main/resources/python/api_client.mustache | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/openapi-generator/src/main/resources/python/api_client.mustache b/modules/openapi-generator/src/main/resources/python/api_client.mustache index c4d44dec0c19..861ac6d3af2c 100644 --- a/modules/openapi-generator/src/main/resources/python/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_client.mustache @@ -345,6 +345,7 @@ class ApiClient: # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + # If the response_type has not matched (eg. did not match the previous if statements) and the default response is available, use it. if response_type is None and str(response_data.status) not in response_types_map \ and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ and 'default' in response_types_map: From a450ff98ba6b6908e97f4c105c3686d08f163f80 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Thu, 16 Jul 2026 15:51:44 +0200 Subject: [PATCH 4/4] Update samples --- .../src/main/resources/python/partial_api.mustache | 2 +- .../openapi_client/api_client.py | 1 + samples/client/echo_api/python/openapi_client/api_client.py | 1 + .../legacy_model_dict_client/api_client.py | 1 + .../client/petstore/python-aiohttp/petstore_api/api_client.py | 1 + .../petstore/python-httpx-sync/petstore_api/api_client.py | 1 + .../client/petstore/python-httpx/petstore_api/api_client.py | 1 + .../petstore/python-lazyImports/petstore_api/api_client.py | 1 + .../openapi3/client/petstore/python/petstore_api/api_client.py | 1 + 9 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/python/partial_api.mustache b/modules/openapi-generator/src/main/resources/python/partial_api.mustache index 6cc063eaedce..c4dcd7bd1454 100644 --- a/modules/openapi-generator/src/main/resources/python/partial_api.mustache +++ b/modules/openapi-generator/src/main/resources/python/partial_api.mustache @@ -50,7 +50,7 @@ {{/isWildcard}} {{#isWildcard}} {{#dataType}} - 'default': {{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}}, + 'default': "{{dataType}}", {{/dataType}} {{/isWildcard}} {{/responses}} diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api_client.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api_client.py index e9b124baddcc..594ec0e5a703 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api_client.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api_client.py @@ -303,6 +303,7 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + # If the response_type has not matched (eg. did not match the previous if statements) and the default response is available, use it. if response_type is None and str(response_data.status) not in response_types_map \ and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ and 'default' in response_types_map: diff --git a/samples/client/echo_api/python/openapi_client/api_client.py b/samples/client/echo_api/python/openapi_client/api_client.py index e9b124baddcc..594ec0e5a703 100644 --- a/samples/client/echo_api/python/openapi_client/api_client.py +++ b/samples/client/echo_api/python/openapi_client/api_client.py @@ -303,6 +303,7 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + # If the response_type has not matched (eg. did not match the previous if statements) and the default response is available, use it. if response_type is None and str(response_data.status) not in response_types_map \ and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ and 'default' in response_types_map: diff --git a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/api_client.py b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/api_client.py index 89689d22cf4b..f306786e8066 100644 --- a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/api_client.py +++ b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/api_client.py @@ -333,6 +333,7 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + # If the response_type has not matched (eg. did not match the previous if statements) and the default response is available, use it. if response_type is None and str(response_data.status) not in response_types_map \ and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ and 'default' in response_types_map: diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py index c586cb71d636..f90151f6105b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py @@ -302,6 +302,7 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + # If the response_type has not matched (eg. did not match the previous if statements) and the default response is available, use it. if response_type is None and str(response_data.status) not in response_types_map \ and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ and 'default' in response_types_map: diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api_client.py index 335263ab7fcd..5fb082d86bc9 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api_client.py @@ -305,6 +305,7 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + # If the response_type has not matched (eg. did not match the previous if statements) and the default response is available, use it. if response_type is None and str(response_data.status) not in response_types_map \ and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ and 'default' in response_types_map: diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/api_client.py index 335263ab7fcd..5fb082d86bc9 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/api_client.py @@ -305,6 +305,7 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + # If the response_type has not matched (eg. did not match the previous if statements) and the default response is available, use it. if response_type is None and str(response_data.status) not in response_types_map \ and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ and 'default' in response_types_map: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api_client.py index 87d778c8e4da..a26ad3c644a2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api_client.py @@ -302,6 +302,7 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + # If the response_type has not matched (eg. did not match the previous if statements) and the default response is available, use it. if response_type is None and str(response_data.status) not in response_types_map \ and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ and 'default' in response_types_map: diff --git a/samples/openapi3/client/petstore/python/petstore_api/api_client.py b/samples/openapi3/client/petstore/python/petstore_api/api_client.py index 40bf44bceece..4a91fbc24248 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api_client.py @@ -302,6 +302,7 @@ def response_deserialize( # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + # If the response_type has not matched (eg. did not match the previous if statements) and the default response is available, use it. if response_type is None and str(response_data.status) not in response_types_map \ and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ and 'default' in response_types_map: