Skip to content

Channels and operations

from litestar_asyncapi.spec import Channel, Operation, OperationAction, Parameter, Reply

A channel is an address that messages travel through. An operation says whether the application sends or receives on a channel.

Channels

litestar_asyncapi.spec.Channel

Bases: BaseSchemaObject

AsyncAPI Channel object.

address: str | None = None

Transport address, which may contain {parameter} expressions.

title: str | None = None

Human-friendly channel title.

summary: str | None = None

Short summary of the channel.

description: str | None = None

Longer description of the channel; CommonMark is allowed.

messages: dict[str, Message | Reference] | None = None

Messages that may be sent on the channel, keyed by message key.

parameters: dict[str, Parameter | Reference] | None = None

Parameters for expressions in address.

servers: list[Reference] | None = None

References to the servers that host the channel; all servers when omitted.

tags: list[Tag | Reference] | None = None

Tags for logical grouping.

external_docs: ExternalDocumentation | Reference | None = None

Additional external documentation.

bindings: dict[str, Any] | Reference | None = None

Protocol-specific channel bindings.

extensions: dict[str, Any] = field(default_factory=dict)

Specification extensions; every key must start with x-.

litestar_asyncapi.spec.Parameter

Bases: BaseSchemaObject

AsyncAPI 3.0 Parameter object.

description: str | None = None

Description of the parameter; CommonMark is allowed.

enum: list[str] | None = None

Allowed values of the parameter.

default: str | None = None

Value used when none is supplied.

examples: list[str] | None = None

Example values.

location: str | None = None

Runtime expression for the parameter's value in a message.

extensions: dict[str, Any] = field(default_factory=dict)

Specification extensions; every key must start with x-.

Operations

litestar_asyncapi.spec.Operation

Bases: BaseSchemaObject

AsyncAPI Operation object.

action: OperationAction

Direction from the application's perspective: send or receive.

channel: Reference

Reference to the channel the operation acts on.

title: str | None = None

Human-friendly operation title.

summary: str | None = None

Short summary of the operation.

description: str | None = None

Longer description of the operation; CommonMark is allowed.

tags: list[Tag | Reference] | None = None

Tags for logical grouping.

external_docs: ExternalDocumentation | Reference | None = None

Additional external documentation.

messages: list[Message | Reference] | None = None

References to the channel messages the operation carries; all of them when omitted.

reply: Reply | Reference | None = None

Reply that the operation expects, for request and reply patterns.

traits: list[OperationTrait | Reference] | None = None

Traits applied to the operation.

bindings: dict[str, Any] | Reference | None = None

Protocol-specific operation bindings.

security: list[SecurityScheme | Reference] | None = None

Security schemes that apply to the operation.

extensions: dict[str, Any] = field(default_factory=dict)

Specification extensions; every key must start with x-.

litestar_asyncapi.spec.OperationTrait

Bases: BaseSchemaObject

Reusable operation properties.

title: str | None = None

Human-friendly operation title.

summary: str | None = None

Short summary of the operation.

description: str | None = None

Longer description of the operation; CommonMark is allowed.

tags: list[Tag | Reference] | None = None

Tags for logical grouping.

external_docs: ExternalDocumentation | Reference | None = None

Additional external documentation.

bindings: dict[str, Any] | Reference | None = None

Protocol-specific operation bindings.

security: list[SecurityScheme | Reference] | None = None

Security schemes that apply to the operation.

extensions: dict[str, Any] = field(default_factory=dict)

Specification extensions; every key must start with x-.

litestar_asyncapi.spec.OperationAction

Bases: StrEnum

AsyncAPI operation direction (from the application's perspective).

RECEIVE = 'receive'

SEND = 'send'

Replies

litestar_asyncapi.spec.Reply

Bases: BaseSchemaObject

AsyncAPI Reply object for request and reply patterns.

address: ReplyAddress | Reference | None = None

Where the reply is sent when it is not a fixed channel address.

channel: Reference | None = None

Reference to the channel the reply is sent on.

messages: list[Reference] | None = None

References to the messages that may be sent as the reply.

extensions: dict[str, Any] = field(default_factory=dict)

Specification extensions; every key must start with x-.

litestar_asyncapi.spec.ReplyAddress

Bases: BaseSchemaObject

Describes the reply address used in request/reply messaging patterns.

location: str

Runtime expression for the reply address, such as $message.header#/replyTo.

description: str | None = None

Description of the address; CommonMark is allowed.

extensions: dict[str, Any] = field(default_factory=dict)

Specification extensions; every key must start with x-.