TaggedOps

endpoints4s.algebra.JsonSchemas.TaggedOps
final implicit class TaggedOps[A](taggedA: Tagged[A]) extends JsonSchemaDocumentationOps[A]

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

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.

Attributes

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.

Attributes

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.

Attributes

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]

Include a description of what this schema represents

Include a description of what this schema represents

  • Encoder and decoder interpreters ignore this description,
  • Documentation interpreters can show this description.

Value parameters

description

information about the values described by the schema

Attributes

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

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

Attributes

def withExample(example: A): Tagged[A]

Include an example of value in this schema

Include an example of value in this schema

  • Encoder and decoder interpreters ignore this value,
  • Documentation interpreters can show this example value.

Value parameters

example

Example value to attach to the schema

Attributes

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

Include a title for the schema

Include a title for the schema

  • Encoder and decoder interpreters ignore the title,
  • Documentation interpreters can show this title.

Value parameters

title

short title to attach to the schema

Attributes