diff --git a/modules/swagger-codegen/src/main/resources/python/model.mustache b/modules/swagger-codegen/src/main/resources/python/model.mustache index 171b7277f06..dcf3c755020 100644 --- a/modules/swagger-codegen/src/main/resources/python/model.mustache +++ b/modules/swagger-codegen/src/main/resources/python/model.mustache @@ -172,6 +172,9 @@ class {{classname}}(object): """ Returns true if both objects are equal """ + if not isinstance(other, {{classname}}): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore-security-test/python/README.md b/samples/client/petstore-security-test/python/README.md index 9f90aa1d071..971b2c7c77a 100644 --- a/samples/client/petstore-security-test/python/README.md +++ b/samples/client/petstore-security-test/python/README.md @@ -5,7 +5,7 @@ This Python package is automatically generated by the [Swagger Codegen](https:// - API version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r - Package version: 1.0.0 -- Build package: class io.swagger.codegen.languages.PythonClientCodegen +- Build package: io.swagger.codegen.languages.PythonClientCodegen ## Requirements. diff --git a/samples/client/petstore-security-test/python/petstore_api/api_client.py b/samples/client/petstore-security-test/python/petstore_api/api_client.py index 02c6172ccc4..f8b73bc1463 100644 --- a/samples/client/petstore-security-test/python/petstore_api/api_client.py +++ b/samples/client/petstore-security-test/python/petstore_api/api_client.py @@ -116,7 +116,7 @@ def __call_api(self, resource_path, method, collection_formats) for k, v in path_params: resource_path = resource_path.replace( - '{%s}' % k, quote(str(v))) + '{%s}' % k, quote(str(v), safe="")) # query parameters if query_params: diff --git a/samples/client/petstore-security-test/python/petstore_api/apis/fake_api.py b/samples/client/petstore-security-test/python/petstore_api/apis/fake_api.py index f713d227c0e..a6961921ac4 100644 --- a/samples/client/petstore-security-test/python/petstore_api/apis/fake_api.py +++ b/samples/client/petstore-security-test/python/petstore_api/apis/fake_api.py @@ -116,12 +116,9 @@ def test_code_inject____end__rn_n_r_with_http_info(self, **kwargs): form_params.append(('test code inject */ ' " =end -- \r\n \n \r', params['test_code_inject____end____rn_n_r'])) body_params = None - # HTTP header `Accept` header_params['Accept'] = self.api_client.\ select_header_accept(['application/json', '*/ \" =end -- ']) - if not header_params['Accept']: - del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.\ diff --git a/samples/client/petstore-security-test/python/petstore_api/models/model_return.py b/samples/client/petstore-security-test/python/petstore_api/models/model_return.py index 8256e70ca94..2b6f2a45172 100644 --- a/samples/client/petstore-security-test/python/petstore_api/models/model_return.py +++ b/samples/client/petstore-security-test/python/petstore_api/models/model_return.py @@ -105,6 +105,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, ModelReturn): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/additional_properties_class.py b/samples/client/petstore/python/petstore_api/models/additional_properties_class.py index 4840f52a8e8..5873f70643f 100644 --- a/samples/client/petstore/python/petstore_api/models/additional_properties_class.py +++ b/samples/client/petstore/python/petstore_api/models/additional_properties_class.py @@ -127,6 +127,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, AdditionalPropertiesClass): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/animal.py b/samples/client/petstore/python/petstore_api/models/animal.py index c12c9d22284..c46cfb28ddb 100644 --- a/samples/client/petstore/python/petstore_api/models/animal.py +++ b/samples/client/petstore/python/petstore_api/models/animal.py @@ -129,6 +129,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, Animal): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/animal_farm.py b/samples/client/petstore/python/petstore_api/models/animal_farm.py index b3884fb4b3f..ff8a3794e90 100644 --- a/samples/client/petstore/python/petstore_api/models/animal_farm.py +++ b/samples/client/petstore/python/petstore_api/models/animal_farm.py @@ -81,6 +81,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, AnimalFarm): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/api_response.py b/samples/client/petstore/python/petstore_api/models/api_response.py index 652c48b69b4..ba5c434abc7 100644 --- a/samples/client/petstore/python/petstore_api/models/api_response.py +++ b/samples/client/petstore/python/petstore_api/models/api_response.py @@ -151,6 +151,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, ApiResponse): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py b/samples/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py index 64a9a2c0513..16c6345baad 100644 --- a/samples/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py @@ -103,6 +103,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, ArrayOfArrayOfNumberOnly): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/array_of_number_only.py b/samples/client/petstore/python/petstore_api/models/array_of_number_only.py index 931ae9b1229..0db1d9591d5 100644 --- a/samples/client/petstore/python/petstore_api/models/array_of_number_only.py +++ b/samples/client/petstore/python/petstore_api/models/array_of_number_only.py @@ -103,6 +103,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, ArrayOfNumberOnly): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/array_test.py b/samples/client/petstore/python/petstore_api/models/array_test.py index 36bceca687f..bd1858faa0d 100644 --- a/samples/client/petstore/python/petstore_api/models/array_test.py +++ b/samples/client/petstore/python/petstore_api/models/array_test.py @@ -151,6 +151,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, ArrayTest): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/capitalization.py b/samples/client/petstore/python/petstore_api/models/capitalization.py index e524d7604fd..b9030b5b76d 100644 --- a/samples/client/petstore/python/petstore_api/models/capitalization.py +++ b/samples/client/petstore/python/petstore_api/models/capitalization.py @@ -225,6 +225,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, Capitalization): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/cat.py b/samples/client/petstore/python/petstore_api/models/cat.py index c52594a9870..67cae27ae8a 100644 --- a/samples/client/petstore/python/petstore_api/models/cat.py +++ b/samples/client/petstore/python/petstore_api/models/cat.py @@ -153,6 +153,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, Cat): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/category.py b/samples/client/petstore/python/petstore_api/models/category.py index 8a312c27094..2cdc9911d4e 100644 --- a/samples/client/petstore/python/petstore_api/models/category.py +++ b/samples/client/petstore/python/petstore_api/models/category.py @@ -127,6 +127,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, Category): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/class_model.py b/samples/client/petstore/python/petstore_api/models/class_model.py index dd08406c04b..cf93b27c760 100644 --- a/samples/client/petstore/python/petstore_api/models/class_model.py +++ b/samples/client/petstore/python/petstore_api/models/class_model.py @@ -103,6 +103,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, ClassModel): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/client.py b/samples/client/petstore/python/petstore_api/models/client.py index 47a89b35729..2d572bfbeb2 100644 --- a/samples/client/petstore/python/petstore_api/models/client.py +++ b/samples/client/petstore/python/petstore_api/models/client.py @@ -103,6 +103,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, Client): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/dog.py b/samples/client/petstore/python/petstore_api/models/dog.py index 0a13575dfb8..fc1d1fbf30c 100644 --- a/samples/client/petstore/python/petstore_api/models/dog.py +++ b/samples/client/petstore/python/petstore_api/models/dog.py @@ -153,6 +153,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, Dog): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/enum_arrays.py b/samples/client/petstore/python/petstore_api/models/enum_arrays.py index a9c96ef1bff..46b34bd41f7 100644 --- a/samples/client/petstore/python/petstore_api/models/enum_arrays.py +++ b/samples/client/petstore/python/petstore_api/models/enum_arrays.py @@ -140,6 +140,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, EnumArrays): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/enum_class.py b/samples/client/petstore/python/petstore_api/models/enum_class.py index 792b6152a2b..45f6b0b4578 100644 --- a/samples/client/petstore/python/petstore_api/models/enum_class.py +++ b/samples/client/petstore/python/petstore_api/models/enum_class.py @@ -81,6 +81,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, EnumClass): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/enum_test.py b/samples/client/petstore/python/petstore_api/models/enum_test.py index d46d145dfaf..e3293425049 100644 --- a/samples/client/petstore/python/petstore_api/models/enum_test.py +++ b/samples/client/petstore/python/petstore_api/models/enum_test.py @@ -193,6 +193,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, EnumTest): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/format_test.py b/samples/client/petstore/python/petstore_api/models/format_test.py index 1223bb1ea99..cde65b89a17 100644 --- a/samples/client/petstore/python/petstore_api/models/format_test.py +++ b/samples/client/petstore/python/petstore_api/models/format_test.py @@ -425,6 +425,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, FormatTest): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/has_only_read_only.py b/samples/client/petstore/python/petstore_api/models/has_only_read_only.py index fcad8f02d4b..c374793e617 100644 --- a/samples/client/petstore/python/petstore_api/models/has_only_read_only.py +++ b/samples/client/petstore/python/petstore_api/models/has_only_read_only.py @@ -127,6 +127,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, HasOnlyReadOnly): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/list.py b/samples/client/petstore/python/petstore_api/models/list.py index 5e23577f213..f1393a4b6a3 100644 --- a/samples/client/petstore/python/petstore_api/models/list.py +++ b/samples/client/petstore/python/petstore_api/models/list.py @@ -103,6 +103,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, List): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/map_test.py b/samples/client/petstore/python/petstore_api/models/map_test.py index 61f97136063..e6ece72af81 100644 --- a/samples/client/petstore/python/petstore_api/models/map_test.py +++ b/samples/client/petstore/python/petstore_api/models/map_test.py @@ -134,6 +134,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, MapTest): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py index bdfa6721fb7..ee9b1e641e4 100644 --- a/samples/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -151,6 +151,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, MixedPropertiesAndAdditionalPropertiesClass): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/model_200_response.py b/samples/client/petstore/python/petstore_api/models/model_200_response.py index ea332d78a59..73b6dccc050 100644 --- a/samples/client/petstore/python/petstore_api/models/model_200_response.py +++ b/samples/client/petstore/python/petstore_api/models/model_200_response.py @@ -127,6 +127,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, Model200Response): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/model_return.py b/samples/client/petstore/python/petstore_api/models/model_return.py index 472c733793a..d99df7402b0 100644 --- a/samples/client/petstore/python/petstore_api/models/model_return.py +++ b/samples/client/petstore/python/petstore_api/models/model_return.py @@ -103,6 +103,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, ModelReturn): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/name.py b/samples/client/petstore/python/petstore_api/models/name.py index f2ea96a04fe..af281208f7a 100644 --- a/samples/client/petstore/python/petstore_api/models/name.py +++ b/samples/client/petstore/python/petstore_api/models/name.py @@ -177,6 +177,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, Name): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/number_only.py b/samples/client/petstore/python/petstore_api/models/number_only.py index 7b471e980d2..48fea068509 100644 --- a/samples/client/petstore/python/petstore_api/models/number_only.py +++ b/samples/client/petstore/python/petstore_api/models/number_only.py @@ -103,6 +103,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, NumberOnly): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/order.py b/samples/client/petstore/python/petstore_api/models/order.py index fa8c7b8c750..d0ed63cd482 100644 --- a/samples/client/petstore/python/petstore_api/models/order.py +++ b/samples/client/petstore/python/petstore_api/models/order.py @@ -231,6 +231,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, Order): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/outer_enum.py b/samples/client/petstore/python/petstore_api/models/outer_enum.py index d86b2a3c03f..8c732caee81 100644 --- a/samples/client/petstore/python/petstore_api/models/outer_enum.py +++ b/samples/client/petstore/python/petstore_api/models/outer_enum.py @@ -81,6 +81,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, OuterEnum): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/pet.py b/samples/client/petstore/python/petstore_api/models/pet.py index 11f84a0f609..7dea8afd1b2 100644 --- a/samples/client/petstore/python/petstore_api/models/pet.py +++ b/samples/client/petstore/python/petstore_api/models/pet.py @@ -235,6 +235,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, Pet): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/read_only_first.py b/samples/client/petstore/python/petstore_api/models/read_only_first.py index 4316ec0911f..2b1dfda420c 100644 --- a/samples/client/petstore/python/petstore_api/models/read_only_first.py +++ b/samples/client/petstore/python/petstore_api/models/read_only_first.py @@ -127,6 +127,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, ReadOnlyFirst): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/special_model_name.py b/samples/client/petstore/python/petstore_api/models/special_model_name.py index 3a133e2534b..651c51e8e56 100644 --- a/samples/client/petstore/python/petstore_api/models/special_model_name.py +++ b/samples/client/petstore/python/petstore_api/models/special_model_name.py @@ -103,6 +103,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, SpecialModelName): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/tag.py b/samples/client/petstore/python/petstore_api/models/tag.py index e0067308f99..4bd6bfedfb6 100644 --- a/samples/client/petstore/python/petstore_api/models/tag.py +++ b/samples/client/petstore/python/petstore_api/models/tag.py @@ -127,6 +127,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, Tag): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other): diff --git a/samples/client/petstore/python/petstore_api/models/user.py b/samples/client/petstore/python/petstore_api/models/user.py index 3d84d068d12..ed3af1ce20d 100644 --- a/samples/client/petstore/python/petstore_api/models/user.py +++ b/samples/client/petstore/python/petstore_api/models/user.py @@ -273,6 +273,9 @@ def __eq__(self, other): """ Returns true if both objects are equal """ + if not isinstance(other, User): + return False + return self.__dict__ == other.__dict__ def __ne__(self, other):