jsonschema

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Format

type Format string
const (
	FormatUnknown  Format = ""
	FormatDateTime Format = "date-time"
	FormatUUID     Format = "uuid"
	FormatEmail    Format = "email"
	FormatURI      Format = "uri"
	FormatDate     Format = "date"
)

type Property

type Property struct {
	Title                string              `json:"title,omitempty"`
	Description          string              `json:"description,omitempty"`
	Type                 Type                `json:"type,omitempty"`
	Properties           map[string]Property `json:"properties,omitempty"`
	Required             []string            `json:"required,omitempty"`
	AdditionalProperties *bool               `json:"additional_properties,omitempty"`
	Ref                  string              `json:"$ref,omitempty"`
	Format               Format              `json:"format,omitempty"`
	Default              interface{}         `json:"default,omitempty"`
	Enum                 []string            `json:"enum,omitempty"`
}

func NewProperty

func NewProperty(typ Type) Property

func (*Property) DisableAdditionalProperties

func (p *Property) DisableAdditionalProperties()

type Schema

type Schema struct {
	Title                string              `json:"title,omitempty"`
	Description          string              `json:"description,omitempty"`
	Schema               string              `json:"$schema,omitempty"`
	Type                 string              `json:"type,omitempty"`
	Properties           map[string]Property `json:"properties,omitempty"`
	AdditionalProperties bool                `json:"additional_properties,omitempty"`
	Definitions          map[string]Property `json:"definitions,omitempty"`
}

func Draft04

func Draft04() *Schema

func (*Schema) AddDefinition

func (s *Schema) AddDefinition(name string, prop Property) string

func (*Schema) Marshal

func (s *Schema) Marshal() ([]byte, error)

func (*Schema) MarshallPretty

func (s *Schema) MarshallPretty() ([]byte, error)

type Type

type Type string
const (
	TypeString  Type = "string"
	TypeBoolean Type = "boolean"
	TypeObject  Type = "object"
	TypeArray   Type = "array"
	TypeInteger Type = "integer"
	TypeNumber  Type = "number"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL