TaggedOps
Value members
Concrete methods
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.
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 aLeft
value or totaggedB
to encode aRight
value, - Decoder interpreters decode the type tag from the JSON object and then
forward to
taggedA
ortaggedB
according to its value, - Documentation interpreters produce a
oneOf
schema listing the alternatives intaggedA
and the alternatives intaggedB
.
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
ortaggedB
based on the runtime type information of the value to encode, - Decoder interpreters decode the type tag from the JSON object, forward to
taggedA
ortaggedB
accordingly, and then widen the result type toC
, - Documentation interpreters produce a
oneOf
schema listing the alternatives intaggedA
and the alternatives intaggedB
.
- See also:
isInstanceOf API documentation
- Note:
Encoder interpreters rely on
ClassTag
s to perform the runtime type test used for deciding whether to encode theC
value as anA
or aB
. Consequently, typesA
andB
must be distinct after erasure. Furthermore, theorElseMerge
implementation requires the typeB
to ''not'' be a supertype ofA
. This should not happen in general. For instance, assuming three schemas,schema1
,schema2
, andschema3
, for types having a common super-type, if you writeschema1 orElseMerge schema2 orElseMerge schema3
, then the right-hand side oforElseMerge
is always a more specific type than its left-hand side. However, if you writeschema1 orElseMerge (schema2 orElseMerge schema3)
(note the parentheses), then the result ofschema2 orElseMerge schema3
is a super-type ofschema1
. In such a case, theorElseMerge
operation won’t work.