diff --git a/src/main/resources/python/api.mustache b/src/main/resources/python/api.mustache index 27d7814246e..1b304e81d96 100644 --- a/src/main/resources/python/api.mustache +++ b/src/main/resources/python/api.mustache @@ -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) diff --git a/src/main/resources/python/swagger.mustache b/src/main/resources/python/swagger.mustache index e62f854c7bf..b4e1fab3595 100644 --- a/src/main/resources/python/swagger.mustache +++ b/src/main/resources/python/swagger.mustache @@ -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.')