Skip to content

Commit b6a84b8

Browse files
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.
1 parent 6de5484 commit b6a84b8

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

apimatic_core/utilities/api_helper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ def form_encode(obj,
434434
retval += ApiHelper.form_encode(obj[item], instance_name + "[" + item + "]", array_serialization,
435435
is_query)
436436
else:
437+
if isinstance(obj, bool):
438+
obj = str(obj).lower()
437439
retval.append((instance_name, obj))
438440

439441
return retval

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
setup(
1414
name='apimatic-core',
15-
version='0.2.4',
15+
version='0.2.5',
1616
description='A library that contains core logic and utilities for '
1717
'consuming REST APIs using Python SDKs generated by APIMatic.',
1818
long_description=long_description,

tests/apimatic_core/utility_tests/test_api_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def test_append_url_with_query_parameters_value_error(self, input_url, input_que
318318
({'query_param': "string",
319319
'query_param2': True,
320320
'query_param3': [1, 2, 3]
321-
}, 'query_param=string&query_param2=True&query_param3[0]=1&query_param3[1]=2&query_param3[2]=3',
321+
}, 'query_param=string&query_param2=true&query_param3[0]=1&query_param3[1]=2&query_param3[2]=3',
322322
SerializationFormats.INDEXED)
323323
])
324324
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
521521
'form_param3': {'key': 'string_val'},
522522
}, [('form_param1', 'string'),
523523
('form_param2[0]', 'string'),
524-
('form_param2[1]', True),
524+
('form_param2[1]', 'true'),
525525
('form_param3[key]', 'string_val')], SerializationFormats.INDEXED)
526526
])
527527
def test_form_encode_parameters(self, input_form_param_value, expected_form_param_value,

0 commit comments

Comments
 (0)