-
Notifications
You must be signed in to change notification settings - Fork 429
feat(event_handler): enable support for custom deserializer to parse the request body #6601
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): enable support for custom deserializer to parse the request body #6601
Conversation
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
Hi @LucasCMFBraga, thanks for working on this PR! I've reviewed it and to me it makes sense for us to add these new parameter to propagate it to DataClasses, but I'm wondering if we're parsing float incorrectly and if it would make sense to make it default here: https://github.com/aws-powertools/powertools-lambda-python/blob/develop/aws_lambda_powertools/utilities/data_classes/common.py#L89 WDYT? |
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #6601 +/- ##
========================================
Coverage 96.12% 96.12%
========================================
Files 253 253
Lines 12104 12105 +1
Branches 902 902
========================================
+ Hits 11635 11636 +1
Misses 369 369
Partials 100 100 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
We could set Decimal as the default for parsing numeric values in JSON, but I would also allow the option to pass a custom JSON deserializer for parsing the request body. |
Issue number: #6600
Summary
This feature allows to pass a custom deserializer to ensure accurate handling of floating-point precision.
Changes
`
from tests.functional.utils import load_even
import json
from decimal import Decimal
app = ApiGatewayResolver(deserializer=partial(json.loads, parse_float=Decimal))
`
User experience
`
app = ApiGatewayResolver(deserializer=partial(json.loads, parse_float=Decimal))
`
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.