Documentation
¶
Overview ¶
Package jsonschema has functionality related to json schema support.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertStringToType ¶ added in v0.17.1
ConvertStringToType converts a string value to jsonschema type.
func EnsureType ¶ added in v0.17.1
EnsureType checks if the given value v respects json schema type t. Returns a type default value if v is nil. Error is returned on type mismatch or type not implemented.
Types ¶
type ErrSchemaValidation ¶ added in v0.17.1
type ErrSchemaValidation struct {
// Path is a key path to the property.
Path []string
// Msg is an error message.
Msg string
// contains filtered or unexported fields
}
ErrSchemaValidation is a validation error.
func NewErrSchemaValidation ¶ added in v0.17.1
func NewErrSchemaValidation(path []string, msg string) ErrSchemaValidation
NewErrSchemaValidation creates a new error.
func (ErrSchemaValidation) Error ¶ added in v0.17.1
func (err ErrSchemaValidation) Error() string
Error implements error interface.
type ErrSchemaValidationArray ¶ added in v0.17.1
type ErrSchemaValidationArray []ErrSchemaValidation
ErrSchemaValidationArray is an array of validation errors.
func (ErrSchemaValidationArray) Error ¶ added in v0.17.1
func (err ErrSchemaValidationArray) Error() string
Error implements error interface.
type ErrTypeMismatch ¶ added in v0.17.2
type ErrTypeMismatch struct {
// contains filtered or unexported fields
}
ErrTypeMismatch is an error when expected jsonschema type and given values mismatch.
func NewErrTypeMismatch ¶ added in v0.17.2
func NewErrTypeMismatch(act, exp any) ErrTypeMismatch
NewErrTypeMismatch constructs new ErrTypeMismatch.
func (ErrTypeMismatch) Error ¶ added in v0.17.2
func (err ErrTypeMismatch) Error() string
Error implements error interface.
type Schema ¶ added in v0.1.2
type Schema struct {
ID string `json:"$id,omitempty"`
Schema string `json:"$schema,omitempty"`
Title string `json:"title"`
Description string `json:"description"`
Type Type `json:"type"`
Required []string `json:"required"`
// @todo make a recursive type of properties.
Properties map[string]any `json:"properties"`
}
Schema is a json schema definition. It doesn't implement all and may not comply fully. See https://json-schema.org/specification.html
type Type ¶
type Type string
Type is a json schema type.
const ( String Type = "string" Number Type = "number" Integer Type = "integer" Boolean Type = "boolean" Null Type = "null" Object Type = "object" Array Type = "array" Unsupported Type = "UNSUPPORTED" )
Json schema types.
func TypeFromString ¶ added in v0.1.2
TypeFromString creates a Type with enum validation.
func (*Type) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler to parse Json Schema type.