Starting from Pydantic 2.4, the solution in the next link worked great for me, fixing also the problem that FastAPI was unable to generate the OpenAPI documentation when using the previous workaround.
1 Like