Add Query(alias=...) for query parameters, fix wire name mismatch#264
Open
chassing wants to merge 1 commit into
Open
Add Query(alias=...) for query parameters, fix wire name mismatch#264chassing wants to merge 1 commit into
chassing wants to merge 1 commit into
Conversation
Lets a query parameter use a Python-friendly (ruff N803-safe) name via Annotated[..., Query(alias="...")] while still calling the API with its real name. The generator now emits this automatically whenever a query parameter's name isn't already valid snake_case, which also fixes a latent bug: such parameters were previously sent to the API under their sanitized Python name instead of the original one.
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.
Summary
clientele.api.Query(alias=...), a FastAPI-inspired marker usable viatyping.Annotated, so a query parameter can have a Python-friendly (ruffN803-safe) name while still being sent to the API under its real name (e.g.order_by: Annotated[str, Query(alias="orderBy")]).orderBy→order_by).?your_input=instead of?yourInput=).Test plan
tests/api/test_api_client.pyproving the wire-format alias is sent (and confirming they failed before the fix)tests/generators/api/test_clients.pytests/generators/api/test_fixture_schemas.pyusing the existingtests/fixtures/regression/dep_query_alias.jsonfixtureuv run pytest(583 passed)uv run mypy clientele(no new errors vs. main)uv run ruff check/ruff format --check