json_schema v0.1.0 JsonSchema.TypePath View Source

Module for creating, manipulating, and printing type paths.

Link to this section Summary

Functions

Converts a json schema path like “#/definitions/foo” into its corresponding JsonSchema.TypePath

Converts a JsonSchema.TypePath back to its string representation

Returns true if the specified type can be treated as a JsonSchema.TypePath. Note that it also returns false if the specified type is a string representation of a JsonSchema.TypePath

Link to this section Types

Link to this section Functions

Link to this function add_child(segments, segment) View Source
add_child(t(), String.t()) :: t()

Adds a child to an existing JsonSchema.TypePath.

Examples

iex> JsonSchema.TypePath.add_child(["#", "definitions", "foo"], "")
["#", "definitions", "foo"]

iex> JsonSchema.TypePath.add_child(["#", "definitions"], "bar")
["#", "definitions", "bar"]
Link to this function from_string(string) View Source
from_string(String.t()) :: t()

Converts a json schema path like “#/definitions/foo” into its corresponding JsonSchema.TypePath.

Examples

iex> JsonSchema.TypePath.from_string("")
[]

iex> JsonSchema.TypePath.from_string("#")
["#"]

iex> JsonSchema.TypePath.from_string("#/definitions/foo")
["#", "definitions", "foo"]
Link to this function to_string(segments) View Source
to_string(t()) :: String.t()

Converts a JsonSchema.TypePath back to its string representation.

Examples

iex> JsonSchema.TypePath.to_string([])
""

iex> JsonSchema.TypePath.to_string(["#"])
"#"

iex> JsonSchema.TypePath.to_string(["#", "definitions", "foo"])
"#/definitions/foo"
Link to this function type_path?(path) View Source
type_path?(any()) :: boolean()

Returns true if the specified type can be treated as a JsonSchema.TypePath. Note that it also returns false if the specified type is a string representation of a JsonSchema.TypePath.

Examples

iex> JsonSchema.TypePath.type_path?("")
false

iex> JsonSchema.TypePath.type_path?("#/definitions/foo")
false

iex> JsonSchema.TypePath.type_path?([])
false

iex> JsonSchema.TypePath.type_path?(["bar"])
false

iex> JsonSchema.TypePath.type_path?(["#"])
true

iex> JsonSchema.TypePath.type_path?(["#", "foo"])
true