Declarative AsyncAPI 3.0 documents for Elixir applications.
Build an AsyncApiSpex.Document from structs, optionally declaring reusable
schemas with use AsyncApiSpex.Schema and messages with
use AsyncApiSpex.Message, then:
resolve/1extracts those modules intocomponentsand replaces their uses with references;to_map/1produces a JSON-encodable map;encode!/1produces JSON;validate/1checks the document and reports errors by JSON path.
Serve a document from a Plug application with AsyncApiSpex.Plug.RenderSpec,
or write it to a file with mix async_api_spex.gen.
Summary
Functions
Returns the media type of an AsyncAPI document, "application/asyncapi+json".
Encodes a document as a JSON string. Resolves it first.
Extracts schema and message modules into components, returning a new document.
Encodes a document as a JSON-encodable map. Resolves it first.
Validates a document, resolving it first.
Functions
@spec content_type() :: String.t()
Returns the media type of an AsyncAPI document, "application/asyncapi+json".
@spec encode!(AsyncApiSpex.Document.t()) :: binary()
Encodes a document as a JSON string. Resolves it first.
@spec resolve(AsyncApiSpex.Document.t()) :: AsyncApiSpex.Document.t()
Extracts schema and message modules into components, returning a new document.
See AsyncApiSpex.Resolver.resolve/1. Idempotent.
@spec to_map(AsyncApiSpex.Document.t()) :: map()
Encodes a document as a JSON-encodable map. Resolves it first.
@spec validate(AsyncApiSpex.Document.t()) :: :ok | {:error, [String.t()]}
Validates a document, resolving it first.
Returns :ok or {:error, messages}, where each message names the JSON path
of the problem. See AsyncApiSpex.Validator.validate/1.