Schema

sttp.tapir.Schema
See theSchema companion class

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Show all
Self type
Schema.type

Members list

Type members

Classlikes

case class Delimiter(delimiter: String)

Used in combination with explode, to properly represent delimited values in examples and default values (#3581)

Used in combination with explode, to properly represent delimited values in examples and default values (#3581)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Delimiter

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Delimiter.type
case class Explode(explode: Boolean)

Corresponds to OpenAPI's explode parameter which should be used for delimited values.

Corresponds to OpenAPI's explode parameter which should be used for delimited values.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Explode

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Explode.type
case class SName(fullName: String, typeParameterShortNames: List[String])

Value parameters

typeParameterShortNames

full name of type parameters, name is legacy and kept only for backward compatibility

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object SName

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
SName.type
case class Title(value: String)

Corresponds to JsonSchema's title parameter which should be used for defining title of the object.

Corresponds to JsonSchema's title parameter which should be used for defining title of the object.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Title

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Title.type
case class UniqueItems(uniqueItems: Boolean)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object UniqueItems

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
object annotations

Annotations which are used during automatic schema derivation, or semi-automatic schema derivation using Schema.derived.

Annotations which are used during automatic schema derivation, or semi-automatic schema derivation using Schema.derived.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

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

def any[T]: Schema[T]

A schema allowing anything: a number, string, object, etc. A SCoproduct with no specified subtypes.

A schema allowing anything: a number, string, object, etc. A SCoproduct with no specified subtypes.

Attributes

See also
def anyObject[T]: Schema[T]

A schema allowing any object. A SProduct with no specified fields.

A schema allowing any object. A SProduct with no specified fields.

Attributes

See also

any

def binary[T]: Schema[T]

Creates a schema for type T, where the low-level representation is binary.

Creates a schema for type T, where the low-level representation is binary.

Attributes

def string[T]: Schema[T]

Creates a schema for type T, where the low-level representation is a String.

Creates a schema for type T, where the low-level representation is a String.

Attributes

def wrapWithSingleFieldProduct[T](schema: Schema[T], fieldName: FieldName): Schema[T]

Wraps the given schema with a single-field product, where fieldName maps to schema.

Wraps the given schema with a single-field product, where fieldName maps to schema.

The resulting schema has no name.

Useful when generating one-of schemas for coproducts, where to discriminate between child types a wrapper product is used. To automatically derive such a schema for a sealed hierarchy, see Schema.oneOfWrapped.

Attributes

def wrapWithSingleFieldProduct[T](schema: Schema[T])(implicit conf: Configuration): Schema[T]

Wraps the given schema with a single-field product, where a field computed using the implicit Configuration maps to schema.

Wraps the given schema with a single-field product, where a field computed using the implicit Configuration maps to schema.

The resulting schema has no name.

Useful when generating one-of schemas for coproducts, where to discriminate between child types a wrapper product is used. To automatically derive such a schema for a sealed hierarchy, see Schema.oneOfWrapped.

Attributes

Inherited methods

inline def derived[T](using genericDerivationConfig: Configuration, m: Of[T]): Schema[T]

Attributes

Inherited from:
SchemaMagnoliaDerivation

Creates a schema 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 schema 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 implicit, 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

Inherited from:
SchemaCompanionMacros
inline def derivedEnumerationValueCustomise[T <: Enumeration#Value]: CreateDerivedEnumerationSchema[T]

Creates a schema for an Enumeration, where the validator is created using the enumeration's values. Unlike the default derivedEnumerationValue method, which provides the schema implicitly, this variant allows customising how the schema is created. This is useful if the low-level representation of the schema is different than a String, or if the enumeration's values should be encoded in a different way than using .toString.

Creates a schema for an Enumeration, where the validator is created using the enumeration's values. Unlike the default derivedEnumerationValue method, which provides the schema implicitly, this variant allows customising how the schema is created. This is useful if the low-level representation of the schema is different than a String, or if the enumeration's values should be encoded in a different way than using .toString.

Because of technical limitations of macros, the customisation arguments can't be given here directly, instead being delegated to CreateDerivedEnumerationSchema.

Attributes

Inherited from:
SchemaCompanionMacros
inline def derivedUnion[E]: Schema[E]

Derives the schema for a union type E. Schemas for all components of the union type must be available in the implicit scope at the point of invocation.

Derives the schema for a union type E. Schemas for all components of the union type must be available in the implicit scope at the point of invocation.

Attributes

Inherited from:
SchemaCompanionMacros
inline def oneOfUsingField[E, V](inline extractor: E => V, asString: V => String)(mapping: (V, Schema[_])*)(implicit conf: Configuration, discriminatorSchema: Schema[V]): Schema[E]

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).

Attributes

Inherited from:
SchemaCompanionMacros
inline def oneOfWrapped[E](implicit conf: Configuration): Schema[E]

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.

Attributes

Inherited from:
SchemaCompanionMacros
inline def schemaForMap[K, V : Schema](keyToString: K => String): Schema[Map[K, V]]

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)

Attributes

Inherited from:
SchemaCompanionMacros

Concrete fields

Implicits

Implicits

implicit def schemaForArray[T : Schema]: Schema[Array[T]]
implicit val schemaForBigDecimal: Schema[BigDecimal]
implicit val schemaForBigInt: Schema[BigInt]
implicit val schemaForBoolean: Schema[Boolean]
implicit val schemaForByte: Schema[Byte]
implicit val schemaForByteArray: Schema[Array[Byte]]
implicit val schemaForByteBuffer: Schema[ByteBuffer]
implicit val schemaForDate: Schema[Date]
implicit def schemaForDelimited[D <: String, T](implicit tSchema: Schema[T]): Schema[Delimited[D, T]]
implicit val schemaForDouble: Schema[Double]
implicit def schemaForEither[A, B](implicit sa: Schema[A], sb: Schema[B]): Schema[Either[A, B]]
implicit val schemaForFile: Schema[TapirFile]
implicit val schemaForFloat: Schema[Float]
implicit val schemaForInputStream: Schema[InputStream]
implicit val schemaForInstant: Schema[Instant]
implicit val schemaForInt: Schema[Int]
implicit def schemaForIterable[T : Schema, C <: (Iterable)]: Schema[C[T]]
implicit val schemaForJBigDecimal: Schema[BigDecimal]
implicit val schemaForJBigInteger: Schema[BigInteger]
implicit val schemaForJavaDuration: Schema[Duration]
implicit val schemaForLocalDate: Schema[LocalDate]
implicit val schemaForLocalDateTime: Schema[LocalDateTime]
implicit val schemaForLocalTime: Schema[LocalTime]
implicit val schemaForLong: Schema[Long]
implicit val schemaForOffsetDateTime: Schema[OffsetDateTime]
implicit val schemaForOffsetTime: Schema[OffsetTime]
implicit def schemaForOption[T : Schema]: Schema[Option[T]]
implicit def schemaForPart[T : Schema]: Schema[Part[T]]
implicit val schemaForScalaDuration: Schema[Duration]
implicit def schemaForSet[T : Schema, C <: (Set)]: Schema[C[T]]
implicit val schemaForShort: Schema[Short]
implicit val schemaForString: Schema[String]
implicit val schemaForUUID: Schema[UUID]
implicit val schemaForUnit: Schema[Unit]
implicit val schemaForZoneId: Schema[ZoneId]
implicit val schemaForZoneOffset: Schema[ZoneOffset]
implicit val schemaForZonedDateTime: Schema[ZonedDateTime]

Inherited implicits

implicit inline def derivedEnumerationValue[T <: Enumeration#Value]: Schema[T]

Create a schema for an Enumeration, where the validator is created using the enumeration's values. The low-level representation of the enum is a String, and the enum values in the documentation will be encoded using .toString.

Create a schema for an Enumeration, where the validator is created using the enumeration's values. The low-level representation of the enum is a String, and the enum values in the documentation will be encoded using .toString.

Attributes

Inherited from:
SchemaCompanionMacros
implicit def derivedSchema[T](implicit derived: Derived[Schema[T]]): Schema[T]

Attributes

Inherited from:
LowPrioritySchema
implicit inline def schemaForMap[V : Schema]: Schema[Map[String, V]]

Attributes

Inherited from:
SchemaCompanionMacros