Skip to content

[python] serialize booleans as lowercase in all parameter styles#24359

Open
fa0311 wants to merge 3 commits into
OpenAPITools:masterfrom
fa0311:fix/python-bool-param-serialization
Open

[python] serialize booleans as lowercase in all parameter styles#24359
fa0311 wants to merge 3 commits into
OpenAPITools:masterfrom
fa0311:fix/python-bool-param-serialization

Conversation

@fa0311

@fa0311 fa0311 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Boolean parameters serialize as Python True/False in every place except a top-level query value, so a strict server rejects them.

parameters_to_url_query lowercased a scalar boolean query value, but booleans inside a collection went through str():

?flags=True,False        # csv array
?multi=True&multi=False  # exploded array

Path, header and form parameters had no boolean handling at all:

/pets/True               # boolean path param

The fix lowercases booleans in parameters_to_tuples (covers path, header, form and the multi branch) and in the collection branches of parameters_to_url_query. After it:

/pets/true
?single=false&flags=true,false&multi=true&multi=false

and boolean headers serialize as true.

Verified against a generated client covering path / query (scalar, csv, exploded) / header booleans; petstore sample tests still pass.

PR checklist

  • Read the contribution guidelines.
  • Ran ./mvnw clean package and regenerated the python samples.
  • Filed the PR against master.

/cc @cbornet @tomplus @krjakbrjak


Summary by cubic

Lowercase boolean serialization across all Python client parameter styles to ensure servers receive true/false instead of True/False. Fixes strict servers rejecting mixed-case booleans.

  • Bug Fixes
    • Lowercase bools in path, header, form, and query (scalar, csv, multi).
    • Implemented in parameters_to_tuples and collection handling in parameters_to_url_query.
    • Regenerated Python samples and updated echo_api header test to expect true.

Written for commit b2e9e74. Summary will update on new commits.

Review in cubic

fa0311 added 2 commits July 20, 2026 06:59
parameters_to_url_query lowercased a top-level boolean query value, but
booleans inside collections went through str() and ended up as True/False
on the wire (?flags=True,False). Path, header and form parameters had no
boolean handling at all, producing /pets/True style urls. Lowercase them
in parameters_to_tuples and in the collection branches of
parameters_to_url_query as well.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

Re-trigger cubic

The manual header test asserted the old buggy 'True'; with booleans now
serialized as 'true' the echo server reflects 'true'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant