snowplow / iglu

Iglu is a machine-readable, open-source schema repository for JSON Schema from the team at Snowplow
http://www.snowplow.io
Apache License 2.0
208 stars 45 forks source link

Scala Core: add Schemaed type class #436

Closed chuwy closed 5 years ago

chuwy commented 6 years ago

It proclaims at type-level that ADT has a SchemaKey.

trait Schemaed[A] {
  def schema: SchemaKey
}

sealed trait MyAdt
case class Foo(a: String) extends MyAdt
case class Bar(b: Int) extends MyAdt

implicit val myAdtSchema: Schemaed[MyAdt] = new Schemaed[MyAdt] {
  def schema = SchemaKey("com.acme", "foo_or_bar", "jsonschema", SchemaVer(1,0,0))
}

SchemaKey.of[MyAdt].asString // iglu:com.acme/foo_or_bar/jsonschema/1-0-0
aldemirenes commented 5 years ago

Migrated to https://github.com/snowplow-incubator/iglu-scala-core/issues/21