Closed upMKuhn closed 10 months ago
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