Skip to content

Commit d1b148a

Browse files
authored
[python] added handling for boolean content type (#17020)
* added handling for boolean content type * adapted addition to newer version of template * [python] updated samples
1 parent 8860d96 commit d1b148a

File tree

4 files changed

+36
-0
lines changed
  • modules/openapi-generator/src/main/resources/python
  • samples
    • client/echo_api
      • python/openapi_client
      • python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client
    • openapi3/client/petstore/python/petstore_api

4 files changed

+36
-0
lines changed

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

+9
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,15 @@ class RESTClientObject:
198198
headers=headers,
199199
preload_content=False
200200
)
201+
elif headers['Content-Type'] == 'text/plain' and isinstance(body, bool):
202+
request_body = "true" if body else "false"
203+
r = self.pool_manager.request(
204+
method,
205+
url,
206+
body=request_body,
207+
preload_content=False,
208+
timeout=timeout,
209+
headers=headers)
201210
else:
202211
# Cannot generate the request from given parameters
203212
msg = """Cannot prepare a request message for provided

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/rest.py

+9
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,15 @@ def request(
209209
headers=headers,
210210
preload_content=False
211211
)
212+
elif headers['Content-Type'] == 'text/plain' and isinstance(body, bool):
213+
request_body = "true" if body else "false"
214+
r = self.pool_manager.request(
215+
method,
216+
url,
217+
body=request_body,
218+
preload_content=False,
219+
timeout=timeout,
220+
headers=headers)
212221
else:
213222
# Cannot generate the request from given parameters
214223
msg = """Cannot prepare a request message for provided

samples/client/echo_api/python/openapi_client/rest.py

+9
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,15 @@ def request(
209209
headers=headers,
210210
preload_content=False
211211
)
212+
elif headers['Content-Type'] == 'text/plain' and isinstance(body, bool):
213+
request_body = "true" if body else "false"
214+
r = self.pool_manager.request(
215+
method,
216+
url,
217+
body=request_body,
218+
preload_content=False,
219+
timeout=timeout,
220+
headers=headers)
212221
else:
213222
# Cannot generate the request from given parameters
214223
msg = """Cannot prepare a request message for provided

samples/openapi3/client/petstore/python/petstore_api/rest.py

+9
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ def request(
208208
headers=headers,
209209
preload_content=False
210210
)
211+
elif headers['Content-Type'] == 'text/plain' and isinstance(body, bool):
212+
request_body = "true" if body else "false"
213+
r = self.pool_manager.request(
214+
method,
215+
url,
216+
body=request_body,
217+
preload_content=False,
218+
timeout=timeout,
219+
headers=headers)
211220
else:
212221
# Cannot generate the request from given parameters
213222
msg = """Cannot prepare a request message for provided

0 commit comments

Comments
 (0)