Error in OpenAPI schema generation with plain serializer when upgrading to pydantic 2.8.0 #11789
Unanswered
rossmacarthur
asked this question in
Questions
Replies: 2 comments 1 reply
-
Had the same issue around here, had to pin the pydantic version to 2.7.4 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Apparently, for some reason that I haven't investigated yet, you need to add def cents_to_dollars(v: Decimal, info: SerializationInfo) -> str:
v = v * Decimal("0.01")
v = v.quantize(Decimal("0.00000000"), rounding=ROUND_HALF_UP)
return format(v, "f") I just saw it in the the Pydantic v2.8 announcement and tryied with your example. Since it is a problem with your function beeing called with def cents_to_dollars(v: Decimal) -> str:
if v:
v = v * Decimal("0.01")
v = v.quantize(Decimal("0.00000000"), rounding=ROUND_HALF_UP)
return format(v, "f") |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
The above code works fine on pydantic 2.7.4 but errors on pydantic 2.8.0
Operating System
macOS
Operating System Details
No response
FastAPI Version
0.111.0
Pydantic Version
2.8.0
Python Version
3.11.7
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions