Skip to content

Add Query(alias=...) for query parameters, fix wire name mismatch#264

Open
chassing wants to merge 1 commit into
phalt:mainfrom
chassing:2026-07-17_query-parameters
Open

Add Query(alias=...) for query parameters, fix wire name mismatch#264
chassing wants to merge 1 commit into
phalt:mainfrom
chassing:2026-07-17_query-parameters

Conversation

@chassing

Copy link
Copy Markdown
Contributor

Summary

  • Add clientele.api.Query(alias=...), a FastAPI-inspired marker usable via typing.Annotated, so a query parameter can have a Python-friendly (ruff N803-safe) name while still being sent to the API under its real name (e.g. order_by: Annotated[str, Query(alias="orderBy")]).
  • Generated clients now emit this automatically whenever a query parameter's name isn't already valid snake_case (e.g. orderByorder_by).
  • Fixes a latent bug this also surfaces: such query parameters were previously sent to the API under their sanitized Python name instead of the original spec name (e.g. ?your_input= instead of ?yourInput=).

Test plan

  • New runtime tests in tests/api/test_api_client.py proving the wire-format alias is sent (and confirming they failed before the fix)
  • New generator unit tests in tests/generators/api/test_clients.py
  • New end-to-end generator test in tests/generators/api/test_fixture_schemas.py using the existing tests/fixtures/regression/dep_query_alias.json fixture
  • uv run pytest (583 passed)
  • uv run mypy clientele (no new errors vs. main)
  • uv run ruff check / ruff format --check

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.
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