JSV.Resolver.Httpc (jsv v0.4.0)
View SourceA JSV.Resolver
implementation that will fetch the schemas from the web with
the help of the :httpc
module.
This resolver must be configured when used to build a schema. It also needs a proper JSON library to decode fetched schemas:
- From Elixir 1.18, the
JSON
module is automatically available in the standard library. - JSV can use Jason if listed in your
dependencies with the
"~> 1.0"
requirement. - JSV also supports Poison with the
"~> 6.0 or ~> 5.0"
requirement.
Options
This resolver supports the following options:
:allowed_prefixes
- This option is mandatory and contains the allowed prefixes to download from.:cache_dir
- The path of a directory to cache downloaded resources. The default value can be retrieved withdefault_cache_dir/0
and is based onSystem.tmp_dir!/0
. The option also acceptsfalse
to disable that cache. Note that there is no cache expiration mechanism.
Example
resolver_opts = [allowed_prefixes: ["https://json-schema.org/"], cache_dir: "_build/custom/dir"]
JSV.build(schema, resolver: {JSV.Resolver.BuiltIn, resolver_opts})
Summary
Functions
Returns the default directory used by the disk-based cache.
Functions
@spec default_cache_dir() :: binary()
Returns the default directory used by the disk-based cache.