Repository navigation
Python: fix(python): serialize OpenAPI boolean and array parameters according to specification (#14788) - #14800
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Path-array serialization incorrectly percent-encodes separator commas, violating OpenAPI simple-style formatting and conflating multiple items with a single comma-containing value.
1 open issue
What changed in this PR
Addresses #14788 by updating the Python OpenAPI plugin’s boolean and array parameter serialization instead of using Python’s default string representations.
Changes:
- Adds shared formatting for lowercase boolean values.
- Expands query arrays into repeated keys and joins header/path arrays with commas.
- Adds unit tests for boolean and array parameters in all three locations.
| File | Description |
|---|---|
python/tests/unit/connectors/openapi_plugin/test_sk_openapi.py |
Adds query, header, and path serialization tests. |
python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py |
Adds value formatting and updates parameter serialization. |
Review effort: Balanced
| formatted_value = ",".join(self._format_parameter_value(item) for item in argument) | ||
| else: | ||
| formatted_value = self._format_parameter_value(argument) | ||
| path_template = path_template.replace(f"{{{parameter.name}}}", quote(formatted_value, safe="")) |
There was a problem hiding this comment.
Good catch! Updated path parameter serialization in commit 9ea0be4f8 so each array item is percent-encoded individually before joining with literal commas, preserving OpenAPI simple-style delimiter syntax (item1,item2) while properly encoding any literal commas within elements (item%2C1,item2). Also updated unit tests and verified all tests pass.
|
@microsoft-github-policy-service agree |

Motivation and Context
When using the OpenAPI plugin with operations that accept �oolean or �rray parameters (in query, header, or path), parameters were previously serialized using Python's default str() representation ( ags=['a', 'b'], �ctive=True). This caused remote APIs to fail parsing requests since OpenAPI specifies lowercase JSON booleans ( rue/alse) and style: form, explode: true repeated query parameters ( ags=a&tags=b) by default.
Fixes .Net: Python: Bug: OpenAPI plugin sends array and boolean query parameters as Python repr (tags=['a', 'b'], active=True) #14788. Ensures �uild_query_string, �uild_headers, and �uild_path format booleans and array parameters compliant with OpenAPI standard serialization rules.
Any tool invocation or agent action via Kernel.add_plugin_from_openapi targeting standard REST APIs that declare boolean flags or array query/header/path parameters.
Fixes .Net: Python: Bug: OpenAPI plugin sends array and boolean query parameters as Python repr (tags=['a', 'b'], active=True) #14788.
Description
Contribution Checklist