mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
[python] Fix body check in rest.py (#6333)
Checking for "trueness" here is not sufficient. An empty list has a truth value of false so it will not be encoded as json and sent as the request body as it should. Instead we need to check explicitly if body is None.
This commit is contained in:
parent
da4deda278
commit
2d2f88e3d1
@ -115,7 +115,7 @@ class RESTClientObject:
|
||||
if query_params:
|
||||
url += '?' + urlencode(query_params)
|
||||
if re.search('json', headers['Content-Type'], re.IGNORECASE):
|
||||
if body:
|
||||
if body is not None:
|
||||
body = json.dumps(body)
|
||||
args["data"] = body
|
||||
elif headers['Content-Type'] == 'application/x-www-form-urlencoded':
|
||||
|
@ -132,7 +132,7 @@ class RESTClientObject(object):
|
||||
url += '?' + urlencode(query_params)
|
||||
if re.search('json', headers['Content-Type'], re.IGNORECASE):
|
||||
request_body = None
|
||||
if body:
|
||||
if body is not None:
|
||||
request_body = json.dumps(body)
|
||||
r = self.pool_manager.request(method, url,
|
||||
body=request_body,
|
||||
|
Loading…
Reference in New Issue
Block a user