trait JsonSchemas extends algebra.JsonSchemas
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
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") ).xmap((User.apply _).tupled)(Function.unlift(User.unapply)) }
- Source
- JsonSchemas.scala
- Alphabetic
- By Inheritance
- JsonSchemas
- JsonSchemas
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
abstract
type
Enum[A] <: JsonSchema[A]
- Definition Classes
- JsonSchemas
- 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], factory: scala.collection.compat.Factory[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
-
implicit abstract
def
byteJsonSchema: JsonSchema[Byte]
- 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
emptyRecord: Record[Unit]
- Definition Classes
- JsonSchemas
-
abstract
def
enumeration[A](values: Seq[A])(encode: (A) ⇒ String)(implicit tpe: JsonSchema[String]): Enum[A]
- Definition Classes
- JsonSchemas
-
abstract
def
field[A](name: String, documentation: Option[String])(implicit tpe: JsonSchema[A]): Record[A]
- Definition Classes
- JsonSchemas
-
implicit abstract
def
floatJsonSchema: JsonSchema[Float]
- Definition Classes
- JsonSchemas
-
implicit abstract
def
intJsonSchema: JsonSchema[Int]
- Definition Classes
- JsonSchemas
-
abstract
def
lazySchema[A](schema: ⇒ JsonSchema[A], name: String): JsonSchema[A]
- Definition Classes
- JsonSchemas
-
implicit abstract
def
longJsonSchema: JsonSchema[Long]
- Definition Classes
- JsonSchemas
-
implicit abstract
def
mapJsonSchema[A](implicit jsonSchema: JsonSchema[A]): JsonSchema[Map[String, A]]
- Definition Classes
- JsonSchemas
-
abstract
def
named[A, S[T] <: JsonSchema[T]](schema: S[A], name: String): S[A]
- Definition Classes
- JsonSchemas
-
abstract
def
optField[A](name: String, documentation: Option[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
-
implicit abstract
def
uuidJsonSchema: JsonSchema[UUID]
- Definition Classes
- JsonSchemas
-
abstract
def
withDiscriminator[A](tagged: Tagged[A], discriminatorName: String): Tagged[A]
- Definition Classes
- JsonSchemas
-
abstract
def
xmapJsonSchema[A, B](jsonSchema: JsonSchema[A], f: (A) ⇒ B, g: (B) ⇒ A): JsonSchema[B]
- Definition Classes
- JsonSchemas
-
abstract
def
xmapRecord[A, B](record: Record[A], f: (A) ⇒ B, g: (B) ⇒ A): Record[B]
- Definition Classes
- JsonSchemas
-
abstract
def
xmapTagged[A, B](taggedA: Tagged[A], f: (A) ⇒ B, g: (B) ⇒ A): Tagged[B]
- 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( ... )
-
def
defaultDiscriminatorName: String
- Definition Classes
- JsonSchemas
-
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 arg0: ClassTag[A], 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) This operation is calculating a name for the schema based on classTag.runtimeClass.getName This could result in non unique values and mess with documentation
-
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
-
def
namedGenericJsonSchema[A](name: String)(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) This operation is using the name provided Please be aware that this name should be unique or documentation will not work properly
-
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