AsyncApiSpex.Plug.RenderSpec (async_api_spex v0.1.0)

Copy Markdown View Source

A Plug that serves an AsyncAPI document with the application/asyncapi+json content type.

Configure it with a module implementing AsyncApiSpex.Spec:

forward "/asyncapi.json", AsyncApiSpex.Plug.RenderSpec, spec: MyApp.AsyncApi

Or send a document directly from your own route with send_spec/2.

Summary

Functions

Calls spec/0 on the configured module and sends the encoded document.

Returns the configured AsyncApiSpex.Spec module.

Sends document as a 200 response with the AsyncAPI content type and halts the connection.

Functions

call(conn, spec)

@spec call(Plug.Conn.t(), module()) :: Plug.Conn.t()

Calls spec/0 on the configured module and sends the encoded document.

init(opts)

@spec init(keyword()) :: module()

Returns the configured AsyncApiSpex.Spec module.

Raises ArgumentError when the :spec option is missing.

send_spec(conn, document)

@spec send_spec(Plug.Conn.t(), AsyncApiSpex.Document.t()) :: Plug.Conn.t()

Sends document as a 200 response with the AsyncAPI content type and halts the connection.