From fdbef5203ebc9bb5b9631b9b15628ee9643907df Mon Sep 17 00:00:00 2001 From: Jeevan Babu Gotru <114808955+jeevan1098@users.noreply.github.com> Date: Thu, 12 Nov 2026 09:39:57 -0600 Subject: [PATCH 1/4] Python: fix OpenAPI plugin sending array and boolean parameters as Python repr --- .../models/rest_api_operation.py | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py b/python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py index cc137083b4da..0fb295098f9e 100644 --- a/python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py +++ b/python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py @@ -198,6 +198,17 @@ def url_join(self, base_url: str, path: str): full_path = urljoin(base_path, path.lstrip("/")) return urlunparse(parsed_base._replace(path=full_path)) + @staticmethod + def _serialize_parameter_value(value: Any) -> Any: + """Serialize a scalar parameter value the way OpenAPI expects it on the wire. + + Booleans use the JSON spelling (``true``/``false``) instead of Python's + ``True``/``False``; every other value is passed through unchanged. + """ + if isinstance(value, bool): + return "true" if value else "false" + return value + def build_headers(self, arguments: dict[str, Any]) -> dict[str, str]: """Build the headers for the operation.""" headers = {} @@ -215,7 +226,7 @@ def build_headers(self, arguments: dict[str, Any]) -> dict[str, str]: ) continue - headers[parameter.name] = str(argument) + headers[parameter.name] = str(self._serialize_parameter_value(argument)) return headers @@ -328,7 +339,9 @@ def build_path(self, path_template: str, arguments: dict[str, Any]) -> str: f"required parameter of the operation - `{self.id}`." ) continue - path_template = path_template.replace(f"{{{parameter.name}}}", quote(str(argument), safe="")) + path_template = path_template.replace( + f"{{{parameter.name}}}", quote(str(self._serialize_parameter_value(argument)), safe="") + ) self._validate_path_segments(path_template) return path_template @@ -396,8 +409,12 @@ def build_query_string(self, arguments: dict[str, Any]) -> str: f"required parameter of the operation - `{self.id}`." ) continue + if isinstance(argument, (list, tuple)): + argument = [self._serialize_parameter_value(item) for item in argument] + else: + argument = self._serialize_parameter_value(argument) segments.append((parameter.name, argument)) - return urlencode(segments) + return urlencode(segments, doseq=True) def replace_invalid_symbols(self, parameter_name): """Replace invalid symbols in the parameter name with underscores.""" From 14bba68c64ceb34659c766c504df143c82100497 Mon Sep 17 00:00:00 2001 From: Jeevan Babu Gotru <114808955+jeevan1098@users.noreply.github.com> Date: Thu, 12 Nov 2026 09:40:50 -0600 Subject: [PATCH 2/4] Python: fix OpenAPI plugin sending array and boolean parameters as Python repr --- .../openapi_plugin/test_sk_openapi.py | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/python/tests/unit/connectors/openapi_plugin/test_sk_openapi.py b/python/tests/unit/connectors/openapi_plugin/test_sk_openapi.py index 58f79f9850eb..1c08a3b50012 100644 --- a/python/tests/unit/connectors/openapi_plugin/test_sk_openapi.py +++ b/python/tests/unit/connectors/openapi_plugin/test_sk_openapi.py @@ -685,6 +685,56 @@ def test_build_query_string_with_optional_and_required_parameters(): assert operation.build_query_string(arguments) == expected_query_string +def test_build_query_string_with_array_and_boolean_parameters(): + parameters = [ + RestApiParameter(name="tags", type="array", location=RestApiParameterLocation.QUERY, is_required=False), + RestApiParameter(name="active", type="boolean", location=RestApiParameterLocation.QUERY, is_required=False), + ] + operation = RestApiOperation( + id="test", method="GET", servers=["https://example.com/"], path="/resource", params=parameters + ) + arguments = {"tags": ["red", "blue"], "active": True} + expected_query_string = "tags=red&tags=blue&active=true" + assert operation.build_query_string(arguments) == expected_query_string + + +def test_build_query_string_with_false_and_boolean_array_parameters(): + parameters = [ + RestApiParameter(name="active", type="boolean", location=RestApiParameterLocation.QUERY, is_required=False), + RestApiParameter(name="flags", type="array", location=RestApiParameterLocation.QUERY, is_required=False), + ] + operation = RestApiOperation( + id="test", method="GET", servers=["https://example.com/"], path="/resource", params=parameters + ) + arguments = {"active": False, "flags": [True, False]} + expected_query_string = "active=false&flags=true&flags=false" + assert operation.build_query_string(arguments) == expected_query_string + + +def test_build_path_with_boolean_parameter(): + parameters = [ + RestApiParameter(name="active", type="boolean", location=RestApiParameterLocation.PATH, is_required=True) + ] + operation = RestApiOperation( + id="test", method="GET", servers=["https://example.com/"], path="/resource/{active}", params=parameters + ) + arguments = {"active": True} + expected_path = "/resource/true" + assert operation.build_path(operation.path, arguments) == expected_path + + +def test_build_headers_with_boolean_parameter(): + parameters = [ + RestApiParameter(name="X-Active", type="boolean", location=RestApiParameterLocation.HEADER, is_required=True) + ] + operation = RestApiOperation( + id="test", method="GET", servers=["https://example.com"], path="test/path", params=parameters + ) + arguments = {"X-Active": False} + expected_headers = {"X-Active": "false"} + assert operation.build_headers(arguments) == expected_headers + + def test_create_payload_artificial_parameter_with_text_plain(): properties = [ RestApiPayloadProperty( From 2a029bfb90e48a0550e5084f3694930dd84d136b Mon Sep 17 00:00:00 2001 From: Jeevan Babu Gotru <114808955+jeevan1098@users.noreply.github.com> Date: Sun, 15 Nov 2026 09:24:13 -0600 Subject: [PATCH 3/4] Serialize array path and header parameters as comma-separated simple style --- .../models/rest_api_operation.py | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py b/python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py index 0fb295098f9e..10737326b39a 100644 --- a/python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py +++ b/python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py @@ -209,6 +209,18 @@ def _serialize_parameter_value(value: Any) -> Any: return "true" if value else "false" return value + @staticmethod + def _serialize_simple_parameter_value(value: Any) -> str: + """Serialize a value for a ``simple``-style parameter (path or header). + + ``simple`` is the OpenAPI default style for path and header parameters: + arrays are comma-separated, with each item serialized as a scalar + (so booleans inside an array also use the ``true``/``false`` spelling). + """ + if isinstance(value, (list, tuple)): + return ",".join(str(RestApiOperation._serialize_parameter_value(item)) for item in value) + return str(RestApiOperation._serialize_parameter_value(value)) + def build_headers(self, arguments: dict[str, Any]) -> dict[str, str]: """Build the headers for the operation.""" headers = {} @@ -226,7 +238,7 @@ def build_headers(self, arguments: dict[str, Any]) -> dict[str, str]: ) continue - headers[parameter.name] = str(self._serialize_parameter_value(argument)) + headers[parameter.name] = self._serialize_simple_parameter_value(argument) return headers @@ -339,9 +351,15 @@ def build_path(self, path_template: str, arguments: dict[str, Any]) -> str: f"required parameter of the operation - `{self.id}`." ) continue - path_template = path_template.replace( - f"{{{parameter.name}}}", quote(str(self._serialize_parameter_value(argument)), safe="") - ) + if isinstance(argument, (list, tuple)): + # `simple`-style arrays are comma-separated; quote each item on its + # own so the separator comma itself is not percent-encoded. + serialized_argument = ",".join( + quote(str(self._serialize_parameter_value(item)), safe="") for item in argument + ) + else: + serialized_argument = quote(str(self._serialize_parameter_value(argument)), safe="") + path_template = path_template.replace(f"{{{parameter.name}}}", serialized_argument) self._validate_path_segments(path_template) return path_template From 0c7b27d0ed75cd96940c41386793e59ac5e64155 Mon Sep 17 00:00:00 2001 From: Jeevan Babu Gotru <114808955+jeevan1098@users.noreply.github.com> Date: Sun, 15 Nov 2026 09:25:09 -0600 Subject: [PATCH 4/4] Serialize array path and header parameters as comma-separated simple style --- .../openapi_plugin/test_sk_openapi.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/python/tests/unit/connectors/openapi_plugin/test_sk_openapi.py b/python/tests/unit/connectors/openapi_plugin/test_sk_openapi.py index 1c08a3b50012..6467bd5ea61e 100644 --- a/python/tests/unit/connectors/openapi_plugin/test_sk_openapi.py +++ b/python/tests/unit/connectors/openapi_plugin/test_sk_openapi.py @@ -735,6 +735,40 @@ def test_build_headers_with_boolean_parameter(): assert operation.build_headers(arguments) == expected_headers +def test_build_path_with_array_parameter(): + parameters = [RestApiParameter(name="tags", type="array", location=RestApiParameterLocation.PATH, is_required=True)] + operation = RestApiOperation( + id="test", method="GET", servers=["https://example.com/"], path="/resource/{tags}", params=parameters + ) + arguments = {"tags": ["red", "blue"]} + expected_path = "/resource/red,blue" + assert operation.build_path(operation.path, arguments) == expected_path + + +def test_build_headers_with_array_parameter(): + parameters = [ + RestApiParameter(name="X-Tags", type="array", location=RestApiParameterLocation.HEADER, is_required=True) + ] + operation = RestApiOperation( + id="test", method="GET", servers=["https://example.com"], path="test/path", params=parameters + ) + arguments = {"X-Tags": ["red", "blue"]} + expected_headers = {"X-Tags": "red,blue"} + assert operation.build_headers(arguments) == expected_headers + + +def test_build_headers_with_boolean_array_parameter(): + parameters = [ + RestApiParameter(name="X-Flags", type="array", location=RestApiParameterLocation.HEADER, is_required=True) + ] + operation = RestApiOperation( + id="test", method="GET", servers=["https://example.com"], path="test/path", params=parameters + ) + arguments = {"X-Flags": [True, False]} + expected_headers = {"X-Flags": "true,false"} + assert operation.build_headers(arguments) == expected_headers + + def test_create_payload_artificial_parameter_with_text_plain(): properties = [ RestApiPayloadProperty(