Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Version = "http://json-schema.org/draft-04/schema#"
Version is the JSON Schema version. If extending JSON Schema with custom values use a custom URI. RFC draft-wright-json-schema-00, section 6
Functions ¶
This section is empty.
Types ¶
type Definitions ¶
Definitions hold schema definitions. http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.26 RFC draft-wright-json-schema-validation-00, section 5.26
type Reflector ¶
type Reflector struct { // AllowAdditionalProperties will cause the Reflector to generate a schema // with additionalProperties to 'true' for all struct types. This means // the presence of additional keys in JSON objects will not cause validation // to fail. Note said additional keys will simply be dropped when the // validated JSON is unmarshaled. AllowAdditionalProperties bool // RequiredFromJSONSchemaTags will cause the Reflector to generate a schema // that requires any key tagged with `jsonschema:required`, overriding the // default of requiring any key *not* tagged with `json:,omitempty`. RequiredFromJSONSchemaTags bool // ExpandedStruct will cause the toplevel definitions of the schema not // be referenced itself to a definition. ExpandedStruct bool // TitleNotation will cause the Reflector to generate a schema // with different title notations. This means // the title will be transform your structure name from // camelcase(go-case) notation to the declared. There are // two supported notations: snake and dash. // P.S. first letter capitalisation will be ignored (converted to lower-case) TitleNotation string }
A Reflector reflects values into a Schema.
func (*Reflector) ReflectFromType ¶
ReflectFromType generates root schema
func (*Reflector) ReflectTitle ¶
ReflectTitle return only structure name as profile type title
type Schema ¶
type Schema struct { *Type Definitions Definitions `json:"definitions,omitempty"` }
Schema is the root schema. RFC draft-wright-json-schema-00, section 4.5
func Reflect ¶
func Reflect(v interface{}) *Schema
Reflect reflects to Schema from a value using the default Reflector
func ReflectFromType ¶
ReflectFromType generates root schema using the default Reflector
type Type ¶
type Type struct { // RFC draft-wright-json-schema-00 // Version string `json:"$schema,omitempty"` // section 6.1 Version string `json:"-"` // section 6.1 Ref string `json:"$ref,omitempty"` // section 7 // RFC draft-wright-json-schema-validation-00, section 5 MultipleOf int `json:"multipleOf,omitempty"` // section 5.1 Maximum int `json:"maximum,omitempty"` // section 5.2 ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"` // section 5.3 Minimum int `json:"minimum,omitempty"` // section 5.4 ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"` // section 5.5 MaxLength int `json:"maxLength,omitempty"` // section 5.6 MinLength int `json:"minLength,omitempty"` // section 5.7 Pattern string `json:"pattern,omitempty"` // section 5.8 AdditionalItems *Type `json:"additionalItems,omitempty"` // section 5.9 Items *Type `json:"items,omitempty"` // section 5.9 MaxItems int `json:"maxItems,omitempty"` // section 5.10 MinItems int `json:"minItems,omitempty"` // section 5.11 UniqueItems bool `json:"uniqueItems,omitempty"` // section 5.12 MaxProperties int `json:"maxProperties,omitempty"` // section 5.13 MinProperties int `json:"minProperties,omitempty"` // section 5.14 Required []string `json:"required,omitempty"` // section 5.15 Properties map[string]*Type `json:"properties,omitempty"` // section 5.16 PatternProperties map[string]*Type `json:"patternProperties,omitempty"` // section 5.17 AdditionalProperties json.RawMessage `json:"additionalProperties,omitempty"` // section 5.18 Dependencies map[string]*Type `json:"dependencies,omitempty"` // section 5.19 Enum []interface{} `json:"enum,omitempty"` // section 5.20 Type string `json:"type,omitempty"` // section 5.21 AllOf []*Type `json:"allOf,omitempty"` // section 5.22 AnyOf []*Type `json:"anyOf,omitempty"` // section 5.23 OneOf []*Type `json:"oneOf,omitempty"` // section 5.24 Not *Type `json:"not,omitempty"` // section 5.25 Definitions Definitions `json:"definitions,omitempty"` // section 5.26 // RFC draft-wright-json-schema-validation-00, section 6, 7 Title string `json:"title,omitempty"` // section 6.1 Description string `json:"description,omitempty"` // section 6.1 Default interface{} `json:"default,omitempty"` // section 6.2 Format string `json:"format,omitempty"` // section 7 // RFC draft-wright-json-schema-hyperschema-00, section 4 Media *Type `json:"media,omitempty"` // section 4.3 BinaryEncoding string `json:"binaryEncoding,omitempty"` // section 4.3 }
Type represents a JSON Schema object type.