JsonSchema.Parser.Util (json_schema v0.6.0)

Copy Markdown View Source

A module containing utility functions for JSON schema parsers.

Summary

Functions

Adds a child to the fragment of a URI.

Creates a new type dictionary based on the given type definition and an optional ID.

Returns a list of type paths when given a type dictionary.

Returns the name of the type of the given value.

Parse a list of JSON schema objects that have a child relation to another schema object with the specified parent_id.

Types

nodeParser()

Functions

add_fragment_child(uri, child)

@spec add_fragment_child(URI.t(), String.t() | :anonymous) :: URI.t()

Adds a child to the fragment of a URI.

Examples

iex> add_fragment_child(URI.parse("#/definitions/foo"), "bar")
URI.parse("#/definitions/foo/bar")

create_type_dict(type_def, path, id)

@spec create_type_dict(
  JsonSchema.Types.typeDefinition(),
  URI.t(),
  URI.t() | nil
) :: JsonSchema.Types.typeDictionary()

Creates a new type dictionary based on the given type definition and an optional ID.

create_types_list(type_dict, path)

@spec create_types_list(JsonSchema.Types.typeDictionary(), URI.t()) :: [URI.t()]

Returns a list of type paths when given a type dictionary.

get_type(value)

@spec get_type(any()) :: String.t()

Returns the name of the type of the given value.

Examples

iex> get_type([1,2,3]) "list"

iex> get_type(%{"type" => "string"}) "object"

iex> get_type("name") "string"

iex> get_type(42) "integer"

parse_child_types(child_nodes, parent_id, path)

Parse a list of JSON schema objects that have a child relation to another schema object with the specified parent_id.

parse_type(schema_node, parent_id, path, name, name_is_regex \\ false)

@spec parse_type(
  JsonSchema.Types.schemaNode(),
  URI.t() | nil,
  URI.t(),
  String.t() | :anonymous,
  boolean()
) :: JsonSchema.Parser.ParserResult.t()

Parses a node type.