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
Ordering
- Alphabetic
- By Inheritance
Inherited
- JsonSchemas
- JsonSchemas
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- All
Type Members
- trait GenericJsonSchema[A] extends AnyRef
- trait GenericJsonSchemaLowLowPriority extends AnyRef
- trait GenericJsonSchemaLowPriority extends GenericJsonSchemaLowLowPriority
-
abstract
type
JsonSchema[A]
- Definition Classes
- JsonSchemas
-
implicit final
class
JsonSchemaOps[A] extends AnyRef
- Definition Classes
- JsonSchemas
-
abstract
type
Record[A] <: JsonSchema[A]
- Definition Classes
- JsonSchemas
- final class RecordGenericOps[L <: HList] extends AnyRef
-
implicit final
class
RecordOps[A] extends AnyRef
- Definition Classes
- JsonSchemas
-
abstract
type
Tagged[A] <: JsonSchema[A]
- Definition Classes
- JsonSchemas
-
implicit final
class
TaggedOps[A] extends AnyRef
- Definition Classes
- JsonSchemas
Abstract Value Members
-
implicit abstract
def
arrayJsonSchema[C[X] <: Seq[X], A](implicit jsonSchema: JsonSchema[A], cbf: CanBuildFrom[_, A, C[A]]): JsonSchema[C[A]]
- Definition Classes
- JsonSchemas
-
implicit abstract
def
bigdecimalJsonSchema: JsonSchema[BigDecimal]
- Definition Classes
- JsonSchemas
-
implicit abstract
def
booleanJsonSchema: JsonSchema[Boolean]
- Definition Classes
- JsonSchemas
-
abstract
def
choiceTagged[A, B](taggedA: Tagged[A], taggedB: Tagged[B]): Tagged[Either[A, B]]
- Definition Classes
- JsonSchemas
-
implicit abstract
def
doubleJsonSchema: JsonSchema[Double]
- Definition Classes
- JsonSchemas
-
abstract
def
field[A](name: String)(implicit tpe: JsonSchema[A]): Record[A]
- Definition Classes
- JsonSchemas
-
implicit abstract
def
intJsonSchema: JsonSchema[Int]
- Definition Classes
- JsonSchemas
-
abstract
def
invmapJsonSchema[A, B](jsonSchema: JsonSchema[A], f: (A) ⇒ B, g: (B) ⇒ A): JsonSchema[B]
- Definition Classes
- JsonSchemas
-
abstract
def
invmapRecord[A, B](record: Record[A], f: (A) ⇒ B, g: (B) ⇒ A): Record[B]
- Definition Classes
- JsonSchemas
-
abstract
def
invmapTagged[A, B](taggedA: Tagged[A], f: (A) ⇒ B, g: (B) ⇒ A): Tagged[B]
- Definition Classes
- JsonSchemas
-
implicit abstract
def
longJsonSchema: JsonSchema[Long]
- Definition Classes
- JsonSchemas
-
abstract
def
optField[A](name: String)(implicit tpe: JsonSchema[A]): Record[Option[A]]
- Definition Classes
- JsonSchemas
-
implicit abstract
def
stringJsonSchema: JsonSchema[String]
- Definition Classes
- JsonSchemas
-
abstract
def
taggedRecord[A](recordA: Record[A], tag: String): Tagged[A]
- Definition Classes
- JsonSchemas
-
abstract
def
zipRecords[A, B](recordA: Record[A], recordB: Record[B]): Record[(A, B)]
- Definition Classes
- JsonSchemas
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
genericJsonSchema[A](implicit genJsonSchema: GenericJsonSchema[A]): JsonSchema[A]
- returns
a
JsonSchema[A]obtained from an implicitly derivedGenericJsonSchema[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 theJsonSchemasalgebra interface)
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
- implicit def toRecordGenericOps[A](record: Record[A]): RecordGenericOps[::[A, HNil]]
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- object GenericJsonSchema extends GenericJsonSchemaLowPriority