forked from loafle/openapi-generator-original
Merge pull request #266 from FindTheBest/pull_request
Python binding generation pull request
This commit is contained in:
commit
ec99bef893
@ -58,6 +58,8 @@ class {{classname}}(object):
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
formParams = {}
|
||||
bodyParam = None
|
||||
|
||||
{{#queryParams}}
|
||||
if ('{{paramName}}' in params):
|
||||
@ -76,7 +78,19 @@ class {{classname}}(object):
|
||||
replacement)
|
||||
{{/pathParams}}
|
||||
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
{{#formParams}}
|
||||
if ('{{paramName}}' in params):
|
||||
formParams['{{paramName}}'] = params['{{paramName}}']
|
||||
{{/formParams}}
|
||||
if formParams:
|
||||
headerParams['Content-type'] = 'application/x-www-form-urlencoded'
|
||||
|
||||
{{#bodyParam}}
|
||||
if ('{{paramName}}' in params):
|
||||
bodyParam = params['{{paramName}}']
|
||||
{{/bodyParam}}
|
||||
|
||||
postData = (formParams if formParams else bodyParam)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
@ -60,9 +60,12 @@ class ApiClient:
|
||||
elif method in ['POST', 'PUT', 'DELETE']:
|
||||
|
||||
if postData:
|
||||
headers['Content-type'] = 'application/json'
|
||||
data = self.sanitizeForSerialization(postData)
|
||||
data = json.dumps(data)
|
||||
if 'Content-type' not in headers:
|
||||
headers['Content-type'] = 'application/json'
|
||||
data = json.dumps(data)
|
||||
else:
|
||||
data = urllib.urlencode(data)
|
||||
|
||||
else:
|
||||
raise Exception('Method ' + method + ' is not recognized.')
|
||||
|
Loading…
x
Reference in New Issue
Block a user