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
Enumbug #204
Enumbug #204
Conversation
Codecov Report
@@ Coverage Diff @@
## master #204 +/- ##
==========================================
- Coverage 100% 99.97% -0.03%
==========================================
Files 170 170
Lines 4122 4130 +8
==========================================
+ Hits 4122 4129 +7
- Misses 0 1 +1
Continue to review full report at Codecov.
|
Thanks @euri10 , I'll check it soon. |
Thanks @euri10 , I'm delaying this until pydantic/pydantic#520 is resolved. It will change how responses are encoded from Pydantic models in a much cleaner way. And it will solve several issues at the same time (most probably including this). |
I think this should be solved in recent versions, so I'll close this now, but feel free to add more comments/issues/PRs 😉 🍰 |
Hi @tiangolo , I have refactored my projects with the orm_mode and the latest updates from both pydantic and fastapi. Enum are still encoded with their values, whatever the Config is...
|
Changing my mind. I think I did not understand correctly pydantic documentation on
I understand now that it is just a matter of passing either the Enum object, or the values (i.e. strings). I though I could choose between the name and the value, but that is not the case. My issue comes from full-stack-fastapi-postgresql, I will update tiangolo/full-stack-fastapi-template#23 with my findings |
Attempt at fixing #196
I have to admit I got no idea if the reported behavior by @ebreton is effectively a bug though, according to Pydantic docs the
use_enum_values
is quote:the default is effectively False so in the edfault case, it uses the raw value of the Enum, not the key of it, hence why I'm not sure if it's the right intent.