schemas

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 12 Imported by: 28

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Input  string `json:"input,omitempty"`
	Output string `json:"output,omitempty"`
}

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:"-"`
}

type FieldMapperFactory

type FieldMapperFactory func(fieldName string, args ...string) Mapper

type Mapper

type Mapper interface {
	FromInternal(data data.Object)
	ToInternal(data data.Object) error
	ModifySchema(schema *Schema, schemas *Schemas) error
}

type MapperFactory

type MapperFactory func() Mapper

type Mappers

type Mappers []Mapper

func (Mappers) FromInternal

func (m Mappers) FromInternal(data data.Object)

func (Mappers) ModifySchema

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

func (Mappers) ToInternal

func (m Mappers) ToInternal(data data.Object) error

type Schema

type Schema struct {
	ID                string                 `json:"-"`
	Description       string                 `json:"description,omitempty"`
	CodeName          string                 `json:"-"`
	CodeNamePlural    string                 `json:"-"`
	PkgName           string                 `json:"-"`
	PluralName        string                 `json:"pluralName,omitempty"`
	ResourceMethods   []string               `json:"resourceMethods,omitempty"`
	ResourceFields    map[string]Field       `json:"resourceFields"`
	ResourceActions   map[string]Action      `json:"resourceActions,omitempty"`
	CollectionMethods []string               `json:"collectionMethods,omitempty"`
	CollectionFields  map[string]Field       `json:"collectionFields,omitempty"`
	CollectionActions map[string]Action      `json:"collectionActions,omitempty"`
	Attributes        map[string]interface{} `json:"attributes,omitempty"`

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

func (*Schema) DeepCopy

func (s *Schema) DeepCopy() *Schema

func (*Schema) MustCustomizeField

func (s *Schema) MustCustomizeField(name string, f func(f Field) Field) *Schema

type Schemas

type Schemas struct {
	sync.Mutex

	DefaultMapper     MapperFactory
	DefaultPostMapper MapperFactory
	// contains filtered or unexported fields
}

func EmptySchemas

func EmptySchemas() *Schemas

func NewSchemas

func NewSchemas(schemas ...*Schemas) (*Schemas, error)

func (*Schemas) AddFieldMapper

func (s *Schemas) AddFieldMapper(name string, factory FieldMapperFactory) *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) error

func (*Schemas) AddSchemas

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

func (*Schemas) Import

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

func (*Schemas) Init

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

func (*Schemas) MustAddSchema

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

func (*Schemas) MustAddSchemas

func (s *Schemas) MustAddSchemas(schema *Schemas) *Schemas

func (*Schemas) MustCustomizeType

func (s *Schemas) MustCustomizeType(obj interface{}, f func(*Schema)) *Schemas

func (*Schemas) MustImport

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

func (*Schemas) MustImportAndCustomize

func (s *Schemas) MustImportAndCustomize(obj interface{}, f func(*Schema), externalOverrides ...interface{}) *Schemas

func (*Schemas) RemoveSchema

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

func (*Schemas) Schema

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

func (*Schemas) SchemaFor

func (s *Schemas) SchemaFor(t reflect.Type) *Schema

func (*Schemas) Schemas

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

func (*Schemas) SchemasByID

func (s *Schemas) SchemasByID() 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