package tapir
- Alphabetic
- By Inheritance
- tapir
- Tapir
- TapirMacros
- ModifyMacroSupport
- ModifyMacroFunctorSupport
- TapirStaticContentEndpoints
- TapirComputedInputs
- TapirExtensions
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Package Members
Type Members
- type AnyListCodec = Codec[_ <: List[_], _, _ <: CodecFormat]
- type AnyPart = Part[_]
- trait Codec[L, H, +CF <: CodecFormat] extends AnyRef
A bi-directional mapping between low-level values of type
L
and high-level values of typeH
.A bi-directional mapping between low-level values of type
L
and high-level values of typeH
. Low level values are formatted asCF
.The mapping consists of a pair of functions, one to decode (
L => H
), and one to encode (H => L
) Decoding can fail, and this is represented as a result of type DecodeResult.A codec also contains optional meta-data on the
schema
of the high-level value, as well as an instance of the format (which determines the media type of the low-level value).Codec instances are used as implicit values, and are looked up when defining endpoint inputs/outputs. Depending on a particular endpoint input/output, it might require a codec which uses a specific format, or a specific low-level value.
Codec instances can be derived basing on other values (e.g. such as json encoders/decoders when integrating with json libraries). Or, they can be defined by hand for custom types, usually customising an existing, simpler codec.
Codecs can be chained with Mappings using the
map
function.- L
The type of the low-level value.
- H
The type of the high-level value.
- CF
The format of encoded values. Corresponds to the media type.
- Annotations
- @implicitNotFound()
- trait CodecExtensions extends AnyRef
- trait CodecFormat extends AnyRef
Specifies the format of the encoded values.
Specifies the format of the encoded values. Each variant must be a proper type so that it can be used as a discriminator for different (implicit) instances of Codec values.
- sealed trait DecodeResult[+T] extends AnyRef
- case class DocsExtension[A](key: String, value: A, codec: JsonCodec[A]) extends Product with Serializable
- case class Endpoint[I, E, O, -R](input: EndpointInput[I], errorOutput: EndpointOutput[E], output: EndpointOutput[O], info: EndpointInfo) extends EndpointInputsOps[I, E, O, R] with EndpointErrorOutputsOps[I, E, O, R] with EndpointOutputsOps[I, E, O, R] with EndpointInfoOps[I, E, O, R] with EndpointMetaOps[I, E, O, R] with EndpointServerLogicOps[I, E, O, R] with Product with Serializable
- I
Input parameter types.
- E
Error output parameter types.
- O
Output parameter types.
- R
The capabilities that are required by this endpoint's inputs/outputs. This might be
Any
(no requirements), sttp.capabilities.Effect (the interpreter must support the given effect type), sttp.capabilities.Streams (the ability to send and receive streaming bodies) or sttp.capabilities.WebSockets (the ability to handle websocket requests).
- trait EndpointErrorOutputsOps[I, E, O, -R] extends EndpointErrorOutputsMacros[I, E, O, R]
- sealed trait EndpointIO[T] extends EndpointInput[T] with EndpointOutput[T]
- case class EndpointInfo(name: Option[String], summary: Option[String], description: Option[String], tags: Vector[String], deprecated: Boolean, docsExtensions: Vector[DocsExtension[_]]) extends Product with Serializable
- trait EndpointInfoOps[I, E, O, -R] extends AnyRef
- sealed trait EndpointInput[T] extends EndpointTransput[T]
- trait EndpointInputsOps[I, E, O, -R] extends EndpointInputsMacros[I, E, O, R]
- trait EndpointMetaOps[I, E, O, -R] extends AnyRef
- sealed trait EndpointOutput[T] extends EndpointTransput[T]
- trait EndpointOutputsOps[I, E, O, -R] extends EndpointOutputsMacros[I, E, O, R]
- trait EndpointServerLogicOps[I, E, O, -R] extends AnyRef
- sealed trait EndpointTransput[T] extends EndpointTransputMacros[T]
A transput is EITHER an input, or an output (see: https://ell.stackexchange.com/questions/21405/hypernym-for-input-and-output).
A transput is EITHER an input, or an output (see: https://ell.stackexchange.com/questions/21405/hypernym-for-input-and-output). The transput traits contain common functionality, shared by all inputs and outputs.
Note that implementations of
EndpointIO
can be used BOTH as inputs and outputs.The hierarchy is as follows:
/--->
EndpointInput
>---\EndpointTransput
>--- --->EndpointIO
\--->EndpointOutput
>---/ - case class FieldName(name: String, encodedName: String) extends Product with Serializable
- trait LowPriorityCodec extends AnyRef
Lower-priority codec implicits, which transform other codecs.
Lower-priority codec implicits, which transform other codecs. For example, when deriving a codec
List[T] <-> Either[A, B]
, given codecsca: T <-> A
andcb: T <-> B
, we want to getlistHead(eitherRight(ca, cb))
, noteitherRight(listHead(ca), listHead(cb))
(although they would function the same). - trait LowPrioritySchema extends AnyRef
- trait Mapping[L, H] extends AnyRef
A bi-directional mapping between values of type
L
and values of typeH
.A bi-directional mapping between values of type
L
and values of typeH
.Low-level values of type
L
can be **decoded** to a higher-level value of typeH
. The decoding can fail; this is represented by a result of type DecodeResult.Failure. Failures might occur due to format errors, wrong arity, exceptions, or validation errors. Validators can be added through thevalidate
method.High-level values of type
H
can be **encoded** as a low-level value of typeL
.Mappings can be chained using one of the
map
functions.- L
The type of the low-level value.
- H
The type of the high-level value.
- case class MultipartCodec[T](rawBodyType: MultipartBody, codec: Codec[Seq[RawPart], T, MultipartFormData]) extends Product with Serializable
- case class PartCodec[R, T](rawBodyType: RawBodyType[R], codec: Codec[List[R], T, _ <: CodecFormat]) extends Product with Serializable
Information needed to read a single part of a multipart body: the raw type (
rawBodyType
), and the codec which further decodes it. - sealed trait RawBodyType[R] extends AnyRef
The raw format of the body: what do we need to know, to read it and pass to a codec for further decoding.
- type RawPart = Part[_]
- case class Schema[T](schemaType: SchemaType[T], name: Option[SName] = None, isOptional: Boolean = false, description: Option[String] = None, default: Option[(T, Option[Any])] = None, format: Option[String] = None, encodedExample: Option[Any] = None, deprecated: Boolean = false, validator: Validator[T] = Validator.pass[T]) extends SchemaMacros[T] with Product with Serializable
Describes the type
T
: its low-level representation, meta-data and validation rules.Describes the type
T
: its low-level representation, meta-data and validation rules.- format
The name of the format of the low-level representation of
T
.
- Annotations
- @implicitNotFound()
- trait SchemaExtensions extends AnyRef
- sealed trait SchemaType[T] extends AnyRef
The type of the low-level representation of a
T
values.The type of the low-level representation of a
T
values. Part of Schemas. - case class StreamBodyIO[BS, T, S](streams: Streams[S], codec: Codec[BS, T, CodecFormat], info: Info[T], charset: Option[Charset]) extends Basic[T] with Product with Serializable
- trait Tapir extends TapirExtensions with TapirComputedInputs with TapirStaticContentEndpoints with ModifyMacroSupport with TapirMacros
- final class WebSocketBodyBuilder[REQ, REQ_CF <: CodecFormat, RESP, RESP_CF <: CodecFormat] extends AnyRef
- Definition Classes
- Tapir
- trait TapirAliases extends AnyRef
Mixin containing aliases for top-level types and modules in the tapir package.
- trait TapirComputedInputs extends AnyRef
- trait TapirExtensions extends AnyRef
- type TapirFile = File
- Definition Classes
- TapirExtensions
- class UnsupportedWebSocketFrameException extends WebSocketException
- sealed trait ValidationError[T] extends AnyRef
- sealed trait Validator[T] extends AnyRef
- case class WebSocketBodyOutput[PIPE_REQ_RESP, REQ, RESP, T, S](streams: Streams[S], requests: Codec[WebSocketFrame, REQ, CodecFormat], responses: Codec[WebSocketFrame, RESP, CodecFormat], codec: Codec[PIPE_REQ_RESP, T, CodecFormat], info: Info[T], requestsInfo: Info[REQ], responsesInfo: Info[RESP], concatenateFragmentedFrames: Boolean, ignorePong: Boolean, autoPongOnPing: Boolean, decodeCloseRequests: Boolean, decodeCloseResponses: Boolean, autoPing: Option[(FiniteDuration, Ping)]) extends Basic[T] with Product with Serializable
- class WebSocketFrameDecodeFailure extends WebSocketException
- implicit class ModifyEach[F[_], T] extends AnyRef
- Definition Classes
- ModifyMacroFunctorSupport
- trait ModifyFunctor[F[_], A] extends AnyRef
- Definition Classes
- ModifyMacroFunctorSupport
- implicit class ModifyEachMap[F[_, _], K, T] extends AnyRef
- Definition Classes
- ModifyMacroSupport
Value Members
- def anyFromStringBody[T, CF <: CodecFormat](codec: Codec[String, T, CF], charset: Charset): Body[String, T]
A body in any format, read using the given
codec
, from a raw string read usingcharset
.A body in any format, read using the given
codec
, from a raw string read usingcharset
.- Definition Classes
- Tapir
- def anyFromUtf8StringBody[T, CF <: CodecFormat](codec: Codec[String, T, CF]): Body[String, T]
A body in any format, read using the given
codec
, from a raw string read using UTF-8.A body in any format, read using the given
codec
, from a raw string read using UTF-8.- Definition Classes
- Tapir
- def auth: TapirAuth.type
- Definition Classes
- Tapir
- def binaryBody[R, T](implicit arg0: Binary[R], arg1: Codec[R, T, OctetStream]): Body[R, T]
- Definition Classes
- Tapir
- def byteArrayBody: Body[Array[Byte], Array[Byte]]
- Definition Classes
- Tapir
- def byteBufferBody: Body[ByteBuffer, ByteBuffer]
- Definition Classes
- Tapir
- def clientIp: EndpointInput[Option[String]]
- Definition Classes
- TapirComputedInputs
- def cookie[T](name: String)(implicit arg0: Codec[Option[String], T, TextPlain]): Cookie[T]
- Definition Classes
- Tapir
- def cookies: Header[List[Cookie]]
- Definition Classes
- Tapir
- def customJsonBody[T](implicit arg0: JsonCodec[T]): Body[String, T]
Requires an implicit Codec.JsonCodec in scope.
Requires an implicit Codec.JsonCodec in scope. Such a codec can be created using Codec.json.
However, json codecs are usually derived from json-library-specific implicits. That's why integrations with various json libraries define
jsonBody
methods, which directly require the library-specific implicits.Unless you have defined a custom json codec, the
jsonBody
methods should be used.- Definition Classes
- Tapir
- val emptyOutput: Empty[Unit]
An empty output.
An empty output. Useful if one of
oneOf
branches should be mapped to the status code only.- Definition Classes
- Tapir
- def emptyOutputAs[T](value: T): Basic[T]
An empty output.
- val endpoint: Endpoint[Unit, Unit, Unit, Any]
- Definition Classes
- Tapir
- def extractFromRequest[T](f: (ServerRequest) => T): ExtractFromRequest[T]
Extract a value from a server request.
Extract a value from a server request. This input is only used by server interpreters, it is ignored by documentation interpreters and the provided value is discarded by client interpreters.
- Definition Classes
- Tapir
- def fileBody: Body[TapirFile, TapirFile]
- Definition Classes
- Tapir
- def formBody[T](charset: Charset)(implicit arg0: Codec[String, T, XWwwFormUrlencoded]): Body[String, T]
- Definition Classes
- Tapir
- def formBody[T](implicit arg0: Codec[String, T, XWwwFormUrlencoded]): Body[String, T]
- Definition Classes
- Tapir
- def header(name: String, value: String): FixedHeader[Unit]
- Definition Classes
- Tapir
- def header(h: Header): FixedHeader[Unit]
- Definition Classes
- Tapir
- def header[T](name: String)(implicit arg0: Codec[List[String], T, TextPlain]): Header[T]
- Definition Classes
- Tapir
- def headers: Headers[List[Header]]
- Definition Classes
- Tapir
- val htmlBodyUtf8: Body[String, String]
- Definition Classes
- Tapir
- val infallibleEndpoint: Endpoint[Unit, Nothing, Unit, Any]
- Definition Classes
- Tapir
- def inputStreamBody: Body[InputStream, InputStream]
- Definition Classes
- Tapir
- def isWebSocket: EndpointInput[Boolean]
- Definition Classes
- TapirComputedInputs
- def multipartBody[T](implicit multipartCodec: MultipartCodec[T]): Body[Seq[RawPart], T]
- Definition Classes
- Tapir
- val multipartBody: Body[Seq[RawPart], Seq[Part[Array[Byte]]]]
- Definition Classes
- Tapir
- def oneOf[T](firstCase: OneOfMapping[_ <: T], otherCases: OneOfMapping[_ <: T]*): OneOf[T, T]
Specifies a correspondence between status codes and outputs.
Specifies a correspondence between status codes and outputs.
All outputs must have a common supertype (
T
). Typically, the supertype is a sealed trait, and the mappings are implementing cases classes.A single status code can have multiple mappings (or there can be multiple default mappings), with different body content types. The mapping can then be chosen based on content type negotiation, or the content type header.
Note that exhaustiveness of the mappings is not checked (that all subtypes of
T
are covered).- Definition Classes
- Tapir
- def oneOfDefaultMapping[T](output: EndpointOutput[T]): OneOfMapping[T]
Create a fallback mapping to be used in oneOf output descriptions.
- macro def oneOfMapping[T](statusCode: StatusCode, output: EndpointOutput[T])(implicit arg0: ClassTag[T]): OneOfMapping[T]
Create a one-of-mapping which uses
statusCode
andoutput
if the class of the provided value (when interpreting as a server) matches the runtime class ofT
.Create a one-of-mapping which uses
statusCode
andoutput
if the class of the provided value (when interpreting as a server) matches the runtime class ofT
.This will fail at compile-time if the type erasure of
T
is different fromT
, as a runtime check in this situation would give invalid results. In such cases, use oneOfMappingClassMatcher, oneOfMappingValueMatcher or oneOfMappingFromMatchType instead.Should be used in oneOf output descriptions.
- Definition Classes
- TapirMacros
- def oneOfMappingClassMatcher[T](statusCode: StatusCode, output: EndpointOutput[T], runtimeClass: Class[_]): OneOfMapping[T]
Create a one-of-mapping which uses
statusCode
andoutput
if the class of the provided value (when interpreting as a server) matches the givenruntimeClass
. - def oneOfMappingExactMatcher[T](statusCode: StatusCode, output: EndpointOutput[T])(firstExactValue: T, rest: T*)(implicit arg0: ClassTag[T]): OneOfMapping[T]
Create a one-of-mapping which uses
statusCode
andoutput
if the provided value exactly matches one of the values provided in the second argument list. - def oneOfMappingFromMatchType[T](statusCode: StatusCode, output: EndpointOutput[T])(implicit arg0: MatchType[T]): OneOfMapping[T]
Experimental!
Experimental!
Create a one-of-mapping which uses
statusCode
andoutput
if the provided value matches the target type, as checked by MatchType. Instances of MatchType are automatically derived and recursively check that classes of all fields match, to bypass issues caused by type erasure.Should be used in oneOf output descriptions.
- Definition Classes
- Tapir
- def oneOfMappingValueMatcher[T](statusCode: StatusCode, output: EndpointOutput[T])(matcher: PartialFunction[Any, Boolean]): OneOfMapping[T]
Create a one-of-mapping which uses
statusCode
andoutput
if the provided value (when interpreting as a server matches thematcher
predicate. - implicit def optionModifyFunctor[A]: ModifyFunctor[Option, A]
- Definition Classes
- ModifyMacroFunctorSupport
- def path[T](name: String)(implicit arg0: Codec[String, T, TextPlain]): PathCapture[T]
- Definition Classes
- Tapir
- def path[T](implicit arg0: Codec[String, T, TextPlain]): PathCapture[T]
- Definition Classes
- Tapir
- def paths: PathsCapture[List[String]]
- Definition Classes
- Tapir
- def plainBody[T](charset: Charset)(implicit arg0: Codec[String, T, TextPlain]): Body[String, T]
- Definition Classes
- Tapir
- def plainBody[T](implicit arg0: Codec[String, T, TextPlain]): Body[String, T]
- Definition Classes
- Tapir
- def query[T](name: String)(implicit arg0: Codec[List[String], T, TextPlain]): Query[T]
- Definition Classes
- Tapir
- def queryParams: QueryParams[QueryParams]
- Definition Classes
- Tapir
- def rawBinaryBody[R](implicit arg0: Binary[R], codec: Codec[R, R, OctetStream]): Body[R, R]
- Definition Classes
- Tapir
- def setCookie(name: String): Header[CookieValueWithMeta]
- Definition Classes
- Tapir
- def setCookies: Header[List[CookieWithMeta]]
- Definition Classes
- Tapir
- def statusCode(statusCode: StatusCode): FixedStatusCode[Unit]
- Definition Classes
- Tapir
- def statusCode: StatusCode[StatusCode]
- Definition Classes
- Tapir
- def streamBinaryBody[S](s: Streams[S]): StreamBodyIO[BinaryStream, BinaryStream, S]
Creates a stream body with a binary schema.
Creates a stream body with a binary schema. The
application/octet-stream
media type will be used by default, but can be later overridden by providing a customContent-Type
header value.- s
A supported streams implementation.
- Definition Classes
- Tapir
- def streamBody[S, T](s: Streams[S])(schema: Schema[T], format: CodecFormat, charset: Option[Charset] = None): StreamBodyIO[BinaryStream, BinaryStream, S]
Creates a stream body with a text schema.
Creates a stream body with a text schema.
- s
A supported streams implementation.
- schema
Schema of the body. This should be a schema for the "deserialized" stream.
- format
The media type to use by default. Can be later overridden by providing a custom
Content-Type
header.- charset
An optional charset of the resulting stream's data, to be used in the content type.
- Definition Classes
- Tapir
- def streamTextBody[S](s: Streams[S])(format: CodecFormat, charset: Option[Charset] = None): StreamBodyIO[BinaryStream, BinaryStream, S]
Creates a stream body with a text schema.
Creates a stream body with a text schema.
- s
A supported streams implementation.
- format
The media type to use by default. Can be later overridden by providing a custom
Content-Type
header.- charset
An optional charset of the resulting stream's data, to be used in the content type.
- Definition Classes
- Tapir
- def stringBody(charset: Charset): Body[String, String]
- Definition Classes
- Tapir
- def stringBody(charset: String): Body[String, String]
- Definition Classes
- Tapir
- def stringBody: Body[String, String]
- Definition Classes
- Tapir
- implicit def stringToPath(s: String): FixedPath[Unit]
- Definition Classes
- Tapir
- implicit def traversableModifyFunctor[F[_], A](implicit fac: Factory[A, F[A]], ev: (F[A]) => Iterable[A]): ModifyFunctor[F, A]
- Definition Classes
- ModifyMacroSupport
- def webSocketBody[REQ, REQ_CF <: CodecFormat, RESP, RESP_CF <: CodecFormat]: WebSocketBodyBuilder[REQ, REQ_CF, RESP, RESP_CF]
- REQ
The type of messages that are sent to the server.
- REQ_CF
The codec format (media type) of messages that are sent to the server.
- RESP
The type of messages that are received from the server.
- RESP_CF
The codec format (media type) of messages that are received from the server.
- Definition Classes
- Tapir
- def webSocketBodyRaw[S](s: Streams[S]): WebSocketBodyOutput[Pipe[WebSocketFrame, WebSocketFrame], WebSocketFrame, WebSocketFrame, Pipe[WebSocketFrame, WebSocketFrame], S]
- Definition Classes
- Tapir
- def xmlBody[T](implicit arg0: XmlCodec[T]): Body[String, T]
Requires an implicit Codec.XmlCodec in scope.
Requires an implicit Codec.XmlCodec in scope. Such a codec can be created using Codec.xml.
- Definition Classes
- Tapir
- object Codec extends CodecExtensions with FormCodecMacros with LowPriorityCodec
- object CodecFormat
- object DecodeResult
- object Defaults
- object DocsExtension extends Serializable
- object EndpointIO
- object EndpointInput extends EndpointInputMacros
- object EndpointOutput extends EndpointOutputMacros
- object EndpointTransput
- object FieldName extends Serializable
- object Mapping
- object MultipartCodec extends MultipartCodecMacros with Serializable
- object RawBodyType
- object RenderPathTemplate
- object Schema extends SchemaExtensions with LowPrioritySchema with SchemaCompanionMacros with Serializable
- object SchemaType
- object TapirAuth
- object ValidationError
- object Validator extends ValidatorMacros
Deprecated Value Members
- def anyJsonBody[T](implicit arg0: JsonCodec[T]): Body[String, T]
- Definition Classes
- Tapir
- Annotations
- @deprecated
- Deprecated
(Since version 0.18.0) Use customJsonBody
- def statusDefaultMapping[T](output: EndpointOutput[T]): OneOfMapping[T]
- Definition Classes
- Tapir
- Annotations
- @deprecated
- Deprecated
(Since version 0.18) Use oneOfDefaultMapping
- macro def statusMapping[T](statusCode: StatusCode, output: EndpointOutput[T])(implicit arg0: ClassTag[T]): OneOfMapping[T]
- Definition Classes
- TapirMacros
- Annotations
- @deprecated
- Deprecated
(Since version 0.18) Use oneOfMapping
- def statusMappingClassMatcher[T](statusCode: StatusCode, output: EndpointOutput[T], runtimeClass: Class[_]): OneOfMapping[T]
- Definition Classes
- Tapir
- Annotations
- @deprecated
- Deprecated
(Since version 0.18) Use oneOfMappingClassMatcher
- def statusMappingExactMatcher[T](statusCode: StatusCode, output: EndpointOutput[T])(firstExactValue: T, rest: T*)(implicit arg0: ClassTag[T]): OneOfMapping[T]
- Definition Classes
- Tapir
- Annotations
- @deprecated
- Deprecated
(Since version 0.18) Use oneOfMappingExactMatcher
- def statusMappingFromMatchType[T](statusCode: StatusCode, output: EndpointOutput[T])(implicit arg0: MatchType[T]): OneOfMapping[T]
- Definition Classes
- Tapir
- Annotations
- @deprecated
- Deprecated
(Since version 0.18) Use oneOfMappingFromMatchType
- def statusMappingValueMatcher[T](statusCode: StatusCode, output: EndpointOutput[T])(matcher: PartialFunction[Any, Boolean]): OneOfMapping[T]
- Definition Classes
- Tapir
- Annotations
- @deprecated
- Deprecated
(Since version 0.18) Use oneOfMappingValueMatcher