Documentation
¶
Overview ¶
Package jsonschema uses reflection to generate JSON Schemas from Go types [1].
If json tags are present on struct fields, they will be used to infer property names and if a property is required (omitempty is present).
[1] http://json-schema.org/latest/json-schema-validation.html
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Schema ¶
type Schema struct { *Type Definitions Definitions `json:"definitions,omitempty"` }
Schema represents a JSON Schema.
func ReflectFromObjType ¶
func ReflectFromObjType(objtype *rpcreflect.ObjType) *Schema
rpcreflect is itself a description so we provide additional handling here
func ReflectFromType ¶
ReflectFromType a Schema from a reflect.Type.
type Type ¶
type Type struct { Type string `json:"type,omitempty"` Format string `json:"format,omitempty"` Items *Type `json:"items,omitempty"` Properties map[string]*Type `json:"properties,omitempty"` PatternProperties map[string]*Type `json:"patternProperties,omitempty"` AdditionalProperties json.RawMessage `json:"additionalProperties,omitempty"` Ref string `json:"$ref,omitempty"` Required []string `json:"required,omitempty"` MaxLength int `json:"maxLength,omitempty"` MinLength int `json:"minLength,omitempty"` Pattern string `json:"pattern,omitempty"` Enum []interface{} `json:"enum,omitempty"` Default interface{} `json:"default,omitempty"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` }
Type represents a JSON Schema type.
Click to show internal directories.
Click to hide internal directories.