forked from loafle/openapi-generator-original
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:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user