Packages

trait JsonSchemas extends algebra.JsonSchemas

Enriches algebra.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

The data type description derivation is based on the underlying field and constructor names.

For instance, consider the following program that derives the description 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")
  ).invmap((User.apply _).tupled)(Function.unlift(User.unapply))
}
Source
JsonSchemas.scala
Linear Supertypes
algebra.JsonSchemas, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. JsonSchemas
  2. JsonSchemas
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. trait GenericJsonSchema[A] extends AnyRef
  2. trait GenericJsonSchemaLowLowPriority extends AnyRef
  3. trait GenericJsonSchemaLowPriority extends GenericJsonSchemaLowLowPriority
  4. abstract type JsonSchema[A]
    Definition Classes
    JsonSchemas
  5. implicit final class JsonSchemaOps[A] extends AnyRef
    Definition Classes
    JsonSchemas
  6. abstract type Record[A] <: JsonSchema[A]
    Definition Classes
    JsonSchemas
  7. final class RecordGenericOps[L <: HList] extends AnyRef
  8. implicit final class RecordOps[A] extends AnyRef
    Definition Classes
    JsonSchemas
  9. abstract type Tagged[A] <: JsonSchema[A]
    Definition Classes
    JsonSchemas
  10. implicit final class TaggedOps[A] extends AnyRef
    Definition Classes
    JsonSchemas

Abstract Value Members

  1. implicit abstract def arrayJsonSchema[C[X] <: Seq[X], A](implicit jsonSchema: JsonSchema[A], cbf: CanBuildFrom[_, A, C[A]]): JsonSchema[C[A]]
    Definition Classes
    JsonSchemas
  2. implicit abstract def bigdecimalJsonSchema: JsonSchema[BigDecimal]
    Definition Classes
    JsonSchemas
  3. implicit abstract def booleanJsonSchema: JsonSchema[Boolean]
    Definition Classes
    JsonSchemas
  4. abstract def choiceTagged[A, B](taggedA: Tagged[A], taggedB: Tagged[B]): Tagged[Either[A, B]]
    Definition Classes
    JsonSchemas
  5. implicit abstract def doubleJsonSchema: JsonSchema[Double]
    Definition Classes
    JsonSchemas
  6. abstract def field[A](name: String)(implicit tpe: JsonSchema[A]): Record[A]
    Definition Classes
    JsonSchemas
  7. implicit abstract def intJsonSchema: JsonSchema[Int]
    Definition Classes
    JsonSchemas
  8. abstract def invmapJsonSchema[A, B](jsonSchema: JsonSchema[A], f: (A) ⇒ B, g: (B) ⇒ A): JsonSchema[B]
    Definition Classes
    JsonSchemas
  9. abstract def invmapRecord[A, B](record: Record[A], f: (A) ⇒ B, g: (B) ⇒ A): Record[B]
    Definition Classes
    JsonSchemas
  10. abstract def invmapTagged[A, B](taggedA: Tagged[A], f: (A) ⇒ B, g: (B) ⇒ A): Tagged[B]
    Definition Classes
    JsonSchemas
  11. implicit abstract def longJsonSchema: JsonSchema[Long]
    Definition Classes
    JsonSchemas
  12. abstract def optField[A](name: String)(implicit tpe: JsonSchema[A]): Record[Option[A]]
    Definition Classes
    JsonSchemas
  13. implicit abstract def stringJsonSchema: JsonSchema[String]
    Definition Classes
    JsonSchemas
  14. abstract def taggedRecord[A](recordA: Record[A], tag: String): Tagged[A]
    Definition Classes
    JsonSchemas
  15. abstract def zipRecords[A, B](recordA: Record[A], recordB: Record[B]): Record[(A, B)]
    Definition Classes
    JsonSchemas

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. def genericJsonSchema[A](implicit genJsonSchema: GenericJsonSchema[A]): JsonSchema[A]

    returns

    a JsonSchema[A] obtained from an implicitly derived GenericJsonSchema[A] In a sense, this operation asks shapeless to compute a type level description of a data type (based on HLists and Coproducts) and turns it into a term level description of the data type (based on the JsonSchemas algebra interface)

  10. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  17. implicit def toRecordGenericOps[A](record: Record[A]): RecordGenericOps[::[A, HNil]]
  18. def toString(): String
    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  22. object GenericJsonSchema extends GenericJsonSchemaLowPriority

Inherited from algebra.JsonSchemas

Inherited from AnyRef

Inherited from Any

Ungrouped