Skip to content

feat: introduce Alias class for handling request parameter aliases. - #938

Open
renatodamas wants to merge 15 commits into
AnswerDotAI:mainfrom
renatodamas:feat/kebab-routers-parameters
Open

renatodamas wants to merge 15 commits into
AnswerDotAI:mainfrom
renatodamas:feat/kebab-routers-parameters

Conversation

@renatodamas

@renatodamas renatodamas commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Related Issue
Closes #937 (feature request: kebab-case / aliased request parameters).

Proposed Changes
Adds an opt-in Alias marker so handler parameters can read request data under a different name, e.g.:

from typing import Annotated
from fasthtml.common import Alias

@rt("/profile")
def get(user_id: Annotated[str, Alias("userId")]): ...

Changes in nbs/api/00_core.ipynb (source for fasthtml/core.py):
• New Alias dataclass, exported via fasthtml.common.
• find_p unwraps Annotated[T, ...] and uses the alias for path, cookie, query, form, htmx values, and header lookups (headers default to snake2hyphens when no alias is set).
• Missing-field errors report the alias name.
Parameters without Alias behave exactly as before.

Validation: tests/test_alias.py 9/9 pass. Full suite: 13 passed, 1 failed. test_toaster.py::test_get_toaster_with_typehint also fails on main, so it is pre-existing.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist
Go over all the following points, and put an x in all the boxes that apply:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I am aware that this is an nbdev project, and I have edited, cleaned, and synced the source notebooks instead of editing .py or .md files directly.

@renatodamas

Copy link
Copy Markdown
Contributor Author

The commit dfc4ea3 has implemented kebab-case parameter support (issue #937). PR #938 will be revised to focus solely on supporting completely different names for request parameters.

This branch has not been deployed

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

Support kebab-case parameter names via Annotated[..., Alias("...")]

2 participants