diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache index 7c566933a5c8..c1c3c934aa35 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache @@ -725,14 +725,14 @@ def deserialize_primitive(data, klass, path_to_item): # '7' -> 7.0 -> '7.0' != '7' raise ValueError('This is not a float') return converted_value - except (OverflowError, ValueError): + except (OverflowError, ValueError) as ex: # parse can raise OverflowError - raise ApiValueError( + six.raise_from(ApiValueError( "{0}Failed to parse {1} as {2}".format( additional_message, repr(data), get_py3_class_name(klass) ), path_to_item=path_to_item - ) + ), ex) def get_discriminator_class(model_class, @@ -1220,7 +1220,7 @@ def get_allof_instances(self, model_args, constant_args): allof_instance = allof_class(**kwargs) composed_instances.append(allof_instance) except Exception as ex: - raise ApiValueError( + six.raise_from(ApiValueError( "Invalid inputs given to generate an instance of '%s'. The " "input data was invalid for the allOf schema '%s' in the composed " "schema '%s'. Error=%s" % ( @@ -1229,7 +1229,7 @@ def get_allof_instances(self, model_args, constant_args): self.__class__.__name__, str(ex) ) - ) + ), ex) return composed_instances diff --git a/samples/client/petstore/python-experimental/petstore_api/model_utils.py b/samples/client/petstore/python-experimental/petstore_api/model_utils.py index 03012553a6ae..9070305650ae 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model_utils.py +++ b/samples/client/petstore/python-experimental/petstore_api/model_utils.py @@ -992,14 +992,14 @@ def deserialize_primitive(data, klass, path_to_item): # '7' -> 7.0 -> '7.0' != '7' raise ValueError('This is not a float') return converted_value - except (OverflowError, ValueError): + except (OverflowError, ValueError) as ex: # parse can raise OverflowError - raise ApiValueError( + six.raise_from(ApiValueError( "{0}Failed to parse {1} as {2}".format( additional_message, repr(data), get_py3_class_name(klass) ), path_to_item=path_to_item - ) + ), ex) def get_discriminator_class(model_class, @@ -1487,7 +1487,7 @@ def get_allof_instances(self, model_args, constant_args): allof_instance = allof_class(**kwargs) composed_instances.append(allof_instance) except Exception as ex: - raise ApiValueError( + six.raise_from(ApiValueError( "Invalid inputs given to generate an instance of '%s'. The " "input data was invalid for the allOf schema '%s' in the composed " "schema '%s'. Error=%s" % ( @@ -1496,7 +1496,7 @@ def get_allof_instances(self, model_args, constant_args): self.__class__.__name__, str(ex) ) - ) + ), ex) return composed_instances diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py index 03012553a6ae..9070305650ae 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py @@ -992,14 +992,14 @@ def deserialize_primitive(data, klass, path_to_item): # '7' -> 7.0 -> '7.0' != '7' raise ValueError('This is not a float') return converted_value - except (OverflowError, ValueError): + except (OverflowError, ValueError) as ex: # parse can raise OverflowError - raise ApiValueError( + six.raise_from(ApiValueError( "{0}Failed to parse {1} as {2}".format( additional_message, repr(data), get_py3_class_name(klass) ), path_to_item=path_to_item - ) + ), ex) def get_discriminator_class(model_class, @@ -1487,7 +1487,7 @@ def get_allof_instances(self, model_args, constant_args): allof_instance = allof_class(**kwargs) composed_instances.append(allof_instance) except Exception as ex: - raise ApiValueError( + six.raise_from(ApiValueError( "Invalid inputs given to generate an instance of '%s'. The " "input data was invalid for the allOf schema '%s' in the composed " "schema '%s'. Error=%s" % ( @@ -1496,7 +1496,7 @@ def get_allof_instances(self, model_args, constant_args): self.__class__.__name__, str(ex) ) - ) + ), ex) return composed_instances