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
What is your use-case and why do you need this feature?
If a type is annotated with @Contextual, but there is no serializer in context, it will use the type's own serializer (i.e. plugin-generated) if it has one. This is contained in the ContextualSerializer.fallbackSerializer property, which is private. I'm trying to do some schema introspection (based on descriptors) and this is making it impossible to have my introspected schema match the actual behavior, since I can't identify the fallback serializer used (I'm doing this in the context of a serializers module, so resolving the serializer itself is not an issue).
Describe the solution you'd like
Make SerializersModule.getContextualDescriptor return the fallback serializer's descriptor if the fallback serializer would be used (or add an overload that does this).
It's simple enough to implement, if you approve the idea I'm happy to make a PR.
The text was updated successfully, but these errors were encountered:
Yeah, I like the idea, it is intended for descriptors to match the behavior of serializers. However, implementing it may not be straightforward, since by the time we have ContextualSerializer.descriptor, we already have lost reference to fallbackSerializer, since it is stored only inside ContextualSerializer itself. Therefore, fallbackSerializer.descriptor has to be stored additionally somewhere. I'm not sure if it is better to store it in ContextDescriptor (because it is also being used by PolymorphicSerializer) or to store it directly in ContextualSerializer.descriptor (and making it a separate internal implementation of SerialDescriptor interface).
Btw. there is a workaround way to "get" the serializer from the contextual serializer by calling deserialize with a special decoder that has no module and will record the serializer provided - it can then throw an exception instead of actually deserializing (from nothing). It would be good to get this information in a better way (especially when it would need nested "deserialization").
As an aside, there is a similar issue with NullableSerializer, although the serial descriptor is normally detailed enough.
What is your use-case and why do you need this feature?
If a type is annotated with
@Contextual
, but there is no serializer in context, it will use the type's own serializer (i.e. plugin-generated) if it has one. This is contained in theContextualSerializer.fallbackSerializer
property, which is private. I'm trying to do some schema introspection (based on descriptors) and this is making it impossible to have my introspected schema match the actual behavior, since I can't identify the fallback serializer used (I'm doing this in the context of a serializers module, so resolving the serializer itself is not an issue).Describe the solution you'd like
Make
SerializersModule.getContextualDescriptor
return the fallback serializer's descriptor if the fallback serializer would be used (or add an overload that does this).It's simple enough to implement, if you approve the idea I'm happy to make a PR.
The text was updated successfully, but these errors were encountered: