# `AsyncApiSpex.Plug.RenderSpec`
[🔗](https://github.com/jamescarr/ankusa/blob/async_api_spex-v0.2.0/packages/async_api_spex/lib/async_api_spex/plug/render_spec.ex#L2)

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`.

# `call`

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

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

# `init`

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

Returns the configured `AsyncApiSpex.Spec` module.

Raises `ArgumentError` when the `:spec` option is missing.

# `send_spec`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
