schemaHelper

package
v0.0.0-...-add256a Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Components

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

func NewComponents

func NewComponents() (c *Components)

func (*Components) Add

func (c *Components) Add(refId uint, ref string, schema *SchemaRef)

func (*Components) Component

func (c *Components) Component(schema *SchemaRef) (*SchemaRef, uint, string)

func (*Components) GetComponents

func (c *Components) GetComponents() map[uint]*component

func (*Components) GetSliceComponents

func (c *Components) GetSliceComponents() map[string]*component

func (*Components) SetHandler

func (c *Components) SetHandler(handler func(refId uint) string)

type Schema

type Schema struct {
	openapi3.ExtensionProps
	Type        string     `json:"type,omitempty" yaml:"type,omitempty"`
	XMockType   string     `json:"x-mock-type,omitempty" yaml:"x-mock-type,omitempty"`
	Items       *SchemaRef `json:"items,omitempty" yaml:"items,omitempty"`
	Properties  Schemas    `json:"properties,omitempty" yaml:"properties,omitempty"`
	AllOf       SchemaRefs `json:"allOf,omitempty" yaml:"allOf,omitempty"`
	OneOf       SchemaRefs `json:"oneOf,omitempty" yaml:"allOf,omitempty"`
	AnyOf       SchemaRefs `json:"anyOf,omitempty" yaml:"allOf,omitempty"`
	Ref         string     `json:"ref,omitempty" yaml:"ref,omitempty"`
	RefExt      string     `json:"$ref,omitempty" yaml:"ref,omitempty"`
	RefId       uint       `json:"refId,omitempty" yaml:"$refId,omitempty"`
	Description string     `json:"description,omitempty" yaml:"description,omitempty"`
	Format      string     `json:"format,omitempty" yaml:"format,omitempty"`

	Enum    []interface{} `json:"enum,omitempty" yaml:"enum,omitempty"`
	Default interface{}   `json:"default,omitempty" yaml:"default,omitempty"`
	Example interface{}   `json:"example,omitempty" yaml:"example,omitempty"`

	// Array-related, here for struct compactness
	UniqueItems bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"`
	// Number-related, here for struct compactness
	ExclusiveMin bool `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"`
	ExclusiveMax bool `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"`
	// Properties
	Nullable        bool `json:"nullable,omitempty" yaml:"nullable,omitempty"`
	ReadOnly        bool `json:"readOnly,omitempty" yaml:"readOnly,omitempty"`
	WriteOnly       bool `json:"writeOnly,omitempty" yaml:"writeOnly,omitempty"`
	AllowEmptyValue bool `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"`
	Deprecated      bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`

	// Number
	Min        *float64 `json:"minimum,omitempty" yaml:"minimum,omitempty"`
	Max        *float64 `json:"maximum,omitempty" yaml:"maximum,omitempty"`
	MultipleOf *float64 `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"`

	// String
	MinLength uint64  `json:"minLength,omitempty" yaml:"minLength,omitempty"`
	MaxLength *uint64 `json:"maxLength,omitempty" yaml:"maxLength,omitempty"`
	Pattern   string  `json:"pattern,omitempty" yaml:"pattern,omitempty"`

	// Array
	MinItems uint64  `json:"minItems,omitempty" yaml:"minItems,omitempty"`
	MaxItems *uint64 `json:"maxItems,omitempty" yaml:"maxItems,omitempty"`

	// Object
	Required []string `json:"required,omitempty" yaml:"required,omitempty"`
	MinProps uint64   `json:"minProperties,omitempty" yaml:"minProperties,omitempty"`
	MaxProps *uint64  `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"`
}

type Schema2conv

type Schema2conv struct {
	Components *Components
	// contains filtered or unexported fields
}

func NewSchema2conv

func NewSchema2conv() *Schema2conv

func (*Schema2conv) AssertDataForSchema

func (s *Schema2conv) AssertDataForSchema(schema *SchemaRef, data interface{}) bool

func (*Schema2conv) CombineSchemas

func (s *Schema2conv) CombineSchemas(schema *SchemaRef)

func (*Schema2conv) Equal

func (s *Schema2conv) Equal(schema1, schema2 *SchemaRef) (ret bool)

func (*Schema2conv) Example2Schema

func (s *Schema2conv) Example2Schema(object interface{}, schema *Schema) (err error)

func (*Schema2conv) FillRefId

func (s *Schema2conv) FillRefId(schema *SchemaRef)

func (*Schema2conv) GetRefComponents

func (s *Schema2conv) GetRefComponents(components *[]openapi3.Schemas, schema *Schema) (err error)

func (*Schema2conv) GetRefIds

func (s *Schema2conv) GetRefIds(schema *SchemaRef) (ret []interface{})

func (*Schema2conv) GetRefs

func (s *Schema2conv) GetRefs(schema *SchemaRef) (ret []interface{})

func (*Schema2conv) Schema2Example

func (s *Schema2conv) Schema2Example(schema SchemaRef) (object interface{})

func (*Schema2conv) SchemaComponents

func (s *Schema2conv) SchemaComponents(schema *SchemaRef, components *Components)

type SchemaRef

type SchemaRef struct {
	Ref    string  `json:"ref,omitempty" yaml:"ref,omitempty"`
	RefExt string  `json:"$ref,omitempty" yaml:"$ref,omitempty"`
	RefId  uint    `json:"refId,omitempty" yaml:"$refId,omitempty"`
	Value  *Schema `json:"value,omitempty" yaml:"value,omitempty"`
}

func (*SchemaRef) MarshalJSON

func (schemaRef *SchemaRef) MarshalJSON() (res []byte, err error)

func (*SchemaRef) UnmarshalJSON

func (schemaRef *SchemaRef) UnmarshalJSON(data []byte) error

type SchemaRefs

type SchemaRefs []*SchemaRef

type Schemas

type Schemas map[string]*SchemaRef

Jump to

Keyboard shortcuts

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