Tapir

Type members

Classlikes

final
class WebSocketBodyBuilder[REQ, REQ_CF <: CodecFormat, RESP, RESP_CF <: CodecFormat]

Inherited classlikes

implicit
class ModifyEach[F[_], T](t: F[T])(implicit f: ModifyFunctor[F, T])
implicit
class ModifyEachMap[F[_, _], K, T](t: F[K, T])(implicit fac: Factory[(K, T), F[K, T]])
Inherited from
ModifyMacroSupport
trait ModifyFunctor[F[_], A]

Inherited types

type TapirFile = File
Inherited from
TapirExtensions

Value members

Concrete methods

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 using charset.

A body in any format, read using the given codec, from a raw string read using charset.

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.

Inputs which describe authentication credentials with metadata.

Inputs which describe authentication credentials with metadata.

def binaryBody[R : ([R] =>> Codec[R, T, OctetStream]), T]: Body[R, T]
def byteArrayBody: Body[Array[Byte], Array[Byte]]
def byteBufferBody: Body[ByteBuffer, ByteBuffer]
def cookies: Header[List[Cookie]]
def customJsonBody[T : JsonCodec]: Body[String, T]

Requires an implicit Codec.JsonCodec in scope. Such a codec can be created using Codec.json.

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.

def emptyOutputAs[T](value: T): Basic[T]

An empty output. Useful if one of the oneOf branches of a coproduct type is a case object that should be mapped to an empty body.

An empty output. Useful if one of the oneOf branches of a coproduct type is a case object that should be mapped to an empty body.

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.

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.

def formBody[T : ([T] =>> Codec[String, T, XWwwFormUrlencoded])]: Body[String, T]
def formBody[T : ([T] =>> Codec[String, T, XWwwFormUrlencoded])](charset: Charset): Body[String, T]
def header[T : ([T] =>> Codec[List[String], T, TextPlain])](name: String): Header[T]
def header(h: Header): FixedHeader[Unit]
def header(name: String, value: String): FixedHeader[Unit]
def headers: Headers[List[Header]]
def inputStreamBody: Body[InputStream, InputStream]
def multipartBody[T](implicit multipartCodec: MultipartCodec[T]): Body[Seq[RawPart], T]
def oneOf[T](firstCase: OneOfMapping[_ <: T], otherCases: OneOfMapping[_ <: T]*): OneOf[T, T]

An output which contains a number of variant outputs.

An output which contains a number of variant outputs.

All possible outputs must have a common supertype (T). Typically, the supertype is a sealed trait, and the mappings are implementing case classes.

When encoding to a response, the first matching output is chosen, using the following rules:

  1. the mappings appliesTo method, applied to the output value (as returned by the server logic) must return true.
  2. when a fixed content type is specified by the output, it must match the request's Accept header (if present). This implements content negotiation.

When decoding from a response, the first output which decodes successfully is chosen.

The outputs might vary in status codes, headers (e.g. different content types), and body implementations. However, for bodies, only replayable ones can be used, and they need to have the same raw representation (e.g. all byte-array-base, or all file-based).

Note that exhaustiveness of the mappings (that all subtypes of T are covered) is not checked.

Create a fallback mapping to be used in oneOf output descriptions. Multiple such mappings can be specified, with different body content types.

Create a fallback mapping to be used in oneOf output descriptions. Multiple such mappings can be specified, with different body content types.

def oneOfMappingClassMatcher[T](output: EndpointOutput[T], runtimeClass: Class[_]): OneOfMapping[T]

Create a one-of-mapping which uses output if the class of the provided value (when interpreting as a server) matches the given runtimeClass. Note that this does not take into account type erasure.

Create a one-of-mapping which uses output if the class of the provided value (when interpreting as a server) matches the given runtimeClass. Note that this does not take into account type erasure.

Should be used in oneOf output descriptions.

def oneOfMappingClassMatcher[T](code: StatusCode, output: EndpointOutput[T], runtimeClass: Class[_]): OneOfMapping[T]

Create a one-of-mapping which uses output i the class of the provided value (when interpreting as a server) matches the given runtimeClass. Note that this does not take into account type erasure. Adds a fixed status-code output with the given value.

Create a one-of-mapping which uses output i the class of the provided value (when interpreting as a server) matches the given runtimeClass. Note that this does not take into account type erasure. Adds a fixed status-code output with the given value.

Should be used in oneOf output descriptions.

def oneOfMappingExactMatcher[T : ClassTag](output: EndpointOutput[T])(firstExactValue: T, rest: T*): OneOfMapping[T]

Create a one-of-mapping which output if the provided value exactly matches one of the values provided in the second argument list.

Create a one-of-mapping which output if the provided value exactly matches one of the values provided in the second argument list.

Should be used in oneOf output descriptions.

def oneOfMappingExactMatcher[T : ClassTag](code: StatusCode, output: EndpointOutput[T])(firstExactValue: T, rest: T*): OneOfMapping[T]

Create a one-of-mapping which uses output if the provided value exactly matches one of the values provided in the second argument list. Adds a fixed status-code output with the given value.

Create a one-of-mapping which uses output if the provided value exactly matches one of the values provided in the second argument list. Adds a fixed status-code output with the given value.

Should be used in oneOf output descriptions.

Experimental!

Experimental!

Create a one-of-mapping which uses output 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.

def oneOfMappingFromMatchType[T : MatchType](code: StatusCode, output: EndpointOutput[T]): OneOfMapping[T]

Experimental!

Experimental!

Create a one-of-mapping which uses output 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. Adds a fixed status-code output with the given value.

Should be used in oneOf output descriptions.

def oneOfMappingValueMatcher[T](output: EndpointOutput[T])(matcher: PartialFunction[Any, Boolean]): OneOfMapping[T]

Create a one-of-mapping which uses output if the provided value (when interpreting as a server matches the matcher predicate.

Create a one-of-mapping which uses output if the provided value (when interpreting as a server matches the matcher predicate.

Should be used in oneOf output descriptions.

def oneOfMappingValueMatcher[T](code: StatusCode, output: EndpointOutput[T])(matcher: PartialFunction[Any, Boolean]): OneOfMapping[T]

Create a one-of-mapping which uses output if the provided value (when interpreting as a server matches the matcher predicate. Adds a fixed status-code output with the given value.

Create a one-of-mapping which uses output if the provided value (when interpreting as a server matches the matcher predicate. Adds a fixed status-code output with the given value.

Should be used in oneOf output descriptions.

def path[T : ([T] =>> Codec[String, T, TextPlain])]: PathCapture[T]
def path[T : ([T] =>> Codec[String, T, TextPlain])](name: String): PathCapture[T]
def paths: PathsCapture[List[String]]
def plainBody[T : ([T] =>> Codec[String, T, TextPlain])]: Body[String, T]
def plainBody[T : ([T] =>> Codec[String, T, TextPlain])](charset: Charset): Body[String, T]
def query[T : ([T] =>> Codec[List[String], T, TextPlain])](name: String): Query[T]
def queryParams: QueryParams[QueryParams]
def rawBinaryBody[R : Binary](implicit evidence$11: Binary[R], codec: Codec[R, R, OctetStream]): Body[R, R]
def setCookie(name: String): Header[CookieValueWithMeta]
def setCookieOpt(name: String): Header[Option[CookieValueWithMeta]]
def setCookies: Header[List[CookieWithMeta]]
def statusCode: StatusCode[StatusCode]

An output which maps to the status code in the response.

An output which maps to the status code in the response.

def statusCode(statusCode: StatusCode): FixedStatusCode[Unit]

An fixed status code output.

An fixed status code output.

def streamBinaryBody[S](s: Streams[S]): StreamBodyIO[BinaryStream, BinaryStream, S]

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 custom Content-Type header value.

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 custom Content-Type header value.

Value Params
s

A supported streams implementation.

def streamBody[S, T](s: Streams[S])(schema: Schema[T], format: CodecFormat, charset: Option[Charset]): StreamBodyIO[BinaryStream, BinaryStream, S]

Creates a stream body with a text schema.

Creates a stream body with a text schema.

Value Params
charset

An optional charset of the resulting stream's data, to be used in the content type.

format

The media type to use by default. Can be later overridden by providing a custom Content-Type header.

s

A supported streams implementation.

schema

Schema of the body. This should be a schema for the "deserialized" stream.

def streamTextBody[S](s: Streams[S])(format: CodecFormat, charset: Option[Charset]): StreamBodyIO[BinaryStream, BinaryStream, S]

Creates a stream body with a text schema.

Creates a stream body with a text schema.

Value Params
charset

An optional charset of the resulting stream's data, to be used in the content type.

format

The media type to use by default. Can be later overridden by providing a custom Content-Type header.

s

A supported streams implementation.

def stringBody: Body[String, String]
def stringBody(charset: String): Body[String, String]
def stringBody(charset: Charset): Body[String, String]
def webSocketBody[REQ, REQ_CF <: CodecFormat, RESP, RESP_CF <: CodecFormat]: WebSocketBodyBuilder[REQ, REQ_CF, RESP, RESP_CF]
Type Params
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.

def webSocketBodyRaw[S](s: Streams[S]): WebSocketBodyOutput[Pipe[WebSocketFrame, WebSocketFrame], WebSocketFrame, WebSocketFrame, Pipe[WebSocketFrame, WebSocketFrame], S]
def xmlBody[T : XmlCodec]: Body[String, T]

Requires an implicit Codec.XmlCodec in scope. Such a codec can be created using Codec.xml.

Requires an implicit Codec.XmlCodec in scope. Such a codec can be created using Codec.xml.

Deprecated methods

@deprecated(message = "Use customJsonBody", since = "0.18.0")
def anyJsonBody[T : JsonCodec]: Body[String, T]
Deprecated
[Since version 0.18.0] Use customJsonBody

Inherited methods

def clientIp: EndpointInput[Option[String]]
Inherited from
TapirComputedInputs
Inherited from
TapirComputedInputs
inline
def oneOfMapping[T : ClassTag](statusCode: StatusCode, output: EndpointOutput[T]): OneOfMapping[T]

Create a one-of-mapping which uses output if the class of the provided value (when interpreting as a server) matches the runtime class of T. Adds a fixed status-code output with the given value.

Create a one-of-mapping which uses output if the class of the provided value (when interpreting as a server) matches the runtime class of T. Adds a fixed status-code output with the given value.

This will fail at compile-time if the type erasure of T is different from T, 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.

Inherited from
TapirMacros
inline
def oneOfMapping[T : ClassTag](output: EndpointOutput[T]): OneOfMapping[T]

Create a one-of-mapping which uses output if the class of the provided value (when interpreting as a server) matches the runtime class of T.

Create a one-of-mapping which uses output if the class of the provided value (when interpreting as a server) matches the runtime class of T.

This will fail at compile-time if the type erasure of T is different from T, 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.

Inherited from
TapirMacros

Concrete fields

val emptyOutput: Empty[Unit]

An empty output.

An empty output.

val endpoint: PublicEndpoint[Unit, Unit, Unit, Any]
val htmlBodyUtf8: Body[String, String]
val infallibleEndpoint: PublicEndpoint[Unit, Nothing, Unit, Any]
val multipartBody: Body[Seq[RawPart], Seq[Part[Array[Byte]]]]

Implicits

Implicits

implicit
def stringToPath(s: String): FixedPath[Unit]

Inherited implicits

final implicit
def ModifyEach[F[_], T](t: F[T])(implicit f: ModifyFunctor[F, T]): ModifyEach[F, T]
final implicit
def ModifyEachMap[F[_, _], K, T](t: F[K, T])(implicit fac: Factory[(K, T), F[K, T]]): ModifyEachMap[F, K, T]
Inherited from
ModifyMacroSupport
implicit
implicit
def traversableModifyFunctor[F[_], A](implicit fac: Factory[A, F[A]], ev: F[A] => Iterable[A]): ModifyFunctor[F, A]
Inherited from
ModifyMacroSupport