Skip to content

fix(event_handler): emit the Path alias in the OpenAPI schema when it matches the route template - #8812

Merged
leandrodamascena merged 1 commit into
developfrom
fix/openapi-path-alias
Nov 14, 2026
Merged

leandrodamascena merged 1 commit into
developfrom
fix/openapi-path-alias

Conversation

@leandrodamascena

Copy link
Copy Markdown
Contributor

Issue number:
closes #8803

Summary

Changes

Regression from #8630 in 3.39.0. Item 5 there made the OpenAPI path parameter name always the Python argument name, to cover def f(user_id: Path(alias="userId")) on a /<user_id> route. That broke the opposite case, def f(snake_id: Path(alias="camelId")) on /<camelId>: the schema emitted snake_id, which does not exist in the template, so the spec was invalid.

The schema generator now receives the placeholder names of the route and picks the one that exists in the template: the alias by default, the argument name only when the alias is not a placeholder and the name is. Same order the runtime already uses to resolve the value, so schema and behaviour agree.

Tests cover the alias matching the template, the alias not matching (the #8630 case, unchanged), and the plain parameter, in the schema and through the validation middleware.

A PR with this same fix was opened yesterday and disappeared with its author's account before I could approve it, so this re-lands the approach.

User experience

Before, on 3.39.0 and 3.40.0:

/P/{camelId} ['snake_id']

After:

/P/{camelId} ['camelId']

Runtime routing and validation answer the same in both cases; only the generated schema changes.

Verification

tests/functional/event_handler and tests/unit/event_handler: 1287 passed. ruff, mypy clean. Ran the three scenarios side by side on develop and on this branch, schema and runtime: only the alias case changes, and only in the schema. The xenon rank E on get_openapi_schema is pre-existing on develop and untouched here. Written with an AI assistant; I ran everything above myself.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@leandrodamascena
leandrodamascena requested a review from a team as a code owner November 14, 2026 13:18
@leandrodamascena leandrodamascena added this to the 3.41.0 milestone Nov 14, 2026
@leandrodamascena leandrodamascena added bug Something isn't working event_handlers labels Nov 14, 2026
@boring-cyborg boring-cyborg Bot added the tests label Nov 14, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 14, 2026
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.17%. Comparing base (d36ecdd) to head (0a028c3).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8812   +/-   ##
========================================
  Coverage    97.17%   97.17%           
========================================
  Files          323      323           
  Lines        16603    16606    +3     
  Branches      1503     1504    +1     
========================================
+ Hits         16134    16137    +3     
  Misses         328      328           
  Partials       141      141           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leandrodamascena
leandrodamascena merged commit 84f690a into develop Nov 14, 2026
19 checks passed
@leandrodamascena
leandrodamascena deleted the fix/openapi-path-alias branch November 14, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working event_handlers size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Path(alias=...) emits the Python argument name instead of the path template name regardless of whether alias is a closer match the path parameter

1 participant