Created
October 23, 2019 02:59
-
-
Save leosilvadev/ce4452616d0651ad0995d5ca6ebd277e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.sksamuel.avro4s.{AvroSchema, SchemaFor} | |
import org.apache.avro.Schema | |
import org.apache.avro.util.Utf8 | |
case class MyClass(id: Utf8, name: Utf8, familyName: Option[Utf8]) | |
object Main extends App { | |
implicit object Utf8Schema extends SchemaFor[Utf8] { | |
override def schema: Schema = Schema.create(Schema.Type.STRING) | |
} | |
implicit object OptionUtf8Schema extends SchemaFor[Option[Utf8]] { | |
override def schema: Schema = Schema.createUnion(Schema.create(Schema.Type.NULL), Schema.create(Schema.Type.STRING)) | |
} | |
val schema = AvroSchema[MyClass] | |
println(schema) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment