# `AsyncApiSpex.Resolver`
[🔗](https://github.com/jamescarr/ankusa/blob/async_api_spex-v0.2.0/packages/async_api_spex/lib/async_api_spex/resolver.ex#L1)

Extracts reusable modules into `AsyncApiSpex.Components` and replaces their
uses with `AsyncApiSpex.Reference` structs.

A channel message that is a module exporting `__async_api_message__/0` moves
into `components.messages`. Any atom inside a message's `payload`, `headers`,
or `extensions` (recursively through maps and lists) that is a module
exporting `__async_api_schema__/0` moves into `components.schemas`. Both are
replaced with a reference at the point of use.

Two different modules claiming the same component name raise
`ArgumentError`. Using the same module twice is fine. `resolve/1` is
idempotent.

# `resolve`

```elixir
@spec resolve(AsyncApiSpex.Document.t()) :: AsyncApiSpex.Document.t()
```

Resolves `document`, returning a new document with component references.

Raises `ArgumentError` when two different modules claim the same component
name.

---

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