Documentation ¶
Index ¶
Constants ¶
View Source
const ( TypeBoolean = "boolean" TypeInteger = "integer" TypeNumber = "number" TypeString = "string" TypeArray = "array" TypeObject = "object" )
JSON Schema type constants
Variables ¶
View Source
var ErrSchemaInvalid = errors.New("schema is invalid")
ErrSchemaInvalid represents an error indicating an invalid schema.
View Source
var GenerateInline = true
GenerateInline determines whether to generate inline schemas.
Functions ¶
This section is empty.
Types ¶
type NestedSchemaReference ¶
type Schema ¶
type Schema struct { Type string `json:"type,omitempty"` Description string `json:"description,omitempty"` Items *Schema `json:"items,omitempty"` Properties map[string]*Schema `json:"properties,omitempty"` AdditionalProperties interface{} `json:"additionalProperties,omitempty"` PatternProperties map[string]*Schema `json:"patternProperties,omitempty"` Required []string `json:"required,omitempty"` Format string `json:"format,omitempty"` Enum []interface{} `json:"enum,omitempty"` Default interface{} `json:"default,omitempty"` Example interface{} `json:"example,omitempty"` Minimum *float64 `json:"minimum,omitempty"` ExclusiveMinimum *bool `json:"exclusiveMinimum,omitempty"` Maximum *float64 `json:"maximum,omitempty"` ExclusiveMaximum *bool `json:"exclusiveMaximum,omitempty"` MultipleOf float64 `json:"multipleOf,omitempty"` MinLength *uint64 `json:"minLength,omitempty"` MaxLength *uint64 `json:"maxLength,omitempty"` Pattern string `json:"pattern,omitempty"` MinItems *uint64 `json:"minItems,omitempty"` MaxItems *uint64 `json:"maxItems,omitempty"` UniqueItems bool `json:"uniqueItems,omitempty"` MinProperties *uint64 `json:"minProperties,omitempty"` MaxProperties *uint64 `json:"maxProperties,omitempty"` AllOf []*Schema `json:"allOf,omitempty"` AnyOf []*Schema `json:"anyOf,omitempty"` OneOf []*Schema `json:"oneOf,omitempty"` Not *Schema `json:"not,omitempty"` Nullable bool `json:"nullable,omitempty"` ReadOnly bool `json:"readOnly,omitempty"` WriteOnly bool `json:"writeOnly,omitempty"` Deprecated bool `json:"deprecated,omitempty"` ContentEncoding string `json:"contentEncoding,omitempty"` Ref string `json:"$ref,omitempty"` }
Schema represents a JSON Schema which can be generated from Go structs
func GenerateFromField ¶
func GenerateFromField(f reflect.StructField, mode Mode, definedRefs map[string]NestedSchemaReference) (string, bool, *Schema, error)
GenerateFromField generates a schema from a struct field.
func GenerateWithMode ¶
func GenerateWithMode(t reflect.Type, mode Mode, schema *Schema, definedRefs map[string]NestedSchemaReference) (*Schema, error)
GenerateWithMode generates a JSON Schema with the specified mode and additional options.
func (*Schema) HasValidation ¶
HasValidation checks if the schema has any validation rules defined.
func (*Schema) RemoveProperty ¶
RemoveProperty removes a property from the schema by name.
Click to show internal directories.
Click to hide internal directories.