avro-kotlin / avro4k

Avro format support for Kotlin
Apache License 2.0
188 stars 36 forks source link

Support char type #195

Open Chuckame opened 2 months ago

Chuckame commented 2 months ago

Currently, this code produces an error:

@Serializable
data class Foo(
    val e: Char,
)
Avro.schema(Foo.serializer())
// or
Avro.schema(Char.serializer())
// -> Unsupported type kotlin.Char of CHAR

Proposal

Generates the corresponding schema as an int (replicates apache's avro behavior) and apply the char logical type. This would generate the following schema:

{
   "type": "int",
   "logicalType": "char"
}