Skip to content

Fix erroneous encoding via contextual serialization #274

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

Merged
merged 1 commit into from
Apr 15, 2025

Conversation

n0900
Copy link
Contributor

@n0900 n0900 commented Apr 9, 2025

Issue:
In bigger structures, when the specific class was known, kotlinx.serialization would pick the generic polymorphic serializer for InputDescriptor instead of the specific InputDescriptorSerializer which is defined for the interface. In this case the type discriminator was added.

Solution:
To address this we force the serializer to use the contextual serializer instead which we set to the appropriate InputDescriptorSerializer.
To this end we also add a BaseInputDescriptorSerializer which only calls the DifInputDescriptor serializer without adding the type discriminator.
We need contextual serialization because InputDescriptor as an interface allows for open polymorphism and in our use case specifically QesInputDescriptor is not defined in the DIF artifact which means the Serializer cannot be hard-coded into the PresentationDefintion class.

Also added some tests.

@n0900 n0900 requested review from nodh and tlenz April 9, 2025 15:03
@n0900 n0900 self-assigned this Apr 10, 2025
Copy link
Contributor

@nodh nodh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@nodh nodh added this to the 5.5.2 milestone Apr 11, 2025
@n0900 n0900 merged commit 9c4c8fc into develop Apr 15, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants