Tapir
Type members
Classlikes
Inherited classlikes
- Inherited from:
- ModifyMacroSupport
Inherited types
Value members
Concrete methods
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
.
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.
Usage:
Usage:
binaryBody(RawBodyType.FileBody)[MyType]
, given that a codec between a file and MyType
is available in the implicit
scope.
binaryBody(RawBodyType.FileBody)[MyType] }}} scope.
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.
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.
An output which contains a number of variant outputs. Each variant can contain different outputs and represent different content. To describe an output which represents same content, but with different content types, use oneOfBody.
An output which contains a number of variant outputs. Each variant can contain different outputs and represent different content. To describe an output which represents same content, but with different content types, use oneOfBody.
All possible outputs must have a common supertype (T
). Typically, the supertype is a sealed trait, and the variants are implementing
case classes.
When encoding to a response, the first matching output is chosen, using the following rules:
- the variant's
appliesTo
method, applied to the output value (as returned by the server logic) must returntrue
. - 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 variants (that all subtypes of T
are covered) is not checked.
A body input or output, which can be one of the given variants. All variants should represent T
instances using different content
types. Hence, the content type is used as a discriminator to choose the appropriate variant.
A body input or output, which can be one of the given variants. All variants should represent T
instances using different content
types. Hence, the content type is used as a discriminator to choose the appropriate variant.
Should be used to describe an input or output which represents the same content, but using different content types. For an output which describes variants including possibly different outputs (representing different content), see oneOf.
The server behavior is as follows:
- when encoding to a response, the first variant matching the request's
Accept
header is chosen (if present). Otherwise, the first variant is used. This implements content negotiation. - when decoding a request, the variant corresponding to the request's
Content-Type
header is chosen (if present). Otherwise, a decode failure is returned, which by default results in an415 Unsupported Media Type
response.
The client behavior is as follows:
- when encoding a request, the first variant is used.
- when decoding a response, the variant corresponding to the response's
Content-Type
header is chosen (if present). Otherwise, the first variant is used. For client interpreters to work correctly, all body variants must have the same raw type (e.g. all are string-based or all byte-array-based)
All possible bodies must have the same type T
. Typically, the bodies will vary in the Codecs that are used for the body.
Create a one-of-variant 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-variant 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 oneOfVariantClassMatcher, oneOfVariantValueMatcher or oneOfVariantFromMatchType
instead.
Should be used in oneOf output descriptions.
Create a one-of-variant 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-variant 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 oneOfVariantClassMatcher, oneOfVariantValueMatcher or oneOfVariantFromMatchType
instead.
Should be used in oneOf output descriptions.
Create a one-of-variant 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-variant 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.
Create a one-of-variant 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-variant 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.
Create a one-of-variant which output
if the provided value exactly matches one of the values provided in the second argument list.
Create a one-of-variant 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.
Create a one-of-variant 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-variant 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-variant 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.
Experimental!
Experimental!
Create a one-of-variant 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.
Create a one-of-variant which uses output
if the provided value (when interpreting as a server matches the matcher
predicate.
Create a one-of-variant which uses output
if the provided value (when interpreting as a server matches the matcher
predicate.
Should be used in oneOf output descriptions.
Create a one-of-variant 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-variant 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.
An output which maps to the status code in the response.
An output which maps to the status code in the response.
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 parameters:
- s
A supported streams implementation.
Creates a stream body with the given schema.
Creates a stream body with the given schema.
- Value parameters:
- 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.
Creates a stream body with a text schema.
Creates a stream body with a text schema.
- Value parameters:
- 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.
- Type parameters:
- 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.
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
[Since version 0.18.0]
Use customJsonBody
- Deprecated
[Since version 0.19.0]
- Deprecated
[Since version 0.19.0]
- Deprecated
[Since version 0.19.0]
- Deprecated
[Since version 0.19.0]
- Deprecated
[Since version 0.19.0]
Inherited methods
Concrete fields
Inherited fields
An input which matches if the request URI ends with a trailing slash, otherwise the result is a decode failure on the path. Has no effect when used by documentation or client interpreters.
An input which matches if the request URI ends with a trailing slash, otherwise the result is a decode failure on the path. Has no effect when used by documentation or client interpreters.
- Inherited from:
- TapirComputedInputs
Implicits
Implicits
Inherited implicits
- Inherited from:
- ModifyMacroSupport
- Inherited from:
- ModifyMacroSupport