json_schema v0.1.0 JsonSchema.TypePath View Source
Module for creating, manipulating, and printing type paths.
Link to this section Summary
Functions
Adds a child to an existing JsonSchema.TypePath
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
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"]
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"]
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"
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