avro-kotlin / avro4k

Avro format support for Kotlin
Apache License 2.0
198 stars 37 forks source link

Polymorphic open support (Take 2) #110

Closed williamboxhall closed 3 years ago

williamboxhall commented 3 years ago

This is a replacement for https://github.com/avro-kotlin/avro4k/pull/109 - Forking this on my personal account to make it easier for @thake to make changes to it.

This PR adds support for open / unsealed / abstract classes to generate avro schemas and serialize/deserialize avro binary, configured like so:

val module = SerializersModule {
   polymorphic(UnsealedPolymorphicRoot::class) {
      subclass(UnsealedChildOne::class)
      subclass(UnsealedChildTwo::class)
   }
}
val schema = Avro(serializersModule = module).schema(UnsealedPolymorphicRoot.serializer())

For now it explicitly doesn't support polymorphic defaults - this is a feature someone could build on top if they want to.

williamboxhall commented 3 years ago

Hey @thake, if it's still too hard to figure out collaboration on the cultureamp branch PR then we can just do it here instead - whatever works for you.

thake commented 3 years ago

@williamboxhall If you approve the changes made to your PR I will merge it and build a new release.

williamboxhall commented 3 years ago

@thake I approve the changes and very much appreciate it!

thake commented 3 years ago

@williamboxhall thank you very much for your work! I will prepare a relase.

williamboxhall commented 3 years ago

Thanks @thake!