question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for sealed interfaces (across multiple files)

See original GitHub issue

I’m using a sealed interface and when I try to generate an avro schema for the sealed hierarchy I get:

Exception in thread "main" kotlinx.serialization.SerializationException: Unsupported type kotlinx.serialization.Polymorphic<SkillsCoachPublishedEvent> of OPEN
	at com.sksamuel.avro4k.schema.SchemaForKt.schemaFor(SchemaFor.kt:160)
	at com.sksamuel.avro4k.schema.ClassSchemaFor.buildField(ClassSchemaFor.kt:70)
	at com.sksamuel.avro4k.schema.ClassSchemaFor.dataClassSchema(ClassSchemaFor.kt:55)
	at com.sksamuel.avro4k.schema.ClassSchemaFor.schema(ClassSchemaFor.kt:43)
	at com.sksamuel.avro4k.Avro.schema(Avro.kt:239)
	at events.AvroSchemaGeneratorKt.main(AvroSchemaGenerator.kt:12)

it looks like kotlinx-serialization thinks this class is SerialKind.OPEN instead of SerialKind.SEALED so I guess this could be a kotlinx-serialization issue with sealed interfaces (not sure if being across multiple files matters)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
thakecommented, Sep 8, 2021

Implemented with #111

0reactions
thakecommented, Jul 25, 2022

Current main supports sealed interfaces

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sealed interfaces in Kotlin - ‍ Jorge Castillo
Sealed interfaces are Experimental. They may be dropped or changed at any time. You can give feedback on them in YouTrack. Subclass location....
Read more >
Kotlin: Sealed classes and Sealed Interfaces in 2022 - Medium
Sealed classes can now form more flexible hierarchies. They can have subclasses in all files of the same compilation unit and the same...
Read more >
Kotlin's Sealed Interfaces & The Hole in The Sealing
Sealed interfaces are a powerful new feature in Kotlin. But they can be easily misused. This article explains when and how to (not)...
Read more >
Sealed classes | Kotlin
Sealed classes and interfaces represent restricted class hierarchies that provide more control over inheritance. All direct subclasses of a ...
Read more >
Sealed interfaces and sealed classes freedom #226 - GitHub
Introduce the concept of a sealed interface. Allow more freedom to sealed class, unify both sealed interface and sealed class as the same ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found