Pickler

sttp.tapir.json.pickler.Pickler
See thePickler companion class
object Pickler

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Pickler.type

Members list

Type members

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

inline def derived[T : ClassTag](implicit evidence$1: ClassTag[T], PicklerConfiguration): Pickler[T]

Derive a Pickler instance for the given type, at compile-time. Depending on the derivation mode (auto / semi-auto), picklers for referenced types (e.g. via a field, enum case or subtype) will either be derived automatically, or will need to be provided manually.

Derive a Pickler instance for the given type, at compile-time. Depending on the derivation mode (auto / semi-auto), picklers for referenced types (e.g. via a field, enum case or subtype) will either be derived automatically, or will need to be provided manually.

This method can either be used explicitly, in the definition of a given, or indirectly by adding a ... derives Pickler modifier to a datatype definition.

The in-scope PicklerConfiguration instance is used to customise field names and other behavior.

Attributes

inline def derivedEnumeration[T : ClassTag](implicit evidence$1: ClassTag[T], Of[T]): CreateDerivedEnumerationPickler[T]

Creates a pickler for an enumeration, where the validator is derived using sttp.tapir.Validator.derivedEnumeration. This requires that this is an enum, where all cases are parameterless, or that all subtypes of the sealed hierarchy T are objects.

Creates a pickler for an enumeration, where the validator is derived using sttp.tapir.Validator.derivedEnumeration. This requires that this is an enum, where all cases are parameterless, or that all subtypes of the sealed hierarchy T are objects.

This method cannot be a given, as there's no way to constraint the type T to be an enum / sealed trait or class enumeration, so that this would be invoked only when necessary.

Attributes

inline def oneOfUsingField[T : ClassTag, V](inline extractorFn: T => V, inline asStringFn: V => String)(mapping: (V, Pickler[_ <: T])*)(implicit evidence$1: ClassTag[T], m: Of[T], c: PicklerConfiguration, discriminatorPickler: Pickler[V]): Pickler[T]

Create a coproduct pickler (e.g. for an enum or 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 pickler (e.g. for an enum or 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 picklers for 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 PicklerConfiguration), the coproduct schema can be derived automatically or semi-automatically.

Value parameters

discriminatorPickler

The pickler that is used when adding the discriminator as a field to child picklers (if it's not yet added).

Attributes

inline def picklerForMap[K, V](keyToString: K => String)(using pk: Pickler[K], pv: Pickler[V]): Pickler[Map[K, V]]

Create a pickler for a map with arbitrary keys. The pickler for the keys (Pickler[K]) should be string-like (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 pickler for a map with arbitrary keys. The pickler for the keys (Pickler[K]) should be string-like (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 pickler to be available as a given type of keys, create an custom implicit, e.g.:

case class MyKey(value: String) extends AnyVal
given picklerForMyMap: Pickler[Map[MyKey, MyValue]] = Pickler.picklerForMap[MyKey, MyValue](_.value)

Attributes

Givens

Givens

given given_Pickler_JBigDecimal: Pickler[BigDecimal]
given given_Pickler_JBigInteger: Pickler[BigInteger]
inline given nonMirrorPickler[T](using PicklerConfiguration, NotGiven[Of[T]]): Pickler[T]
inline given picklerForAnyVal[T <: AnyVal]: Pickler[T]
given picklerForArray[T : ClassTag]: Pickler[Array[T]]
given picklerForEither[A, B](using pa: Pickler[A], pb: Pickler[B]): Pickler[Either[A, B]]
given picklerForIterable[T : Pickler, C <: (Iterable)](implicit evidence$1: Pickler[T], PicklerConfiguration, Of[T], Factory[T, C[T]]): Pickler[C[T]]
given picklerForOption[T : Pickler](implicit evidence$1: Pickler[T], PicklerConfiguration, Of[T]): Pickler[Option[T]]
inline given picklerForStringMap[V](using pv: Pickler[V]): Pickler[Map[String, V]]