View Source JSV.Ref (jsv v0.3.0)

Representation of a JSON Schema reference ($ref or $dynamicRef).

Summary

Functions

Encodes the given string as a JSON representation of a JSON pointer, that is with ~ as ~0 and / as ~1.

Creates a new reference from an URL, relative to the given namespace.

Like parse/2 but flags the reference as dynamic.

Types

ns()

@type ns() :: binary() | :root

t()

@type t() :: %JSV.Ref{
  arg: term(),
  dynamic?: term(),
  fragment: term(),
  kind: term(),
  ns: term()
}

Functions

escape_json_pointer(str)

@spec escape_json_pointer(binary()) :: binary()

Encodes the given string as a JSON representation of a JSON pointer, that is with ~ as ~0 and / as ~1.

parse(url, current_ns)

@spec parse(binary(), ns()) :: {:ok, t()} | {:error, term()}

Creates a new reference from an URL, relative to the given namespace.

If the URL is absolute and its namespace is different from the given namespace, returns an absolute URL.

parse_dynamic(url, current_ns)

@spec parse_dynamic(binary(), ns()) :: {:ok, t()} | {:error, term()}

Like parse/2 but flags the reference as dynamic.