data

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONEncoder

func JSONEncoder(writer io.Writer, v interface{}) error

func NewErrors

func NewErrors(inErrors ...error) error

func YAMLEncoder

func YAMLEncoder(writer io.Writer, v interface{}) error

Types

type Errors

type Errors []error

func (Errors) Err

func (e Errors) Err() error

func (Errors) Error

func (e Errors) Error() string

type Field

type Field struct {
	Type         string      `json:"type,omitempty"`
	Default      interface{} `json:"default,omitempty"`
	Nullable     bool        `json:"nullable,omitempty"`
	Create       bool        `json:"create"`
	WriteOnly    bool        `json:"writeOnly,omitempty"`
	Required     bool        `json:"required,omitempty"`
	Update       bool        `json:"update"`
	MinLength    *int64      `json:"minLength,omitempty"`
	MaxLength    *int64      `json:"maxLength,omitempty"`
	Min          *int64      `json:"min,omitempty"`
	Max          *int64      `json:"max,omitempty"`
	Options      []string    `json:"options,omitempty"`
	ValidChars   string      `json:"validChars,omitempty"`
	InvalidChars string      `json:"invalidChars,omitempty"`
	Description  string      `json:"description,omitempty"`
	CodeName     string      `json:"-"`
	DynamicField bool        `json:"dynamicField,omitempty"`
}

type Mapper

type Mapper interface {
	FromInternal(data map[string]interface{})
	ToInternal(data map[string]interface{}) error
	ModifySchema(schema *Schema, schemas *Schemas) error
}

type Mappers

type Mappers []Mapper

func (Mappers) FromInternal

func (m Mappers) FromInternal(data map[string]interface{})

func (Mappers) ModifySchema

func (m Mappers) ModifySchema(schema *Schema, schemas *Schemas) error

func (Mappers) ToInternal

func (m Mappers) ToInternal(data map[string]interface{}) error

type MappersFactory

type MappersFactory func() []Mapper

type Schema

type Schema struct {
	ID             string            `json:"id,omitempty"`
	CodeName       string            `json:"-"`
	CodeNamePlural string            `json:"-"`
	PkgName        string            `json:"-"`
	Type           string            `json:"type,omitempty"`
	Links          map[string]string `json:"links"`
	PluralName     string            `json:"pluralName,omitempty"`
	ResourceFields map[string]Field  `json:"resourceFields"`
	NonNamespaced  bool              `json:"-"`
	Object         bool              `json:"-"`

	InternalSchema *Schema `json:"-"`
	Mapper         Mapper  `json:"-"`
}

type SchemaCollection

type SchemaCollection struct {
	Data []Schema
}

type Schemas

type Schemas struct {
	sync.Mutex

	DefaultMappers     MappersFactory
	DefaultPostMappers MappersFactory
	// contains filtered or unexported fields
}

func NewSchemas

func NewSchemas() *Schemas

func (*Schemas) AddMapper

func (s *Schemas) AddMapper(schemaID string, mapper Mapper) *Schemas

func (*Schemas) AddMapperForType

func (s *Schemas) AddMapperForType(obj interface{}, mapper ...Mapper) *Schemas

func (*Schemas) AddSchema

func (s *Schemas) AddSchema(schema Schema) *Schemas

func (*Schemas) AddSchemas

func (s *Schemas) AddSchemas(schema *Schemas) *Schemas

func (*Schemas) Err

func (s *Schemas) Err() error

func (*Schemas) Import

func (s *Schemas) Import(obj interface{}, overrides ...interface{}) (*Schema, error)

func (*Schemas) Init

func (s *Schemas) Init(initFunc SchemasInitFunc) *Schemas

func (*Schemas) MustImport

func (s *Schemas) MustImport(obj interface{}, overrides ...interface{}) *Schemas

func (*Schemas) RemoveSchema

func (s *Schemas) RemoveSchema(schema Schema) *Schemas

func (*Schemas) Schema

func (s *Schemas) Schema(name string) *Schema

func (*Schemas) Schemas

func (s *Schemas) Schemas() map[string]*Schema

func (*Schemas) TypeName

func (s *Schemas) TypeName(name string, obj interface{}) *Schemas

type SchemasInitFunc

type SchemasInitFunc func(*Schemas) *Schemas

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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