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

@@ -64,8 +64,11 @@ class PetApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = 'application/json,application/xml,'
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = ['application/json', 'application/xml', ]
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
@@ -120,8 +123,11 @@ class PetApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = 'application/json,application/xml,'
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = ['application/json', 'application/xml', ]
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
@@ -176,8 +182,11 @@ class PetApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
if ('status' in params):
@@ -238,8 +247,11 @@ class PetApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
if ('tags' in params):
@@ -300,8 +312,11 @@ class PetApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
@@ -371,8 +386,11 @@ class PetApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = 'application/x-www-form-urlencoded,'
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = ['application/x-www-form-urlencoded', ]
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
@@ -439,8 +457,11 @@ class PetApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
@@ -507,8 +528,11 @@ class PetApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = 'multipart/form-data,'
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = ['multipart/form-data', ]
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'

View File

@@ -61,8 +61,11 @@ class StoreApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
@@ -120,8 +123,11 @@ class StoreApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
@@ -182,8 +188,11 @@ class StoreApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
@@ -247,8 +256,11 @@ class StoreApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'

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)

View File

@@ -64,8 +64,11 @@ class UserApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
@@ -120,8 +123,11 @@ class UserApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
@@ -176,8 +182,11 @@ class UserApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
@@ -235,8 +244,11 @@ class UserApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
if ('username' in params):
@@ -297,8 +309,11 @@ class UserApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
@@ -350,8 +365,11 @@ class UserApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
@@ -418,8 +436,11 @@ class UserApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
@@ -480,8 +501,11 @@ class UserApi(object):
files = {}
bodyParam = None
headerParams['Accept'] = 'application/json,application/xml'
headerParams['Content-Type'] = ''
accepts = ['application/json', 'application/xml']
headerParams['Accept'] = ', '.join(accepts)
content_types = []
headerParams['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'