Documentation
¶
Index ¶
- func Contains(a []string, b string) bool
- func DataTypeValues() map[DataType]string
- func Filter(a []string, delegate func(string) bool) []string
- func MetaSchemaVersions() []string
- func ResolveIDs(b json.RawMessage) map[ID]*Schema
- type DataType
- type ID
- type Path
- type Reference
- type Schema
- type SchemaVersion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DataTypeValues ¶
func MetaSchemaVersions ¶
func MetaSchemaVersions() []string
MetaSchemaVersions returns a list of all supported schema versions
func ResolveIDs ¶
func ResolveIDs(b json.RawMessage) map[ID]*Schema
ResolveIDs looks over the raw json and traverses over the schema looking for $id fields,
Types ¶
type DataType ¶
type DataType string
DataType specifies the data type for a schema
const ( // String type is used for strings of text. It may contain Unicode characters String DataType = "string" // Object are the mapping type in JSON. They map “keys” to “values”. In JSON, the “keys” must always be strings. Each of these pairs is conventionally referred to as a “property” Object DataType = "object" // Array are used for ordered elements. In JSON, each element in an array may be of a different type Array DataType = "array" // Integer type is used for integral numbers Integer DataType = "integer" // Number type is used for any numeric type, either integers or floating point numbers Number DataType = "number" // Boolean type matches only two special values: true and false. Note that values that evaluate to true or false, such as 1 and 0, are not accepted by the schema Boolean DataType = "boolean" // Null type is generally used to represent a missing value. When a schema specifies a type of null, it has only one acceptable value: null Null DataType = "null" )
JSON Schema defines the following basic types
type ID ¶
type ID string
ID ($id) property is a URI-reference that serves two purposes:
It declares a unique identifier for the schema. It declares a base URI against which $ref URI-references are resolved.
func (ID) Fragment ¶
Fragment returns the fragment identifier from the ID, everything after the hash mark '#'
func (*ID) UnmarshalJSON ¶
type Reference ¶
type Reference string
Reference ($ref) is used to reference other schemas, used with allOf, anyOf and oneOf
func (Reference) IsNotEmpty ¶
func (*Reference) UnmarshalJSON ¶
type Schema ¶
type Schema struct {
// Annotations
Description string `json:"description,omitempty"`
Title string `json:"title,omitempty"`
Default string `json:"default,omitempty"`
Examples string `json:"examples,omitempty"`
ID ID `json:"$id,omitempty"`
Schema SchemaVersion `json:"$schema,omitempty"`
Ref Reference `json:"$ref,omitempty"`
Defs map[string]*Schema `json:"$defs,omitempty"`
// Deprecated use Defs
Definitions map[string]*Schema `json:"definitions,omitempty"`
Anchor string `json:"$anchor,omitempty"`
Type DataType `json:"type,omitempty"`
// Required Properties
Required []string `json:"required,omitempty"`
// Properties
Properties map[string]*Schema `json:"properties,omitempty"`
AdditionalProperties *bool `json:"additionalproperties,omitempty"`
Items *Schema `json:"items,omitempty"`
OneOf []*Schema `json:"oneof,omitempty"`
AnyOf []*Schema `json:"anyof,omitempty"`
AllOf []*Schema `json:"allof,omitempty"`
Enum []string `json:"enum,omitempty"`
// Size
MaxProperties *uint32 `json:"maxproperties,omitempty"`
MinProperties *uint32 `json:"minproperties,omitempty"`
// Validation
MaxLength *uint32 `json:"maxlength,omitempty"`
MinLength *uint32 `json:"minlength,omitempty"`
MaxContains *uint32 `json:"maxcontains,omitempty"`
MinContains *uint32 `json:"mincontains,omitempty"`
MaxItems *uint32 `json:"maxitems,omitempty"`
MinItems *uint32 `json:"minitems,omitempty"`
Maximum *int32 `json:"maximum,omitempty"`
ExclusiveMaximum *int32 `json:"exclusivemaximum,omitempty"`
Minimum *int32 `json:"minimum,omitempty"`
ExclusiveMinimum *int32 `json:"exclusiveminimum,omitempty"`
Pattern string `json:"pattern,omitempty"`
Parent *Schema `json:"-"`
Key string `json:"-"`
}
Schema the base JSON Schema
func (*Schema) AllDefinitions ¶
AllDefinitions returns a merged map of the definitions and $def fields, $def takes precedences
func (*Schema) UnmarshalJSON ¶
type SchemaVersion ¶
type SchemaVersion string
SchemaVersion declares which version of the JSON Schema standard that the schema was written against
const ( // Draft07 is not really supported Draft07 SchemaVersion = "http://json-schema.org/draft-07/schema" // Draft08 old name not really supported Draft08 SchemaVersion = "http://json-schema.org/draft-08/schema" // IETF_2019_19 formerly known as Draft 8 IETF_2019_19 SchemaVersion = "https://json-schema.org/2019-09/schema" )
func (*SchemaVersion) UnmarshalJSON ¶
func (s *SchemaVersion) UnmarshalJSON(b []byte) error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
sample_schemas
|
|
|
allOf
Code generated by jsonschema.
|
Code generated by jsonschema. |
|
allOfObject
Code generated by jsonschema.
|
Code generated by jsonschema. |
|
anyOf
Code generated by jsonschema.
|
Code generated by jsonschema. |
|
basic
Code generated by jsonschema.
|
Code generated by jsonschema. |
|
enum
Code generated by jsonschema.
|
Code generated by jsonschema. |
|
nesting
Code generated by jsonschema.
|
Code generated by jsonschema. |
|
oneOf
Code generated by jsonschema.
|
Code generated by jsonschema. |
|
reference
Code generated by jsonschema.
|
Code generated by jsonschema. |
|
referenceOutside
Code generated by jsonschema.
|
Code generated by jsonschema. |
|
spec
|
|