Skip to content

Commit fc9b7ea

Browse files
committed
Fix missing post-params when content type is json
1 parent 045cfde commit fc9b7ea

6 files changed

Lines changed: 12 additions & 0 deletions

File tree

modules/openapi-generator/src/main/resources/python-pydantic-v1/asyncio/rest.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ class RESTClientObject:
128128
if re.search('json', headers['Content-Type'], re.IGNORECASE):
129129
if body is not None:
130130
body = json.dumps(body)
131+
if body is None and post_params:
132+
body = json.dumps(dict(post_params))
131133
args["data"] = body
132134
elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501
133135
args["data"] = aiohttp.FormData(post_params)

modules/openapi-generator/src/main/resources/python-pydantic-v1/rest.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ class RESTClientObject:
172172
request_body = None
173173
if body is not None:
174174
request_body = json.dumps(body)
175+
if body is None and post_params:
176+
request_body = json.dumps(dict(post_params))
175177
r = self.pool_manager.request(
176178
method, url,
177179
body=request_body,

modules/openapi-generator/src/main/resources/python-pydantic-v1/tornado/rest.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ class RESTClientObject:
112112
if re.search('json', headers['Content-Type'], re.IGNORECASE):
113113
if body:
114114
body = json.dumps(body)
115+
if body is None and post_params:
116+
body = json.dumps(dict(post_params))
115117
request.body = body
116118
elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501
117119
request.body = urlencode(post_params)

modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ class RESTClientObject:
156156
if re.search('json', headers['Content-Type'], re.IGNORECASE):
157157
if body is not None:
158158
body = json.dumps(body)
159+
if body is None and post_params:
160+
body = json.dumps(dict(post_params))
159161
args["data"] = body
160162
elif headers['Content-Type'] == 'application/x-www-form-urlencoded':
161163
args["data"] = aiohttp.FormData(post_params)

modules/openapi-generator/src/main/resources/python/httpx/rest.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ class RESTClientObject:
128128
if re.search('json', headers['Content-Type'], re.IGNORECASE):
129129
if body is not None:
130130
args["json"] = body
131+
if body is None and post_params:
132+
args["json"] = dict(post_params)
131133
elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501
132134
args["data"] = dict(post_params)
133135
elif headers['Content-Type'] == 'multipart/form-data':

modules/openapi-generator/src/main/resources/python/tornado/rest.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ class RESTClientObject:
122122
if re.search('json', headers['Content-Type'], re.IGNORECASE):
123123
if body:
124124
body = json.dumps(body)
125+
if body is None and post_params:
126+
body = json.dumps(dict(post_params))
125127
request.body = body
126128
elif headers['Content-Type'] == 'application/x-www-form-urlencoded':
127129
request.body = urlencode(post_params)

0 commit comments

Comments
 (0)