Skip to content
Snippets Groups Projects
Commit 3ee389ea authored by Erin (Josh) Rigler's avatar Erin (Josh) Rigler
Browse files

Fix custom json encoder in pydantic+fastapi

Pydantic v1's json module contain[s|ed] a dictionary called `ENCODERS_BY_TYPE`
that was commonly used to overide default json encoders. Pydantic v2 is moving
away from this to a "better" system. FastAPI attempted to stay compatible with
both v1 and v2 by pulling ENCODERS_BY_TYPE into their own codebase, but this
broke our custom type `UTCDateTime`, at least for anything using fastapi.

We thought we fixed this with a recent MR, but it turns out all we did was
fix the validator. We did not fix the encoder itself. So, validation steps
would pass, but we continued to server malformed json for UTCDateTimes. This
commit reverts to the earlier version of pydantic_utcdatetime.py, and adds a
small kluge that modifies `ENCODERS_BY_TYPE` in both pydantic and fastapi.
parent 86abe9bf
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment