Documentation
¶
Overview ¶
Copyright Kozyrev Yury MIT license.
Index ¶
- Constants
- func Generate(root interface{}) string
- type Generator
- func (g *Generator) Generate() (*JSONSchema, error)
- func (g *Generator) MustGenerate() *JSONSchema
- func (g *Generator) WithDefinition(name string, d interface{}) *Generator
- func (g *Generator) WithDefinitions(d map[string]interface{}) *Generator
- func (g *Generator) WithRoot(r interface{}) *Generator
- type JSONSchema
- type Options
- type Property
Constants ¶
View Source
const DEFAULT_SCHEMA = "http://json-schema.org/schema#"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
func NewGenerator ¶
func (*Generator) Generate ¶
func (g *Generator) Generate() (*JSONSchema, error)
Generate generates a schema for the provided interface.
func (*Generator) MustGenerate ¶
func (g *Generator) MustGenerate() *JSONSchema
func (*Generator) WithDefinition ¶
func (*Generator) WithDefinitions ¶
type JSONSchema ¶
type JSONSchema struct {
Schema string `json:"$schema,omitempty"`
Definitions map[string]Property `json:"definitions,omitempty"`
Property
}
func (JSONSchema) String ¶
func (d JSONSchema) String() string
String return the JSON encoding of the JSONSchema as a string
type Property ¶
type Property struct {
Type string `json:"type,omitempty"`
Format string `json:"format,omitempty"`
Items *Property `json:"items,omitempty"`
Properties map[string]*Property `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
AdditionalProperties interface{} `json:"additionalProperties,omitempty"`
Description string `json:"description,omitempty"`
AnyOf []*Property `json:"anyOf,omitempty"`
OneOf []*Property `json:"oneOf,omitempty"`
Dependencies map[string]*Property `json:"dependencies,omitempty"`
Default interface{} `json:"default,omitempty"`
Extensions map[string]interface{} `json:"-"`
// numbers validators
MultipleOf *float64 `json:"multipleOf,omitempty"`
Maximum *float64 `json:"maximum,omitempty"`
Minimum *float64 `json:"minimum,omitempty"`
ExclusiveMaximum *float64 `json:"exclusiveMaximum,omitempty"`
ExclusiveMinimum *float64 `json:"exclusiveMinimum,omitempty"`
// string validators
MaxLength *int64 `json:"maxLength,omitempty"`
MinLength *int64 `json:"minLength,omitempty"`
Pattern string `json:"pattern,omitempty"`
// Enum is defined for arbitrary types, but I'm currently just implementing it for strings.
Enum []string `json:"enum,omitempty"`
Title string `json:"title,omitempty"`
// Implemented for strings and numbers
Const interface{} `json:"const,omitempty"`
Ref string `json:"$ref,omitempty"`
// contains filtered or unexported fields
}
func (*Property) MarshalJSON ¶ added in v0.2.0
Click to show internal directories.
Click to hide internal directories.