forked from loafle/openapi-generator-original
[python] Encode list query params (#20148)
* Bugfix: #17688: Encode list query params * Test: #17688: Update validation error message tests for Pydantic 2.10+ Pydantic 2.10+ introduced changes to validation error messages, requiring updates to the affected test cases.
This commit is contained in:
parent
7072009ab5
commit
7b35613cfc
@ -525,7 +525,7 @@ class ApiClient:
|
||||
if k in collection_formats:
|
||||
collection_format = collection_formats[k]
|
||||
if collection_format == 'multi':
|
||||
new_params.extend((k, str(value)) for value in v)
|
||||
new_params.extend((k, quote(str(value))) for value in v)
|
||||
else:
|
||||
if collection_format == 'ssv':
|
||||
delimiter = ' '
|
||||
|
@ -518,7 +518,7 @@ class ApiClient:
|
||||
if k in collection_formats:
|
||||
collection_format = collection_formats[k]
|
||||
if collection_format == 'multi':
|
||||
new_params.extend((k, str(value)) for value in v)
|
||||
new_params.extend((k, quote(str(value))) for value in v)
|
||||
else:
|
||||
if collection_format == 'ssv':
|
||||
delimiter = ' '
|
||||
|
@ -518,7 +518,7 @@ class ApiClient:
|
||||
if k in collection_formats:
|
||||
collection_format = collection_formats[k]
|
||||
if collection_format == 'multi':
|
||||
new_params.extend((k, str(value)) for value in v)
|
||||
new_params.extend((k, quote(str(value))) for value in v)
|
||||
else:
|
||||
if collection_format == 'ssv':
|
||||
delimiter = ' '
|
||||
|
@ -520,7 +520,7 @@ class ApiClient:
|
||||
if k in collection_formats:
|
||||
collection_format = collection_formats[k]
|
||||
if collection_format == 'multi':
|
||||
new_params.extend((k, str(value)) for value in v)
|
||||
new_params.extend((k, quote(str(value))) for value in v)
|
||||
else:
|
||||
if collection_format == 'ssv':
|
||||
delimiter = ' '
|
||||
|
@ -517,7 +517,7 @@ class ApiClient:
|
||||
if k in collection_formats:
|
||||
collection_format = collection_formats[k]
|
||||
if collection_format == 'multi':
|
||||
new_params.extend((k, str(value)) for value in v)
|
||||
new_params.extend((k, quote(str(value))) for value in v)
|
||||
else:
|
||||
if collection_format == 'ssv':
|
||||
delimiter = ' '
|
||||
|
@ -294,3 +294,8 @@ class ApiClientTests(unittest.TestCase):
|
||||
params = self.api_client.parameters_to_url_query(params=[('list', [1, 2, 3])],
|
||||
collection_formats={'list': 'multi'})
|
||||
self.assertEqual(params, "list=1&list=2&list=3")
|
||||
|
||||
def test_parameters_to_url_query_list_value_encoded(self):
|
||||
params = self.api_client.parameters_to_url_query(params=[('list', [" !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", "2023-01-01T00:00:00+01:00"])],
|
||||
collection_formats={'list': 'multi'})
|
||||
self.assertEqual(params, "list=%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-./%3A%3B%3C%3D%3E%3F%40%5B%5C%5D%5E_%60%7B%7C%7D~&list=2023-01-01T00%3A00%3A00%2B01%3A00")
|
||||
|
@ -50,7 +50,7 @@ class ApiExceptionTests(unittest.TestCase):
|
||||
try:
|
||||
self.pet_api.get_pet_by_id() # type: ignore
|
||||
except ValidationError as e:
|
||||
self.assertIn("1 validation error for get_pet_by_id", str(e))
|
||||
self.assertIn("1 validation error for PetApi.get_pet_by_id", str(e))
|
||||
self.assertIn("Missing required argument", str(e))
|
||||
|
||||
def test_integer_validation(self):
|
||||
@ -61,7 +61,7 @@ class ApiExceptionTests(unittest.TestCase):
|
||||
# pet_id
|
||||
# Input should be a valid integer [type=int_type, input_value='123', input_type=str]
|
||||
# For further information visit https://errors.pydantic.dev/2.3/v/int_type
|
||||
self.assertIn("1 validation error for get_pet_by_id", str(e))
|
||||
self.assertIn("1 validation error for PetApi.get_pet_by_id", str(e))
|
||||
self.assertIn("Input should be a valid integer", str(e))
|
||||
|
||||
def test_string_enum_validation(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user