Fix OpenAPI empty parameters (#1128)

This commit is contained in:
Fabrizio Sandri 2025-07-12 15:24:11 +02:00 committed by GitHub
commit 21ee0d3ea7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -367,7 +367,11 @@ class OpenAPITool(Tool):
) # Default explode for query is True
# Handle deepObject style for object parameters
if param_style == "deepObject" and isinstance(param_value, dict):
if (
param_style == "deepObject"
and isinstance(param_value, dict)
and len(param_value) > 0
):
if param_explode:
# deepObject with explode=true: object properties become separate parameters
# e.g., target[id]=123&target[type]=user
@ -386,6 +390,7 @@ class OpenAPITool(Tool):
elif (
isinstance(param_value, list)
and p.schema_.get("type") == "array"
and len(param_value) > 0
):
if param_explode:
# When explode=True, we pass the array directly, which HTTPX will serialize