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..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,12 @@ 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: + 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..c4dcd7bd1454 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,10 @@ {{^isWildcard}} '{{code}}': {{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}}, {{/isWildcard}} + {{#isWildcard}} + {{#dataType}} + 'default': "{{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 08e47e909630..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,12 @@ 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: + 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..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,12 @@ 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: + 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..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,12 @@ 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: + 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_client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py index b6d774214042..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,12 @@ 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: + 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_client.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api_client.py index e2d924bfae3b..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,12 @@ 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: + 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_client.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/api_client.py index e2d924bfae3b..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,12 @@ 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: + 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_client.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api_client.py index ed93e2a2b472..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,12 @@ 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: + 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_client.py b/samples/openapi3/client/petstore/python/petstore_api/api_client.py index 30c054f2f194..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,12 @@ 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: + response_type = response_types_map['default'] + # deserialize response data response_text = None return_data = None