From b6a84b842eaf63ccfd27a5c479ebbdfbca1dfe9b Mon Sep 17 00:00:00 2001 From: Muhammad Sufyan Date: Wed, 18 Oct 2023 13:13:38 +0500 Subject: [PATCH] fix(bool-serialization): bool value serialization in query and form (#46) This commit serializes the boolean value from Pascal case to lowercase in query and form parameters. Earlier, It was Pascal Case due to the native boolean value. During query and form serialization, the boolean value is transformed into lowercase. --- apimatic_core/utilities/api_helper.py | 2 ++ setup.py | 2 +- tests/apimatic_core/utility_tests/test_api_helper.py | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apimatic_core/utilities/api_helper.py b/apimatic_core/utilities/api_helper.py index 9ddd0a8..9b0609d 100644 --- a/apimatic_core/utilities/api_helper.py +++ b/apimatic_core/utilities/api_helper.py @@ -434,6 +434,8 @@ def form_encode(obj, retval += ApiHelper.form_encode(obj[item], instance_name + "[" + item + "]", array_serialization, is_query) else: + if isinstance(obj, bool): + obj = str(obj).lower() retval.append((instance_name, obj)) return retval diff --git a/setup.py b/setup.py index 05ab829..7d34a71 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='apimatic-core', - version='0.2.4', + version='0.2.5', description='A library that contains core logic and utilities for ' 'consuming REST APIs using Python SDKs generated by APIMatic.', long_description=long_description, diff --git a/tests/apimatic_core/utility_tests/test_api_helper.py b/tests/apimatic_core/utility_tests/test_api_helper.py index 41ddedd..7b44126 100644 --- a/tests/apimatic_core/utility_tests/test_api_helper.py +++ b/tests/apimatic_core/utility_tests/test_api_helper.py @@ -318,7 +318,7 @@ def test_append_url_with_query_parameters_value_error(self, input_url, input_que ({'query_param': "string", 'query_param2': True, 'query_param3': [1, 2, 3] - }, 'query_param=string&query_param2=True&query_param3[0]=1&query_param3[1]=2&query_param3[2]=3', + }, 'query_param=string&query_param2=true&query_param3[0]=1&query_param3[1]=2&query_param3[2]=3', SerializationFormats.INDEXED) ]) def test_process_complex_query_parameters(self, input_query_params, expected_query_param_value, @@ -521,7 +521,7 @@ def test_form_params(self, input_form_param_value, expected_form_param_value, ar 'form_param3': {'key': 'string_val'}, }, [('form_param1', 'string'), ('form_param2[0]', 'string'), - ('form_param2[1]', True), + ('form_param2[1]', 'true'), ('form_param3[key]', 'string_val')], SerializationFormats.INDEXED) ]) def test_form_encode_parameters(self, input_form_param_value, expected_form_param_value,