Documentation ¶
Index ¶
- func FormatError(e *jsonschema.ValidationError) (string, string)
- func FormatValidationErrorForCLI(w io.Writer, conf []byte, err error)
- func JSONPointerToDotNotation(pointer string) (string, error)
- type Error
- type ErrorType
- type Path
- func ListPaths(ctx context.Context, ref string, compiler *jsonschema.Compiler) ([]Path, error)
- func ListPathsBytes(ctx context.Context, raw json.RawMessage, maxRecursion int16) ([]Path, error)
- func ListPathsWithArraysIncluded(ctx context.Context, ref string, compiler *jsonschema.Compiler) ([]Path, error)
- func ListPathsWithInitializedSchema(schema *jsonschema.Schema) ([]Path, error)
- func ListPathsWithInitializedSchemaAndArraysIncluded(schema *jsonschema.Schema) ([]Path, error)
- func ListPathsWithRecursion(ctx context.Context, ref string, compiler *jsonschema.Compiler, ...) ([]Path, error)
- type PathEnhancer
- type TypeHint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatError ¶
func JSONPointerToDotNotation ¶
JSONPointerToDotNotation converts JSON Pointer "#/foo/bar" to dot-notation "foo.bar".
Types ¶
type Error ¶
type Error struct { // Type is the error type. Type ErrorType // DocumentPointer is the JSON Pointer in the document. DocumentPointer string // SchemaPointer is the JSON Pointer in the schema. SchemaPointer string // DocumentFieldName is a pointer to the document in dot-notation: fo.bar.baz DocumentFieldName string }
Error represents a schema error.
func NewFromSanthoshError ¶
func NewFromSanthoshError(validationError jsonschema.ValidationError) *Error
NewFromSanthoshError converts github.com/santhosh-tekuri/jsonschema.ValidationError to Error.
type Path ¶
type Path struct { // Title of the path. Title string // Description of the path. Description string // Examples of the path. Examples []interface{} // Name is the JSON path name. Name string // Default is the default value of that path. Default interface{} // Type is a prototype (e.g. float64(0)) of the path type. Type interface{} TypeHint // Format is the format of the path if defined Format string // Pattern is the pattern of the path if defined Pattern *regexp.Regexp // Enum are the allowed enum values Enum []interface{} // first element in slice is constant value. note: slice is used to capture nil constant. Constant []interface{} // ReadOnly is whether the value is readonly ReadOnly bool // -1 if not specified MinLength int MaxLength int // Required if set indicates this field is required. Required bool Minimum *big.Float Maximum *big.Float MultipleOf *big.Float CustomProperties map[string]interface{} }
Path represents a JSON Schema Path.
func ListPaths ¶
ListPaths lists all paths of a JSON Schema. Will return an error if circular references are found.
func ListPathsBytes ¶
ListPathsBytes works like ListPathsWithRecursion but prepares the JSON Schema itself.
func ListPathsWithArraysIncluded ¶
func ListPathsWithArraysIncluded(ctx context.Context, ref string, compiler *jsonschema.Compiler) ([]Path, error)
ListPathsWithArraysIncluded lists all paths of a JSON Schema. Will return an error if circular references are found. Includes arrays with `#`.
func ListPathsWithInitializedSchema ¶
ListPathsWithInitializedSchema loads the paths from the schema without compiling it.
You MUST ensure that the compiler was using `ExtractAnnotations = true`.
func ListPathsWithInitializedSchemaAndArraysIncluded ¶
ListPathsWithInitializedSchemaAndArraysIncluded loads the paths from the schema without compiling it.
You MUST ensure that the compiler was using `ExtractAnnotations = true`. Includes arrays with `#`.