Creating an AVRO Schema from a JSON Schema File

I have a JSON and JSON Schema file for analysis in an AVRO scheme. I'm a little confused, I need to write a manual AVRO schema using the data types defined in the AVRO documentation.

Or is there some kind of automated method / function / program that can work exactly as required

+4
source share
2 answers

Well, you can try https://github.com/fge/json-schema-avro , but they say that it is not completed yet. So not sure if this will work though

+1
source

avro4s prints schemas at compile time from case classes:

import com.sksamuel.avro4s.SchemaFor

object Avro {
  case class MyAvroClass(s: String, i: Int)

  def main(args: Array[String]): Unit = {
    val avroSchema = SchemaFor[MyAvroClass]()
    println(avroSchema.toString(true))
  }
}

Productivity:

{
  "type" : "record",
  "name" : "MyAvroClass",
  "namespace" : "tests",
  "fields" : [ {
    "name" : "s",
    "type" : "string"
  }, {
    "name" : "i",
    "type" : "int"
  } ]
}
-1
source

All Articles