TaggedOps

final implicit class TaggedOps[A](taggedA: Tagged[A]) extends JsonSchemaDocumentationOps[A]
class Object
trait Matchable
class Any

Type members

Types

type Self = Tagged[A]

Value members

Concrete methods

def named(name: String): Tagged[A]

Give a name to the schema

Give a name to the schema

  • Encoder and decoder interpreters ignore the name,
  • Documentation interpreters use that name to refer to this schema.
Note:

Names are used by documentation interpreters to construct references and the JSON schema specification requires these to be valid URI's. Consider using withTitle if you just want to override the heading displayed in documentation.

def orElse[B](taggedB: Tagged[B]): Tagged[Either[A, B]]

Define a schema that alternatively accepts taggedA or taggedB

Define a schema that alternatively accepts taggedA or taggedB

  • Encoder interpreters forward to taggedA to encode a Left value or to taggedB to encode a Right value,
  • Decoder interpreters decode the type tag from the JSON object and then forward to taggedA or taggedB according to its value,
  • Documentation interpreters produce a oneOf schema listing the alternatives in taggedA and the alternatives in taggedB.
def orElseMerge[B <: C, C >: A](taggedB: Tagged[B])(implicit cta: ClassTag[A], ctb: ClassTag[B]): Tagged[C]

Define a schema that alternatively accepts taggedA or taggedB and merges the result

Define a schema that alternatively accepts taggedA or taggedB and merges the result

Similar to orElse but instead of returning a Tagged[Either[A, B]], it returns a Tagged[C], where C is a super type of both A and B.

  • Encoder interpreters forward to taggedA or taggedB based on the runtime type information of the value to encode,
  • Decoder interpreters decode the type tag from the JSON object, forward to taggedA or taggedB accordingly, and then widen the result type to C,
  • Documentation interpreters produce a oneOf schema listing the alternatives in taggedA and the alternatives in taggedB.
See also:

isInstanceOf API documentation

Note:

Encoder interpreters rely on ClassTags to perform the runtime type test used for deciding whether to encode the C value as an A or a B. Consequently, types A and B must be distinct after erasure. Furthermore, the orElseMerge implementation requires the type B to ''not'' be a supertype of A. This should not happen in general. For instance, assuming three schemas, schema1, schema2, and schema3, for types having a common super-type, if you write schema1 orElseMerge schema2 orElseMerge schema3, then the right-hand side of orElseMerge is always a more specific type than its left-hand side. However, if you write schema1 orElseMerge (schema2 orElseMerge schema3) (note the parentheses), then the result of schema2 orElseMerge schema3 is a super-type of schema1. In such a case, the orElseMerge operation won’t work.

def withDescription(description: String): Tagged[A]

Override the name of the type discriminator field of this record.

Override the name of the type discriminator field of this record.

def withExample(example: A): Tagged[A]
def withTitle(title: String): Tagged[A]