Declares a reusable AsyncAPI Schema Object (JSON Schema draft-07).
Use it inside a module:
defmodule MyApp.Schemas do
use AsyncApiSpex.Schema,
name: "OrderCreatedV1",
schema: %{type: "object", required: ["id"], properties: %{id: %{type: "string"}}}
endThis defines schema/0 returning the schema map and
__async_api_schema__/0 returning {name, schema}. AsyncApiSpex.resolve/1
moves a schema module used from a message into components.schemas and
replaces the use with a reference.
name must be a string literal matching
~r/\A[A-Za-z0-9_.-]+\z/; schema must be a map literal. Both
requirements raise ArgumentError at compile time, as does any unknown
option.
Summary
Functions
Declares schema/0 and __async_api_schema__/0 on the calling module.