Documentation
¶
Index ¶
- Variables
- func GenCollectionSchema(jsonSchema []byte, lang string) ([]byte, error)
- type Collection
- type Field
- type FieldGen
- type FieldMultiType
- func NewArrayType() FieldMultiType
- func NewBooleanType() FieldMultiType
- func NewFloatType() FieldMultiType
- func NewIntegerType() FieldMultiType
- func NewMultiType(val string) FieldMultiType
- func NewNullableMultiType(val string) FieldMultiType
- func NewObjectType() FieldMultiType
- func NewStringType() FieldMultiType
- type JSONToGo
- type JSONToJava
- type JSONToLangType
- type JSONToTypeScript
- type Object
- type Schema
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidType = fmt.Errorf("invalid type. expected string or array of strings") ErrOnlyOneNonNullTypeAllowed = fmt.Errorf("only one non-null type allowed for the field") )
View Source
var ( ErrUnsupportedFormat = fmt.Errorf("unsupported format. supported formats are: JSON, TypeScripts, Go, Java") ErrEmptyObjectName = fmt.Errorf("object name should be non-zero length") )
View Source
var ErrUnsupportedType = fmt.Errorf("unsupported type")
Functions ¶
Types ¶
type Collection ¶
type Field ¶
type Field struct { Type FieldMultiType `json:"type,omitempty"` Format string `json:"format,omitempty"` Tags []string `json:"tags,omitempty"` Desc string `json:"description,omitempty"` Fields map[string]*Field `json:"properties,omitempty"` Items *Field `json:"items,omitempty"` Default any `json:"default,omitempty"` MaxLength int `json:"maxLength,omitempty"` CreatedAt bool `json:"createdAt,omitempty"` UpdatedAt bool `json:"updatedAt,omitempty"` AutoGenerate bool `json:"autoGenerate,omitempty"` Required []string `json:"required,omitempty"` SearchIndex bool `json:"searchIndex,omitempty"` Facet bool `json:"facet,omitempty"` Sort bool `json:"sort,omitempty"` // RequiredTag is used during schema building only RequiredTag bool `json:"-"` }
Field represents JSON schema object.
type FieldGen ¶
type FieldGen struct { Type string TypeDecap string Name string NameDecap string NameSnake string NameJSON string NamePlural string JSONCap string IsArray bool IsObject bool AutoGenerate bool PrimaryKeyIdx int ArrayDimensions int Default any DefaultStr string DefaultStrSingleQuotes string MaxLength int UpdatedAt bool CreatedAt bool Required bool SearchIndex bool Facet bool Sort bool Nullable bool ItemsNullable bool Description string }
type FieldMultiType ¶
type FieldMultiType struct { Type []string // contains filtered or unexported fields }
func NewArrayType ¶
func NewArrayType() FieldMultiType
func NewBooleanType ¶
func NewBooleanType() FieldMultiType
func NewFloatType ¶
func NewFloatType() FieldMultiType
func NewIntegerType ¶
func NewIntegerType() FieldMultiType
func NewMultiType ¶
func NewMultiType(val string) FieldMultiType
func NewNullableMultiType ¶
func NewNullableMultiType(val string) FieldMultiType
func NewObjectType ¶
func NewObjectType() FieldMultiType
func NewStringType ¶
func NewStringType() FieldMultiType
func (*FieldMultiType) First ¶
func (f *FieldMultiType) First() string
func (*FieldMultiType) MarshalJSON ¶
func (f *FieldMultiType) MarshalJSON() ([]byte, error)
func (*FieldMultiType) Set ¶
func (f *FieldMultiType) Set(tp string)
func (*FieldMultiType) SetNullable ¶
func (f *FieldMultiType) SetNullable()
func (*FieldMultiType) UnmarshalJSON ¶
func (f *FieldMultiType) UnmarshalJSON(b []byte) error
type JSONToJava ¶
type JSONToJava struct{}
func (*JSONToJava) GetObjectTemplate ¶
func (*JSONToJava) GetObjectTemplate() string
type JSONToLangType ¶
type JSONToTypeScript ¶
type JSONToTypeScript struct{}
func (*JSONToTypeScript) GetObjectTemplate ¶
func (*JSONToTypeScript) GetObjectTemplate() string
type Schema ¶
type Schema struct { Name string `json:"title,omitempty"` Desc string `json:"description,omitempty"` Fields map[string]*Field `json:"properties,omitempty"` PrimaryKey []string `json:"primary_key,omitempty"` Required []string `json:"required,omitempty"` CollectionType string `json:"collection_type,omitempty"` }
Schema is top level JSON schema object.
Click to show internal directories.
Click to hide internal directories.