CodecMacros
trait CodecMacros
Value members
Concrete methods
inline def derivedEnumeration[L, T](decode: L => Option[T], encode: T => L, default: Option[T])(implicit baseCodec: PlainCodec[L]): PlainCodec[T]
Creates a codec 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 codec 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.
- Type parameters:
- L
The type of the low-level representation of the enum, typically a String or an Int.
- T
The type of the enum.
- Value parameters:
- decode
How low-level values are decoded to the enum value.
None
if the low-level value is invalid, that is, when there's no high-level enum value.- encode
How the enum value is encoded as a low-level value.