feat(event_handler): add support for Pydantic models in Query and Header types - WIP#7076
Closed
leandrodamascena wants to merge 6 commits into
Closed
feat(event_handler): add support for Pydantic models in Query and Header types - WIP#7076leandrodamascena wants to merge 6 commits into
leandrodamascena wants to merge 6 commits into
Conversation
2 tasks
This was referenced Jul 30, 2025
2 tasks
Contributor
|
|
tonnico
reviewed
Aug 16, 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) |
Contributor
There was a problem hiding this comment.
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.
tonnico
reviewed
Aug 16, 2025
|
|
||
| body = json.loads(result["body"]) | ||
| assert body["fullName"] == "Snake Case Test" | ||
| assert body["nextToken"] == "token789" |
Contributor
There was a problem hiding this comment.
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, | ||
| ) |
Contributor
There was a problem hiding this comment.
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 |
Contributor
There was a problem hiding this comment.
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 |
Contributor
Author
|
Closing in favor of #7253 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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.