Fixed request content-type in objc client.

In api.mustache the name of content-type is `Content-Type`,
but in swagger.mustache the name of content-type is `Content-type`.
This commit is contained in:
geekerzp
2015-04-13 17:30:43 +08:00
parent 7f84deaf30
commit 10a9d298d7
6 changed files with 113 additions and 50 deletions

View File

@@ -65,8 +65,11 @@ class {{classname}}(object):
files = {}
bodyParam = None
headerParams['Accept'] = '{{#produces}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/produces}}'
headerParams['Content-Type'] = '{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}'
accepts = [{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]
headerParams['Accept'] = ', '.join(accepts)
content_types = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
{{#queryParams}}
if ('{{paramName}}' in params):

View File

@@ -82,12 +82,12 @@ class ApiClient(object):
elif method in ['POST', 'PUT', 'DELETE']:
if postData:
postData = ApiClient.sanitizeForSerialization(postData)
if 'Content-type' not in headers:
headers['Content-type'] = 'application/json'
if 'Content-Type' not in headers:
headers['Content-Type'] = 'application/json'
data = json.dumps(postData)
elif headers['Content-type'] == 'multipart/form-data':
elif headers['Content-Type'] == 'multipart/form-data':
data = self.buildMultipartFormData(postData, files)
headers['Content-type'] = 'multipart/form-data; boundary={0}'.format(self.boundary)
headers['Content-Type'] = 'multipart/form-data; boundary={0}'.format(self.boundary)
headers['Content-length'] = str(len(data))
else:
data = urllib.urlencode(postData)