SchemaCompanionMacros
Value members
Concrete methods
Creates a schema for an enumeration, where the validator is derived using sttp.tapir.Validator.derivedEnumeration. This requires
that all subtypes of the sealed hierarchy T
must be object
s.
Creates a schema for an enumeration, where the validator is derived using sttp.tapir.Validator.derivedEnumeration. This requires
that all subtypes of the sealed hierarchy T
must be object
s.
- Value parameters:
- encode
Specify how values of this type can be encoded to a raw value (typically a String; the raw form should correspond with
schemaType
). This encoding will be used when generating documentation.- schemaType
The low-level representation of the enumeration. Defaults to a string.
Create a coproduct schema (e.g. for a sealed trait
), where the value of the discriminator between child types is a read of a field
of the base type. The field, if not yet present, is added to each child schema.
Create a coproduct schema (e.g. for a sealed trait
), where the value of the discriminator between child types is a read of a field
of the base type. The field, if not yet present, is added to each child schema.
The schemas of the child types have to be provided explicitly with their value mappings in mapping
.
Note that if the discriminator value is some transformation of the child's type name (obtained using the implicit Configuration), the coproduct schema can be derived automatically or semi-automatically.
- Value parameters:
- discriminatorSchema
The schema that is used when adding the discriminator as a field to child schemas (if it's not yet in the schema).
Create a coproduct schema for an enum
, sealed trait
or sealed abstract class
, where to discriminate between child types a
wrapper product is used. The name of the sole field in this product corresponds to the type's name, transformed using the implicit
Configuration.
Create a coproduct schema for an enum
, sealed trait
or sealed abstract class
, where to discriminate between child types a
wrapper product is used. The name of the sole field in this product corresponds to the type's name, transformed using the implicit
Configuration.
See also Schema.wrapWithSingleFieldProduct, which creates the wrapper product given a schema.
Create a schema for a map with arbitrary keys. The schema for the keys (Schema[K]
) should be a string (that is, the schema type
should be sttp.tapir.SchemaType.SString), however this cannot be verified at compile-time and is not verified at run-time.
Create a schema for a map with arbitrary keys. The schema for the keys (Schema[K]
) should be a string (that is, the schema type
should be sttp.tapir.SchemaType.SString), however this cannot be verified at compile-time and is not verified at run-time.
The given keyToString
conversion function is used during validation.
If you'd like this schema to be available as an implicit for a given type of keys, create an custom implicit, e.g.:
case class MyKey(value: String) extends AnyVal
implicit val schemaForMyMap = Schema.schemaForMap[MyKey, MyValue](_.value)