All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sttp.tapir.derevo.schema.scala Maven / Gradle / Ivy

The newest version!
package sttp.tapir.derevo

import derevo.Derivation
import derevo.NewTypeDerivation
import sttp.tapir.Schema

import scala.reflect.macros.blackbox

object schema extends Derivation[Schema] with NewTypeDerivation[Schema] {
  def instance[A]: Schema[A] = macro SchemaCustomDerived.schema[A]

  def apply[A](description: String): Schema[A] = macro SchemaCustomDerived.schemaDescription[A]

}

class SchemaCustomDerived(val c: blackbox.Context) {

  import c.universe._

  def schema[T: c.WeakTypeTag]: c.Tree =
    q"sttp.tapir.Schema.derived[${weakTypeOf[T]}]"

  def schemaDescription[T: c.WeakTypeTag](description: c.Expr[String]): c.Tree = q"$schema.description($description)"

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy