Documentation ¶
Overview ¶
Package schema defines helpers for working with JSON schema. As defined by https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-04
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromKnownJSONType ¶
func FromKnownJSONType(t KnownJSONType) (v1.TransformIOType, error)
FromKnownJSONType returns the TransformIOType for the given KnownJSONType.
Types ¶
type KnownJSONType ¶
type KnownJSONType string
KnownJSONType is all the known JSON types. See https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-04#section-3.5
const ( // KnownJSONTypeArray is the JSON type for arrays. KnownJSONTypeArray KnownJSONType = "array" // KnownJSONTypeBoolean is the JSON type for booleans. KnownJSONTypeBoolean KnownJSONType = "boolean" // KnownJSONTypeInteger is the JSON type for integers. KnownJSONTypeInteger KnownJSONType = "integer" // KnownJSONTypeNull is the JSON type for null. KnownJSONTypeNull KnownJSONType = "null" // KnownJSONTypeNumber is the JSON type for numbers. KnownJSONTypeNumber KnownJSONType = "number" // KnownJSONTypeObject is the JSON type for objects. KnownJSONTypeObject KnownJSONType = "object" // KnownJSONTypeString is the JSON type for strings. KnownJSONTypeString KnownJSONType = "string" )
func FromTransformIOType ¶
func FromTransformIOType(c v1.TransformIOType) KnownJSONType
FromTransformIOType returns the matching JSON type for the given TransformIOType. It returns an empty string if the type is not valid, call IsValid() before calling this method.
func (KnownJSONType) IsEquivalent ¶
func (t KnownJSONType) IsEquivalent(t2 KnownJSONType) bool
IsEquivalent returns true if the two supplied types are equal, or if the first type is an integer and the second is a number. This is because the JSON schema spec allows integers to be used in place of numbers.