Packages

p

endpoints

generic

package generic

Type Members

  1. trait JsonSchemas extends algebra.JsonSchemas

    Enriches JsonSchemas with two kinds of operations:

    Enriches JsonSchemas with two kinds of operations:

    • genericJsonSchema[A] derives the JsonSchema of an algebraic data type A;
    • (field1 :×: field2 :×: …).as[A] builds a tuple of Records and maps it to a case class A

    For instance, consider the following program that derives the JSON schema of a case class:

    case class User(name: String, age: Int)
    object User {
      implicit val schema: JsonSchema[User] = genericJsonSchema[User]
    }

    It is equivalent to the following:

    case class User(name: String, age: Int)
    object User {
      implicit val schema: JsonSchema[User] = (
        field[String]("name") zip
        field[Int]("age")
      ).xmap((User.apply _).tupled)(Function.unlift(User.unapply))
    }
  2. case class discriminator(name: String) extends Annotation with Product with Serializable

    Defines the name of the discriminator field of a generic tagged schema.

    Defines the name of the discriminator field of a generic tagged schema.

    Annotate a sealed trait definition with this annotation to define the name of its discriminator field.

    name

    Name of the tagged discriminator field

  3. case class docs(text: String) extends Annotation with Product with Serializable

    Documents a case class field.

    Documents a case class field.

    Annotate a case class field with this annotation to define its documentation.

    text

    Description of the annotated field

  4. case class name(value: String) extends Annotation with Product with Serializable

    Defines the name of a generic schema.

    Defines the name of a generic schema.

    Annotate a sealed trait or case class definition with this annotation to define its schema name.

    value

    Name of the schema

Ungrouped