Body

sealed interface Body<T : Any>(source)

Describes how an endpoint body is represented on the wire.

A body couples the semantic payload type T with the codec and media type needed to encode and decode it. Request and response definitions both use this contract.

Parameters

T

payload type exposed to callers and generated clients.

Inheritors

Properties

Link copied to clipboard
abstract val codec: ByteArrayCodec<T>

Codec responsible for the byte-level representation of the payload.

Link copied to clipboard
abstract val mediaType: MediaType?

Preferred media type for the body, or null when the payload is not tied to a specific one.

Link copied to clipboard
abstract val name: String

Short diagnostic name used in generated code and codec error messages.

Functions

Link copied to clipboard
open fun bytes(value: T): ByteArray?

Encodes value into its wire representation.