pl.iterators.kebs.jsonschema.macros.KebsJsonSchemaMacros.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kebs-jsonschema_2.13 Show documentation
Show all versions of kebs-jsonschema_2.13 Show documentation
Automatic generation of JSON Schemas for case classes
The newest version!
package pl.iterators.kebs.jsonschema.macros
import scala.reflect.macros._
import pl.iterators.kebs.core.macros.MacroUtils
import pl.iterators.kebs.jsonschema.JsonSchemaWrapper
class KebsJsonSchemaMacros(override val c: whitebox.Context) extends MacroUtils {
import c.universe._
final def materializeSchema[T: c.WeakTypeTag]: c.Expr[JsonSchemaWrapper[T]] = {
val T = weakTypeOf[T]
val tree =
q"""{
val schema = _root_.json.Json.schema[$T]
_root_.pl.iterators.kebs.jsonschema.JsonSchemaWrapper(schema)
}"""
c.Expr[JsonSchemaWrapper[T]](tree)
}
}