Skip to content

feat(event_handler): add support for Pydantic models in Query and Header types - WIP #7076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

leandrodamascena
Copy link
Contributor

Issue number: #7039
Related: #5325

Summary

Changes

TBD

User experience

TBD

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

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

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 30, 2025
@leandrodamascena leandrodamascena linked an issue Jul 30, 2025 that may be closed by this pull request
2 tasks
@leandrodamascena leandrodamascena self-assigned this Jul 30, 2025
@github-actions github-actions bot added the feature New feature or functionality label Jul 30, 2025
@leandrodamascena leandrodamascena changed the title feat(event_handler): add supoort for Pydantic models in Query and Header types - WIP feat(event_handler): add support for Pydantic models in Query and Header types - WIP Jul 30, 2025
@leandrodamascena leandrodamascena linked an issue Jul 30, 2025 that may be closed by this pull request
2 tasks
@pull-request-size pull-request-size bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 8, 2025
Copy link
Contributor

github-actions bot commented Aug 8, 2025

⚠️Large PR detected⚠️

Please consider breaking into smaller PRs to avoid significant review delays. Ignore if this PR has naturally grown to this size after reviews.

Copy link

sonarqubecloud bot commented Aug 8, 2025

assert body["nextToken"] == "dGVzdA=="
assert body["id"] == "search-456"

# Test QueryAdvanced with snake_case field names (should also work due to populate_by_name behavior)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to test populate_by_name behavior you either need to use populate_by_name or set validate_by_name and validate_by_alias.


body = json.loads(result["body"])
assert body["fullName"] == "Snake Case Test"
assert body["nextToken"] == "token789"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert body["nextToken"] == "token789"
assert body["nextToken"] == "dGVzdA=="

Comment on lines +2300 to +2303
alias_generator=alias_generators.to_camel,
validate_by_alias=True,
serialize_by_alias=True,
)
Copy link
Contributor

@tonnico tonnico Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same for populate_by_alias and is prefered for pydantic >2.11.

Suggested change
alias_generator=alias_generators.to_camel,
validate_by_alias=True,
serialize_by_alias=True,
)
alias_generator=alias_generators.to_camel,
validate_by_alias=True,
validate_by_name=True,
serialize_by_alias=True,
)

try:
model_data[field_alias] = query_string[field_alias][0]
except KeyError:
pass
Copy link
Contributor

@tonnico tonnico Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pass
if model_class.model_config.get("validate_by_name") or model_class.model_config.get("populate_by_name"):
try:
model_data[field_alias] = query_string[field_name][0]
except KeyError:
pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event_handlers feature New feature or functionality size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: alias generator for Query, Path or Header Feature request: improve support for parameter injection
2 participants