forked from loafle/openapi-generator-original
fix parameters_to_url_query returns booleans with upper letter (#16947)
* chore: add test to show python bool url params are not lower case * fix: python parameters_to_url_query template to properly detect booleans * fix: typo in test * fix: typo in test * chore: update test name to snake case and be more descriptive
This commit is contained in:
parent
8893c7136a
commit
a4267ee630
@ -567,10 +567,10 @@ class ApiClient:
|
||||
if collection_formats is None:
|
||||
collection_formats = {}
|
||||
for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, bool):
|
||||
v = str(v).lower()
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, dict):
|
||||
v = json.dumps(v)
|
||||
|
||||
|
@ -481,10 +481,10 @@ class ApiClient:
|
||||
if collection_formats is None:
|
||||
collection_formats = {}
|
||||
for k, v in params.items() if isinstance(params, dict) else params:
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, bool):
|
||||
v = str(v).lower()
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, dict):
|
||||
v = json.dumps(v)
|
||||
|
||||
|
@ -476,10 +476,10 @@ class ApiClient:
|
||||
if collection_formats is None:
|
||||
collection_formats = {}
|
||||
for k, v in params.items() if isinstance(params, dict) else params:
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, bool):
|
||||
v = str(v).lower()
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, dict):
|
||||
v = json.dumps(v)
|
||||
|
||||
|
@ -529,10 +529,10 @@ class ApiClient:
|
||||
if collection_formats is None:
|
||||
collection_formats = {}
|
||||
for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, bool):
|
||||
v = str(v).lower()
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, dict):
|
||||
v = json.dumps(v)
|
||||
|
||||
|
@ -145,6 +145,11 @@ class TestManual(unittest.TestCase):
|
||||
self.assertTrue("Authorization" in e.headers)
|
||||
self.assertEqual(e.headers["Authorization"], "Basic dGVzdF91c2VybmFtZTp0ZXN0X3Bhc3N3b3Jk")
|
||||
|
||||
def test_parameters_to_url_query_boolean_value(self):
|
||||
client = openapi_client.ApiClient()
|
||||
params = client.parameters_to_url_query([("boolean", True),], {})
|
||||
self.assertEqual(params, "boolean=true")
|
||||
|
||||
def echoServerResponseParaserTest(self):
|
||||
s = """POST /echo/body/Pet/response_string HTTP/1.1
|
||||
Host: localhost:3000
|
||||
|
@ -476,10 +476,10 @@ class ApiClient:
|
||||
if collection_formats is None:
|
||||
collection_formats = {}
|
||||
for k, v in params.items() if isinstance(params, dict) else params:
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, bool):
|
||||
v = str(v).lower()
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, dict):
|
||||
v = json.dumps(v)
|
||||
|
||||
|
@ -212,6 +212,11 @@ class TestManual(unittest.TestCase):
|
||||
self.assertEqual(pet2.tags[0].name, "None")
|
||||
self.assertEqual(pet2.category.id, 1)
|
||||
|
||||
def test_parameters_to_url_query_boolean_value(self):
|
||||
client = openapi_client.ApiClient()
|
||||
params = client.parameters_to_url_query([("boolean", True),], {})
|
||||
self.assertEqual(params, "boolean=true")
|
||||
|
||||
def echoServerResponseParaserTest(self):
|
||||
s = """POST /echo/body/Pet/response_string HTTP/1.1
|
||||
Host: localhost:3000
|
||||
|
@ -483,10 +483,10 @@ class ApiClient:
|
||||
if collection_formats is None:
|
||||
collection_formats = {}
|
||||
for k, v in params.items() if isinstance(params, dict) else params:
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, bool):
|
||||
v = str(v).lower()
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, dict):
|
||||
v = json.dumps(v)
|
||||
|
||||
|
@ -499,10 +499,10 @@ class ApiClient:
|
||||
if collection_formats is None:
|
||||
collection_formats = {}
|
||||
for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, bool):
|
||||
v = str(v).lower()
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, dict):
|
||||
v = json.dumps(v)
|
||||
|
||||
|
@ -528,10 +528,10 @@ class ApiClient:
|
||||
if collection_formats is None:
|
||||
collection_formats = {}
|
||||
for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, bool):
|
||||
v = str(v).lower()
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, dict):
|
||||
v = json.dumps(v)
|
||||
|
||||
|
@ -257,5 +257,6 @@ class ApiClientTests(unittest.TestCase):
|
||||
result = self.api_client.parameters_to_url_query([('value', dictionary)], {})
|
||||
self.assertEqual(result, 'value=%7B%22strValues%22%3A%20%5B%22one%22%2C%20%22two%22%2C%20%22three%22%5D%2C%20%22dictValues%22%3A%20%5B%7B%22name%22%3A%20%22value1%22%2C%20%22age%22%3A%2014%7D%2C%20%7B%22name%22%3A%20%22value2%22%2C%20%22age%22%3A%2012%7D%5D%7D')
|
||||
|
||||
|
||||
|
||||
def test_parameters_to_url_query_boolean_value(self):
|
||||
result = self.api_client.parameters_to_url_query([('boolean', True)], {})
|
||||
self.assertEqual(result, "boolean=true")
|
||||
|
@ -475,10 +475,10 @@ class ApiClient:
|
||||
if collection_formats is None:
|
||||
collection_formats = {}
|
||||
for k, v in params.items() if isinstance(params, dict) else params:
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, bool):
|
||||
v = str(v).lower()
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, dict):
|
||||
v = json.dumps(v)
|
||||
|
||||
|
@ -243,5 +243,6 @@ class ApiClientTests(unittest.TestCase):
|
||||
result = self.api_client.parameters_to_url_query([('value', dictionary)], {})
|
||||
self.assertEqual(result, 'value=%7B%22strValues%22%3A%20%5B%22one%22%2C%20%22two%22%2C%20%22three%22%5D%2C%20%22dictValues%22%3A%20%5B%7B%22name%22%3A%20%22value1%22%2C%20%22age%22%3A%2014%7D%2C%20%7B%22name%22%3A%20%22value2%22%2C%20%22age%22%3A%2012%7D%5D%7D')
|
||||
|
||||
|
||||
|
||||
def test_parameters_to_url_query_boolean_value(self):
|
||||
result = self.api_client.parameters_to_url_query([('boolean', True)], {})
|
||||
self.assertEqual(result, "boolean=true")
|
||||
|
Loading…
x
Reference in New Issue
Block a user