jsonschema

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Object = "object"

Functions

func Hydrate

func Hydrate(ctx context.Context, anyVal interface{}, cwd string, c *client.MassdriverClient) (interface{}, error)

func Loader

func Loader(path string) gojsonschema.JSONLoader

Load a JSON Schema with or without a path prefix

func Validate

func Validate(schemaPath string, documentPath string) (*gojsonschema.Result, error)

Validate the input object against the schema

func WriteDereferencedSchema

func WriteDereferencedSchema(schemaFilePath string, outFile io.Writer, c *client.MassdriverClient) error

Types

type Example added in v0.4.4

type Example struct {
	Name   string `json:"__name"`
	Values map[string]interface{}
}

func (*Example) UnmarshalJSON added in v0.4.4

func (e *Example) UnmarshalJSON(b []byte) error

type GenerateAuthFile

type GenerateAuthFile struct {
	Format   string  `json:"format"`
	Template *string `json:"template,omitempty"`
}

type PropertiesMap

type PropertiesMap map[string]Property

PropertiesMap is a named map of Property

type Property

type Property struct {
	AdditionalProperties bool              `json:"additionalProperties"`
	Type                 string            `json:"type"`
	Items                *Property         `json:"items"`
	Properties           PropertiesMap     `json:"properties,omitempty"`
	Default              interface{}       `json:"default,omitempty"`
	GenerateAuthFile     *GenerateAuthFile `json:"md.generateAuthFile,omitempty"`
	Minimum              *float64          `json:"minimum,omitempty"`
}

Property is a single JSON Schema property field

type RefdSchema

type RefdSchema struct {
	SchemaID   string
	Definition interface{}
}

A RefdSchema is a JSON Schema that may contain $ref

func (*RefdSchema) Type

func (r *RefdSchema) Type() string

type Schema

type Schema struct {
	Properties PropertiesMap `json:"properties"`
	Required   []string      `json:"required,omitempty"`
	Examples   []Example     `json:"examples,omitempty"`
	Type       string        `json:"type,omitempty"`
}

Schema is a flimsy representation of a JSON Schema. It provides just enough structure to get type information.

func GetJSONSchema

func GetJSONSchema(path string) (Schema, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL