# README
JSON Schema Helpers
This package contains utilities for working with JSON Schemas.
Listing all Possible JSON Schema Paths
Using jsonschemax.ListPaths()
you can get a list of all possible JSON paths in
a JSON Schema.
package main
import (
"bytes"
"fmt"
"github.com/ory/jsonschema/v3"
"github.com/ory/x/jsonschemax"
)
var schema = "..."
func main() {
c := jsonschema.NewCompiler()
_ = c.AddResource("test.json", bytes.NewBufferString(schema))
paths, _ := jsonschemax.ListPaths("test.json", c)
fmt.Printf("%+v", paths)
}
All keys are delimited using .
. Please note that arrays are denoted with #
when ListPathsWithArraysIncluded
is used. For example, the JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"providers": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
}
}
}
}
}
}
Results in paths:
[
{
"Title": "",
"Description": "",
"Examples": null,
"Name": "providers",
"Default": null,
"Type": [],
"TypeHint": 5,
"Format": "",
"Pattern": null,
"Enum": null,
"Constant": null,
"ReadOnly": false,
"MinLength": -1,
"MaxLength": -1,
"Required": false,
"Minimum": null,
"Maximum": null,
"MultipleOf": null,
"CustomProperties": null
},
{
"Title": "",
"Description": "",
"Examples": null,
"Name": "providers.#",
"Default": null,
"Type": {},
"TypeHint": 5,
"Format": "",
"Pattern": null,
"Enum": null,
"Constant": null,
"ReadOnly": false,
"MinLength": -1,
"MaxLength": -1,
"Required": false,
"Minimum": null,
"Maximum": null,
"MultipleOf": null,
"CustomProperties": null
},
{
"Title": "",
"Description": "",
"Examples": null,
"Name": "providers.#.id",
"Default": null,
"Type": "",
"TypeHint": 1,
"Format": "",
"Pattern": null,
"Enum": null,
"Constant": null,
"ReadOnly": false,
"MinLength": -1,
"MaxLength": -1,
"Required": false,
"Minimum": null,
"Maximum": null,
"MultipleOf": null,
"CustomProperties": null
}
]
# Functions
No description provided by the author
No description provided by the author
JSONPointerToDotNotation converts JSON Pointer "#/foo/bar" to dot-notation "foo.bar".
ListPaths lists all paths of a JSON Schema.
ListPathsBytes works like ListPathsWithRecursion but prepares the JSON Schema itself.
ListPathsWithArraysIncluded lists all paths of a JSON Schema.
ListPathsWithInitializedSchema loads the paths from the schema without compiling it.
ListPathsWithInitializedSchemaAndArraysIncluded loads the paths from the schema without compiling it.
ListPathsWithRecursion will follow circular references until maxRecursion is reached, without returning an error.
NewFromSanthoshError converts github.com/santhosh-tekuri/jsonschema.ValidationError to Error.
# Constants
No description provided by the author
No description provided by the author
ErrorTypeMissing represents a validation that failed because a value is missing.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author