-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
Description
Right now, we have some inconsistent behavior in terms of using aliases in validation and serialization.
By default, if an alias or validation_alias is defined on a field, we use the alias for validation. This behavior can be changed by setting populate_by_name to True on the model_config.
Conversely, if an alias or serialization_alias is defined on a field, that alias not used by default for serialization. We must specify by_alias=True in the call to model_dump + other serialization functions.
I propose that in V3:
- We use
aliasby default for both validation and serialization - We add a field (or fields, but ideally just one) to
ConfigDictto support different behavior than the default
This is a breaking change, hence the V3 label.
Requests to change the inconsistent default behavior have been made for a few years, so I'm going to comb through issues and close those so we can centralize discussion here.
bijlpieter, marcussaad, bluenote10, latk, justin-snyder-slgg and 43 more