Skip to content

Commit

Permalink
fix(bool-serialization): bool value serialization in query and form (#46
Browse files Browse the repository at this point in the history
)

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.
  • Loading branch information
sufyankhanrao authored Oct 18, 2023
1 parent 6de5484 commit b6a84b8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apimatic_core/utilities/api_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/apimatic_core/utility_tests/test_api_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b6a84b8

Please sign in to comment.