[python] serialize booleans as lowercase in all parameter styles#24359
Open
fa0311 wants to merge 3 commits into
Open
[python] serialize booleans as lowercase in all parameter styles#24359fa0311 wants to merge 3 commits into
fa0311 wants to merge 3 commits into
Conversation
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.
The manual header test asserted the old buggy 'True'; with booleans now serialized as 'true' the echo server reflects 'true'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Boolean parameters serialize as Python
True/Falsein every place except a top-level query value, so a strict server rejects them.parameters_to_url_querylowercased a scalar boolean query value, but booleans inside a collection went throughstr():Path, header and form parameters had no boolean handling at all:
The fix lowercases booleans in
parameters_to_tuples(covers path, header, form and the multi branch) and in the collection branches ofparameters_to_url_query. After it: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
./mvnw clean packageand regenerated the python samples.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.
parameters_to_tuplesand collection handling inparameters_to_url_query.true.Written for commit b2e9e74. Summary will update on new commits.