From d053d464dd2ae5cd87b9231b4d858c942a78520e Mon Sep 17 00:00:00 2001 From: geekerzp Date: Mon, 20 Apr 2015 18:05:16 +0800 Subject: [PATCH] Fixed encoding issue for request json body in python client. --- .../swagger-codegen/src/main/resources/python/swagger.mustache | 2 ++ .../python/SwaggerPetstore-python/SwaggerPetstore/swagger.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/modules/swagger-codegen/src/main/resources/python/swagger.mustache b/modules/swagger-codegen/src/main/resources/python/swagger.mustache index 53933ba50d1..76857b09ab7 100644 --- a/modules/swagger-codegen/src/main/resources/python/swagger.mustache +++ b/modules/swagger-codegen/src/main/resources/python/swagger.mustache @@ -85,6 +85,8 @@ class ApiClient(object): if 'Content-Type' not in headers: headers['Content-Type'] = 'application/json' data = json.dumps(postData) + elif headers['Content-Type'] == 'application/json': + data = json.dumps(postData) elif headers['Content-Type'] == 'multipart/form-data': data = self.buildMultipartFormData(postData, files) headers['Content-Type'] = 'multipart/form-data; boundary={0}'.format(self.boundary) diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/swagger.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/swagger.py index 53933ba50d1..76857b09ab7 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/swagger.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/swagger.py @@ -85,6 +85,8 @@ class ApiClient(object): if 'Content-Type' not in headers: headers['Content-Type'] = 'application/json' data = json.dumps(postData) + elif headers['Content-Type'] == 'application/json': + data = json.dumps(postData) elif headers['Content-Type'] == 'multipart/form-data': data = self.buildMultipartFormData(postData, files) headers['Content-Type'] = 'multipart/form-data; boundary={0}'.format(self.boundary)