# `JSV.Resolver`
[🔗](https://github.com/lud/jsv/blob/v0.18.3/lib/jsv/resolver.ex#L1)

A behaviour describing the implementation of a [guides/build/custom resolver.
Resolves remote resources when building a JSON schema.

# `resolvable`

```elixir
@type resolvable() :: JSV.Key.ns() | JSV.Key.pointer() | JSV.Ref.t()
```

# `t`

```elixir
@opaque t()
```

# `resolve`

```elixir
@callback resolve(uri :: String.t(), opts :: term()) ::
  {:ok, map()} | {:normal, map()} | {:error, term()}
```

Receives an URI and the options passed in the resolver tuple to `JSV.build/2`
and returns a result tuple for a raw JSON schema map.

Returning boolean schemas from resolvers is not supported. You may wrap the
boolean value in a `$defs` or any other pointer as a workaround.

Schemas will be normalized using `JSV.Schema.normalize/1`. If the resolver
returns schema that are already in JSON-decoded form (like a response body
from an HTTP call) without atoms, module names or structs, the resolver
implementation can return `{:normal, map}` instead to skip the normalization.

# `chain_of`

```elixir
@spec chain_of([{module(), term()}], binary()) :: t()
```

Returns a new resolver, with the given behaviour implementations, and a
default meta-schema URL to use with schemas that do not declare a `$schema`
property.

# `fetch_resolved`

```elixir
@spec fetch_resolved(t(), resolvable() | {:meta, resolvable()}) ::
  {:ok, JSV.Resolver.Resolved.t() | {:alias_of, JSV.Key.t()}} | {:error, term()}
```

Returns the raw schema identified by the given key if was previously resolved.

# `fetch_vocabulary`

```elixir
@spec fetch_vocabulary(t(), binary()) ::
  {:ok, %{optional(binary()) =&gt; boolean()}} | {:error, term()}
```

Returns the $vocabulary property of a schema identified by its namespace.

The schema must have been resolved previously as a meta-schema (_i.e._ found
in an $schema property of a resolved schema).

# `resolve`

```elixir
@spec resolve(t(), resolvable()) :: {:ok, t()} | {:error, term()}
```

Fetches the remote resource into the internal resolver cache and returns a new
resolver with that updated cache.

---

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