A message on a channel: its metadata, headers, and payload.
payload and headers are AsyncAPI Schema Objects, which may be plain maps,
%AsyncApiSpex.Reference{} structs, or modules that export
__async_api_schema__/0. A module is extracted into components.schemas by
AsyncApiSpex.resolve/1 and replaced with a reference.
Use the use AsyncApiSpex.Message macro to declare a message:
defmodule MyApp.Messages do
use AsyncApiSpex.Message,
name: "OrderCreated",
payload: MyApp.Schemas.OrderCreatedV1
endThis defines message/0 returning a %AsyncApiSpex.Message{} and
__async_api_message__/0 returning {name, message}.
Summary
Functions
Declares a message on the calling module.
Types
@type t() :: %AsyncApiSpex.Message{ bindings: map() | nil, content_type: String.t() | nil, correlation_id: AsyncApiSpex.CorrelationId.t() | nil, description: String.t() | nil, examples: [term()] | nil, extensions: map(), headers: map() | AsyncApiSpex.Reference.t() | module() | nil, name: String.t() | nil, payload: map() | AsyncApiSpex.Reference.t() | module() | nil, summary: String.t() | nil, tags: [AsyncApiSpex.Tag.t()] | nil, title: String.t() | nil }
Functions
Declares a message on the calling module.
Options: [:title, :summary, :description, :content_type, :payload, :headers, :correlation_id, :tags, :bindings, :examples, :extensions] plus the required :name (a
string matching ~r/\A[A-Za-z0-9_.-]+\z/). Unknown options raise
ArgumentError. The option values are evaluated in the calling module's
context.