-
Notifications
You must be signed in to change notification settings - Fork 429
Bug: Mongo ObjectIds not serializing out of the box #3892
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
Comments
Looking at this now |
Thank you for reporting this. Do you think it makes sense to include the custom serializer as part of the OpenAPI module? We could try to do that too. |
Yeah, I would like that. |
@aitchnyu I've wrote a simple PR that should enable you to use the custom serializer like intended. Can you check it to see if it looks good to you? I would appreciate your feedback :) |
Maybe I'm too tired to brain this, but
|
|
This is now released under 2.35.1 version! |
Expected Behaviour
My app has a custom serializer. I used enable_validation. A dict with Mongo ObjectId should have been serialized.
Current Behaviour
If we use enable_validation, the openapi modules uses its own encoders which cannot handle ObjectIds.
Code snippet
Possible Solution
My workaround is to monkey patch openapi encoder. Ideally openapi should reuse json encoder of APIGatewayRestResolver, or allow plugging in our own function.
Steps to Reproduce
Serialize an object which contains Mongo ObjectId
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.8
Packaging format used
PyPi
Debugging logs
No response
The text was updated successfully, but these errors were encountered: