-
Notifications
You must be signed in to change notification settings - Fork 37
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
Generic classes lead to serialisation issues #153
Comments
Hey @upMKuhn, this seems to be a bug in avro4k. Thanks for bringing it up. Can you provide a branch with a Junit-Testcase? This helps a lot to track down the cause. |
Thanks, I will have a look into it! |
Hey @upMKuhn, I've dug a little bit deeper and found an Avro-Issue that states that Avro, as of now, does not support parameterized types. Until this issue is resolved, I wouldn't know how to correctly generate a schema for a parameterized type. As a workaround, you could do the following: ```kotlin
@Serializable
data class Owner(
val brokerId: String,
val type: Int,
val name: List<StringDatedValue>,
val quantity: List<DoubleDatedValue>
)
interface DatedValue<T> {
val asOfDate: LocalDate
val value: T
}
@Serializable
data class StringDatedValue(
@Serializable(with = LocalDateSerializer::class)
override val asOfDate: LocalDate,
override val value: String
) : DatedValue<String>
@Serializable
data class DoubleDatedValue(
@Serializable(with = LocalDateSerializer::class)
override val asOfDate: LocalDate,
override val value: Double
) : DatedValue<Double> |
Nice thank you! |
But in parallel, kotlinx serialization should handle nested generics, another feature to take into account in #148 |
Closing this issue for now. If parameterized types are supported in avro, we'll open a new issue. |
Hello,
I have a class called DatedValue of type String and Double. The schema for this class is generated wrongly. As you can see the first
definition says the value is of type string and then this reference is wrongly repeated. Is this a bug in avro4k or a limitation in avro schemas?
Thank you!
Schema
The text was updated successfully, but these errors were encountered: