Thread
#serialization
    Eugen Martynov

    Eugen Martynov

    4 weeks ago
    I’m reading official documentation on GitHub, and it looks like I need to add
    SerialName
    to all implementations to serialise the sealed interface. However, when I try to test it, I see that serialiset is not found for the discriminator. Does it mean I have to define all subclasses when defining the serializable module?
    Dominaezzz

    Dominaezzz

    4 weeks ago
    You don't need to add it but it's good practice to do so. If the discriminator is missing then you're using the wrong serializer.
    Eugen Martynov

    Eugen Martynov

    4 weeks ago
    There is class with this discriminator that serialiser looks like can not find
    Dominaezzz

    Dominaezzz

    4 weeks ago
    Do you have a code snippet?
    Eugen Martynov

    Eugen Martynov

    4 weeks ago
    @Serializable
    internal sealed class SocketMessage : BaseSocketMessage {...
    
    @Serializable
    @SerialName("typing")
    internal data class TypingSocketMessage(...)
    Error:
    Polymorphic serializer was not found for class discriminator 'typing'
    Dominaezzz

    Dominaezzz

    4 weeks ago
    Shouldn't
    TypingSocketMessage
    extend
    SocketMessage
    ?
    Eugen Martynov

    Eugen Martynov

    4 weeks ago
    It does
    Dominaezzz

    Dominaezzz

    4 weeks ago
    How are you serializing?
    Eugen Martynov

    Eugen Martynov

    4 weeks ago
    private fun parseMessage(json: String): SocketMessage {
        return json.decodeFromString(json)
    Dominaezzz

    Dominaezzz

    4 weeks ago
    Nothing seems wrong from the snippets and messages. Create an issue with a reproducer.
    Eugen Martynov

    Eugen Martynov

    4 weeks ago
    Super thank you for the validation
    Paul Woitaschek

    Paul Woitaschek

    4 weeks ago
    Can you try with an explicit SocketMessage.serializer() It might be related to the serializer module
    Eugen Martynov

    Eugen Martynov

    4 weeks ago
    I will try it tomorrow
    @Dominaezzz You were right the class was extending the different interface - we have around 35 these messages and this one only one was different
    Dominaezzz

    Dominaezzz

    3 weeks ago
    Ah nice! Glad you found the issue.