You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The use of Annotated combined with a WrapSerializer prevents a custom serializer from being used.
The following example code should be self-explanatory:
Hmm, thanks for reporting this. I don't think this is necessarily a bug, but perhaps a change request. Looks like the current behavior is such that the custom get schema function overrides any changes applied via annotations.
@adriangb, is this intentional? Is this something we want to change?
Looks like the current behavior is such that the custom get schema function overrides any changes applied via annotations.
you got that backwards: the annotation is overriding the custom serializer of the type.
From an implementation point-of-view, I get why you'd think this is more a limitation than a bug, since the workaround for a user is pretty straightforward. However, I'd definitely argue that this is conceptually a bug. Also, it can be very disorientating for a user using a custom type from a 3rd-party library: here the user would likely not be aware beforehand that the custom type is using a custom serializer method, and would annotate it all the same in their code, at which point they would be confused as to why their WrapSerializer doesn't actually wrap the expected serialization.
Initial Checks
Description
The use of
Annotated
combined with aWrapSerializer
prevents a custom serializer from being used.The following example code should be self-explanatory:
Example Code
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: