# `WardrikRest.Reader`

Reads an API's description into a `WardrikRest.Spec`.

A source is `{module, opts}`: a module with this behaviour, and what it reads.
`WardrikRest.Discovery` reads Google Discovery documents. Write one for another format to load
its APIs the same way:

    defmodule MyApp.Described do
      @behaviour WardrikRest.Reader

      @impl true
      def read(opts), do: {:ok, %WardrikRest.Spec{...}}
    end

    WardrikRest.API.load({MyApp.Described, path: "priv/api.json"}, name: "my_api", ...)

The spec's schemas are JSON Schema, and refer to its `types` as `%{"$ref" => name}`; each tool's
schema is fitted from them. See `WardrikRest.Spec`.

# `t`

```elixir
@type t() :: {module(), keyword()}
```

A reader and its options.

# `read`

```elixir
@callback read(opts :: keyword()) :: {:ok, WardrikRest.Spec.t()} | {:error, String.t()}
```

Returns the spec, or why the description can't be read.

# `read`

```elixir
@spec read(t()) :: {:ok, WardrikRest.Spec.t()} | {:error, String.t()}
```

Reads `source` with its reader.

---

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