generator

package
v0.0.0-...-c0f3d90 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResposePostfix = "Resp"
)

Variables

View Source
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

func NewParameterInPath

func NewParameterInPath(in ParameterLocation, name string, required bool, typ string) *openapi3.ParameterRef

func NewParameterInQuery

func NewParameterInQuery(in ParameterLocation, name string, required bool, typ string) *openapi3.ParameterRef

func NewParameterRef

func NewParameterRef(refName string) *openapi3.ParameterRef

func NewParameterWithSchema

func NewParameterWithSchema(in ParameterLocation, name string, required bool, schema *openapi3.SchemaRef) *openapi3.ParameterRef

func NewRequestBodyRef

func NewRequestBodyRef(refName string) *openapi3.RequestBodyRef

func NewRequestBodyWithContent

func NewRequestBodyWithContent(content openapi3.Content, required bool) *openapi3.RequestBodyRef

func NewSchema

func NewSchema(typ string) *openapi3.SchemaRef

func NewSchemaBoolean

func NewSchemaBoolean() *openapi3.SchemaRef

func NewSchemaDate

func NewSchemaDate() *openapi3.SchemaRef

func NewSchemaDateTime

func NewSchemaDateTime() *openapi3.SchemaRef

func NewSchemaEmail

func NewSchemaEmail() *openapi3.SchemaRef

func NewSchemaInteger

func NewSchemaInteger() *openapi3.SchemaRef

func NewSchemaNumber

func NewSchemaNumber() *openapi3.SchemaRef

func NewSchemaRef

func NewSchemaRef(refName string) *openapi3.SchemaRef

func NewSchemaString

func NewSchemaString() *openapi3.SchemaRef

func NewSchemaURI

func NewSchemaURI() *openapi3.SchemaRef

func NewSchemaUUID

func NewSchemaUUID() *openapi3.SchemaRef

func NewSchemaWithFormat

func NewSchemaWithFormat(typ string, format string) *openapi3.SchemaRef

Types

type AdditionalProperties

type AdditionalProperties Schema

type Definitions

type Definitions map[string]*Type

type Format

type Format int
const (
	JSON Format = iota
	YAML
)

type Generator

type Generator struct {
	SkipUnderscore bool
	Swagger        *openapi3.Swagger
	Schema         *Schema
}

func New

func New() *Generator

func (*Generator) Do

func (g *Generator) Do(schema io.Reader, output io.Writer, format Format) error

func (*Generator) String

func (g *Generator) String() string

type ParameterLocation

type ParameterLocation string
const (
	InQuery ParameterLocation = "query"
	InPath  ParameterLocation = "path"
)

type Schema

type Schema struct {
	Type
}

Schema is the root schema. RFC draft-wright-json-schema-00, section 4.5.

type Type

type Type struct {
	// RFC draft-wright-json-schema-00
	Version string `json:"$schema,omitempty"` // section 6.1
	Ref     string `json:"$ref,omitempty"`    // section 7
	// RFC draft-wright-json-schema-validation-00, section 5
	MultipleOf           *float64         `json:"multipleOf,omitempty"`           // section 5.1
	Maximum              *float64         `json:"maximum,omitempty"`              // section 5.2
	ExclusiveMaximum     bool             `json:"exclusiveMaximum,omitempty"`     // section 5.3
	Minimum              *float64         `json:"minimum,omitempty"`              // section 5.4
	ExclusiveMinimum     bool             `json:"exclusiveMinimum,omitempty"`     // section 5.5
	MaxLength            *uint64          `json:"maxLength,omitempty"`            // section 5.6
	MinLength            uint64           `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             *uint64          `json:"maxItems,omitempty"`             // section 5.10
	MinItems             uint64           `json:"minItems,omitempty"`             // section 5.11
	UniqueItems          bool             `json:"uniqueItems,omitempty"`          // section 5.12
	MaxProperties        *uint64          `json:"maxProperties,omitempty"`        // section 5.13
	MinProperties        uint64           `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
	Const                interface{}      `json:"const,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
	Examples    []interface{} `json:"examples,omitempty"`    // section 7.4
	// 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

	Extras map[string]interface{} `json:"-"`

	// path element - for creating a path by traversing back to the root element
	PathElement string `json:"-"`

	// calculated struct name of this object, cached here
	GeneratedType string `json:"-"`
}

Type represents a JSON Schema object type.

type TypeMapper

type TypeMapper struct {
	// contains filtered or unexported fields
}

func NewTypeMapper

func NewTypeMapper(prefix string) *TypeMapper

func (*TypeMapper) Add

func (t *TypeMapper) Add(from string, schema *Type) *TypeMapper

func (*TypeMapper) Convert

func (t *TypeMapper) Convert(schema *Type)

func (*TypeMapper) Exists

func (t *TypeMapper) Exists(name string) bool

Jump to

Keyboard shortcuts

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