-
Notifications
You must be signed in to change notification settings - Fork 444
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
base: develop
Are you sure you want to change the base?
feat(event_handler): add support for Pydantic models in Query and Header types - WIP #7076
Conversation
|
|
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) |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert body["nextToken"] == "token789" | |
assert body["nextToken"] == "dGVzdA==" |
alias_generator=alias_generators.to_camel, | ||
validate_by_alias=True, | ||
serialize_by_alias=True, | ||
) |
There was a problem hiding this comment.
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.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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:
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.