entity_generator

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONBase

func JSONBase() []byte

func JSONSub

func JSONSub() []byte

func JSONSub2

func JSONSub2() []byte

func JSONSub3 added in v1.0.10

func JSONSub3() []byte

func JSONUnnamedNestedObject added in v1.0.11

func JSONUnnamedNestedObject() []byte

func JSONsetId added in v1.0.10

func JSONsetId(jsp JSONDict, p Property)

func JSONsetOptionalBoolean added in v1.0.10

func JSONsetOptionalBoolean(js JSONDict, key string, value rusty.Optional[bool])

func JSONsetOptionalFloat64 added in v1.0.10

func JSONsetOptionalFloat64(js JSONDict, key string, value rusty.Optional[float64])

func JSONsetOptionalInt added in v1.0.10

func JSONsetOptionalInt(js JSONDict, key string, value rusty.Optional[int])

func JSONsetOptionalString added in v1.0.10

func JSONsetOptionalString(js JSONDict, key string, value rusty.Optional[string])

func JSONsetString added in v1.0.10

func JSONsetString(js JSONDict, key string, value string)

func JSONsetXProperties added in v1.0.34

func JSONsetXProperties(js JSONDict, value map[string]interface{})

func NewPropertyArray

func NewPropertyArray(p PropertyArrayBuilder) rusty.Result[Property]

func NewPropertyArrayItem added in v1.0.14

func NewPropertyArrayItem(name string, property rusty.Result[Property], optionals ...bool) rusty.Result[PropertyItem]

func NewPropertyObjectItem added in v1.0.14

func NewPropertyObjectItem(name string, property rusty.Result[Property], idx int, optionals ...bool) rusty.Result[PropertyItem]

func TestFlatSchema

func TestFlatSchema(sl PropertyCtx) rusty.Result[Property]

func TestPayloadSchema added in v1.0.13

func TestPayloadSchema(sl PropertyCtx) rusty.Result[Property]

func WriteTestSchema

func WriteTestSchema(cfg *GeneratorConfig) string

Types

type BufLineWriter

type BufLineWriter struct {
	Lines []string
}

func (*BufLineWriter) Write

func (w *BufLineWriter) Write(p []byte) (n int,
	err error)

type Config

type Config struct {
	Language    string
	Indent      string
	PackageName string
	FromWueste  string
}

func FromArgs

func FromArgs(prefix string, cfg *Config) *Config

type ForIfWhileLangWriter

type ForIfWhileLangWriter struct {
	OfsIndent string
	// contains filtered or unexported fields
}

func (*ForIfWhileLangWriter) FormatLine

func (w *ForIfWhileLangWriter) FormatLine(format string, args ...interface{}) string

func (*ForIfWhileLangWriter) Indent

func (*ForIfWhileLangWriter) Lines

func (w *ForIfWhileLangWriter) Lines() []string

func (*ForIfWhileLangWriter) WriteBlock

func (w *ForIfWhileLangWriter) WriteBlock(keyword, expression string, fn func(wr *ForIfWhileLangWriter), opts ...string) string

func (*ForIfWhileLangWriter) WriteIf

func (w *ForIfWhileLangWriter) WriteIf(expression string, fnTrue func(wr *ForIfWhileLangWriter), fnFalses ...func(wr *ForIfWhileLangWriter))

func (*ForIfWhileLangWriter) WriteLine

func (w *ForIfWhileLangWriter) WriteLine(lines ...string)

type GeneratorConfig

type GeneratorConfig struct {
	IncludeDirs     []string
	OutputDir       string
	InputFiles      []string
	EntityCfg       Config
	WriteTestSchema bool
	Version         bool
}

type JSONDict added in v1.0.16

type JSONDict interface {
	// orderedmap.OrderedMap
	Set(key string, value any)
	Get(key string) any
	Keys() []string
	Len() int
	Lookup(key string) (any, bool)
	UnmarshalJSON([]byte) error
	MarshalJSON() ([]byte, error)
}

type JSONDict map[string]interface{}

func NewJSONDict added in v1.0.16

func NewJSONDict() JSONDict

func PropertyArrayToJson added in v1.0.10

func PropertyArrayToJson(b PropertyArray) JSONDict

func PropertyBooleanToJson added in v1.0.10

func PropertyBooleanToJson(b PropertyBoolean) JSONDict

func PropertyIntegerToJson added in v1.0.10

func PropertyIntegerToJson(b PropertyInteger) JSONDict

func PropertyNumberToJson added in v1.0.10

func PropertyNumberToJson(b PropertyNumber) JSONDict

func PropertyObjectToJson added in v1.0.10

func PropertyObjectToJson(b PropertyObject) JSONDict

func PropertyStringToJson added in v1.0.10

func PropertyStringToJson(b PropertyString) JSONDict

func PropertyToJson added in v1.0.10

func PropertyToJson(iprop Property) JSONDict

type JSonFile added in v1.0.14

type JSonFile struct {
	FileName     string   `json:"filename"`
	JSONProperty JSONDict `json:"jsonProperty"`
}

func BaseSchema

func BaseSchema() JSonFile

func Sub2Schema

func Sub2Schema() JSonFile

func Sub3Schema added in v1.0.10

func Sub3Schema() JSonFile

func TestJSONPayloadSchema added in v1.0.13

func TestJSONPayloadSchema() JSonFile

func TestJSONSchema added in v1.0.14

func TestJSONSchema() JSonFile

func TestJsonFlatSchema

func TestJsonFlatSchema() JSonFile

func TestJsonSubSchema added in v1.0.10

func TestJsonSubSchema() JSonFile

func UnnamedNestedObject added in v1.0.11

func UnnamedNestedObject() JSonFile

type PropertiesBuilder

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

func NewPropertiesBuilder

func NewPropertiesBuilder(run PropertyCtx) *PropertiesBuilder

func (*PropertiesBuilder) Build

func (b *PropertiesBuilder) Build() rusty.Result[Property]

func (*PropertiesBuilder) FileName added in v1.0.10

func (b *PropertiesBuilder) FileName() rusty.Optional[string]

func (*PropertiesBuilder) FromJson

func (b *PropertiesBuilder) FromJson(js JSONDict) *PropertiesBuilder

func (*PropertiesBuilder) MergeJson added in v1.0.14

func (b *PropertiesBuilder) MergeJson(parentFname rusty.Optional[string], ref string, js JSONDict) rusty.Result[JSonFile]

type Property

type Property interface {
	Id() string
	Type() Type
	Description() rusty.Optional[string]
	Ref() rusty.Optional[string]
	XProperties() map[string]interface{}
	Meta() PropertyMeta
}

func NewProperty

func NewProperty(p PropertyBuilder) Property

func TestSchema

func TestSchema(sl PropertyCtx) Property

type PropertyArray

type PropertyArray interface {
	Id() string
	Type() Type
	Description() rusty.Optional[string]
	XProperties() map[string]interface{}
	// Format() rusty.Optional[string]
	// Optional() bool
	// SetOptional()
	MinItems() rusty.Optional[int]
	MaxItems() rusty.Optional[int]
	Items() Property
	// UniqueItems() bool
	// Containts() Property
	// AdditionalItems() rusty.Optional[Property]
	Ref() rusty.Optional[string]

	// ToPropertyObject() rusty.Result[PropertyObject]
	Meta() PropertyMeta
}

type PropertyArrayBuilder added in v1.0.14

type PropertyArrayBuilder struct {
	// __loader SchemaLoader
	Id          string
	Type        Type
	Ref         rusty.Optional[string]
	Description rusty.Optional[string]
	XProperties map[string]interface{}
	// Format      rusty.Optional[string]
	// Optional    bool
	MinItems rusty.Optional[int]
	MaxItems rusty.Optional[int]
	Items    rusty.Result[Property]
	// contains filtered or unexported fields
}

func NewPropertyArrayBuilder added in v1.0.14

func NewPropertyArrayBuilder(pb *PropertiesBuilder) *PropertyArrayBuilder

func (*PropertyArrayBuilder) Build added in v1.0.14

func (*PropertyArrayBuilder) FromJson added in v1.0.14

type PropertyBoolean

type PropertyBoolean interface {
	Id() string
	Type() Type
	Description() rusty.Optional[string]
	Default() rusty.Optional[bool] // match Type
	XProperties() map[string]interface{}
	Ref() rusty.Optional[string]
	Meta() PropertyMeta
}

type PropertyBooleanBuilder added in v1.0.14

type PropertyBooleanBuilder struct {
	Id          string
	Type        Type
	XProperties map[string]interface{}
	Description rusty.Optional[string]
	Default     rusty.Optional[bool]
	Ref         rusty.Optional[string]
}

func NewPropertyBooleanBuilder added in v1.0.14

func NewPropertyBooleanBuilder(pb *PropertiesBuilder) *PropertyBooleanBuilder

func (*PropertyBooleanBuilder) Build added in v1.0.14

func (*PropertyBooleanBuilder) FromJson added in v1.0.14

type PropertyBuilder added in v1.0.14

type PropertyBuilder struct {
	Id          string
	Type        Type
	Description rusty.Optional[string]
	XProperties map[string]interface{}
	Ref         rusty.Optional[string]
}

type PropertyCtx added in v1.0.10

type PropertyCtx struct {
	Registry *SchemaRegistry
}

func NewTestContext added in v1.0.10

func NewTestContext() PropertyCtx

type PropertyFormat added in v1.0.34

type PropertyFormat interface {
	Format() rusty.Optional[string]
}

type PropertyInteger

type PropertyInteger interface {
	Id() string
	Type() Type
	Description() rusty.Optional[string]
	Format() rusty.Optional[string]
	XProperties() map[string]interface{}
	// Optional() bool
	// SetOptional()
	Default() rusty.Optional[int] // match Type
	// Enum() []T
	Maximum() rusty.Optional[int]
	Minimum() rusty.Optional[int]

	Ref() rusty.Optional[string]
	Meta() PropertyMeta
}

type PropertyIntegerBuilder added in v1.0.14

type PropertyIntegerBuilder struct {
	// __loader    SchemaLoader
	Id          string
	Type        Type
	Ref         rusty.Optional[string]
	Description rusty.Optional[string]
	Format      rusty.Optional[string]
	Default     rusty.Optional[int]
	XProperties map[string]interface{}
	// Enum        []T
	// Default rusty.Optional[T]
	Maximum rusty.Optional[int]
	Minimum rusty.Optional[int]
}

func NewPropertyIntegerBuilder added in v1.0.14

func NewPropertyIntegerBuilder(pb *PropertiesBuilder) *PropertyIntegerBuilder

func (*PropertyIntegerBuilder) Build added in v1.0.14

func (*PropertyIntegerBuilder) FromJson added in v1.0.14

type PropertyItem

type PropertyItem interface {
	Property() Property
	Optional() bool
	Idx() int
	Name() string

	Id() string
	Type() Type
	Description() rusty.Optional[string]
	XProperties() map[string]interface{}
	Ref() rusty.Optional[string]
	Meta() PropertyMeta
}

type PropertyMeta added in v1.0.14

type PropertyMeta interface {
	Parent() rusty.Optional[Property]
	SetParent(p Property) PropertyMeta
	FileName() rusty.Optional[string]
	SetFileName(fn string) PropertyMeta
	SetMeta(m Property) PropertyMeta
}

func NewPropertyMeta added in v1.0.14

func NewPropertyMeta() PropertyMeta

type PropertyNumber

type PropertyNumber interface {
	Id() string
	Type() Type
	Ref() rusty.Optional[string]
	Description() rusty.Optional[string]
	Format() rusty.Optional[string]
	XProperties() map[string]interface{}
	Default() rusty.Optional[float64] // match Type
	// Enum() []float64
	Maximum() rusty.Optional[float64]
	Minimum() rusty.Optional[float64]

	Meta() PropertyMeta
}

type PropertyNumberBuilder added in v1.0.14

type PropertyNumberBuilder struct {
	// __loader    SchemaLoader
	Id          string
	Ref         rusty.Optional[string]
	Type        Type
	Description rusty.Optional[string]
	Format      rusty.Optional[string]
	Default     rusty.Optional[float64]
	XProperties map[string]interface{}
	// Enum        []float64
	Maximum rusty.Optional[float64]
	Minimum rusty.Optional[float64]
}

func NewPropertyNumberBuilder added in v1.0.14

func NewPropertyNumberBuilder(pb *PropertiesBuilder) *PropertyNumberBuilder

func (*PropertyNumberBuilder) Build added in v1.0.14

func (*PropertyNumberBuilder) FromJson added in v1.0.14

type PropertyObject

type PropertyObject interface {
	Type() Type
	Id() string
	Title() string
	Schema() string
	Description() rusty.Optional[string]
	XProperties() map[string]interface{}

	Properties() *properties
	Items() []PropertyItem
	PropertyByName(name string) rusty.Result[PropertyItem]
	Required() []string

	Ref() rusty.Optional[string]
	Meta() PropertyMeta
}

type PropertyObjectBuilder added in v1.0.14

type PropertyObjectBuilder struct {
	// items       []PropertyItem
	Type        Type
	Description rusty.Optional[string]

	Id          string
	Title       string
	Schema      string
	Properties  *properties // PropertiesObject
	Required    []string
	Ref         rusty.Optional[string]
	XProperties map[string]interface{}

	// Runtime PropertyRuntime
	// Ctx     PropertyCtx
	Errors []error
	// contains filtered or unexported fields
}

func NewPropertyObjectBuilder added in v1.0.14

func NewPropertyObjectBuilder(pb *PropertiesBuilder) *PropertyObjectBuilder

func (*PropertyObjectBuilder) Build added in v1.0.14

func (*PropertyObjectBuilder) FromJson added in v1.0.14

type PropertyString

type PropertyString interface {
	// Property
	Id() string
	Type() string
	Description() rusty.Optional[string]
	Default() rusty.Optional[string] // match Type
	Format() rusty.Optional[StringFormat]
	Ref() rusty.Optional[string]
	XProperties() map[string]interface{}
	Meta() PropertyMeta
}

type PropertyStringBuilder added in v1.0.14

type PropertyStringBuilder struct {
	// PropertyParam
	Id          string
	Type        Type
	Description rusty.Optional[string]
	Default     rusty.Optional[string]
	Ref         rusty.Optional[string]
	XProperties map[string]interface{}

	Format rusty.Optional[StringFormat]
}

func NewPropertyStringBuilder added in v1.0.14

func NewPropertyStringBuilder(pb *PropertiesBuilder) *PropertyStringBuilder

func (*PropertyStringBuilder) Build added in v1.0.14

func (*PropertyStringBuilder) FromJson added in v1.0.14

type SchemaLoader

type SchemaLoader interface {
	ReadFile(path string) ([]byte, error)
	Abs(path string) (string, error)
	Unmarshal(bytes []byte, v interface{}) error
	IncludeDirs() []string
	Clone(prependIncDirs ...string) SchemaLoader
}

type SchemaLoaderImpl added in v1.0.31

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

func NewSchemaLoaderImpl added in v1.0.31

func NewSchemaLoaderImpl(includeDirs ...string) SchemaLoaderImpl

func (SchemaLoaderImpl) Abs added in v1.0.31

func (sl SchemaLoaderImpl) Abs(fname string) (string, error)

Abs implements SchemaLoader.

func (SchemaLoaderImpl) Clone added in v1.0.32

func (sl SchemaLoaderImpl) Clone(prependIncDirs ...string) SchemaLoader

func (SchemaLoaderImpl) IncludeDirs added in v1.0.32

func (sl SchemaLoaderImpl) IncludeDirs() []string

func (SchemaLoaderImpl) ReadFile added in v1.0.31

func (sl SchemaLoaderImpl) ReadFile(fname string) ([]byte, error)

ReadFile implements SchemaLoader.

func (SchemaLoaderImpl) Unmarshal added in v1.0.31

func (SchemaLoaderImpl) Unmarshal(bytes []byte, v interface{}) error

Unmarshal implements SchemaLoader.

type SchemaRegistry

type SchemaRegistry struct {
	BaseDir rusty.Optional[string]
	// contains filtered or unexported fields
}

func NewSchemaRegistry

func NewSchemaRegistry(loaders ...SchemaLoader) *SchemaRegistry

func (*SchemaRegistry) EnsureJSONProperty added in v1.0.14

func (sr *SchemaRegistry) EnsureJSONProperty(parentFname rusty.Optional[string], inRef string) rusty.Result[JSonFile]

func (*SchemaRegistry) Items

func (sr *SchemaRegistry) Items() []SchemaRegistryItem

type SchemaRegistryItem

type SchemaRegistryItem interface {
	Written() bool
	JSonFile() JSonFile
}

type StringFormat

type StringFormat = string
const (
	DATE_TIME StringFormat = "date-time"
	TIME      StringFormat = "time"
	DATE      StringFormat = "date"
)

type TestSchemaLoader

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

func NewTestSchemaLoader

func NewTestSchemaLoader() *TestSchemaLoader

func (*TestSchemaLoader) Abs

func (l *TestSchemaLoader) Abs(path string) (string, error)

func (TestSchemaLoader) Clone added in v1.0.32

func (sl TestSchemaLoader) Clone(prependIncDirs ...string) SchemaLoader

func (*TestSchemaLoader) IncludeDirs added in v1.0.32

func (t *TestSchemaLoader) IncludeDirs() []string

func (*TestSchemaLoader) ReadFile

func (l *TestSchemaLoader) ReadFile(path string) ([]byte, error)

ReadFile implements SchemaLoader.

func (*TestSchemaLoader) Unmarshal

func (l *TestSchemaLoader) Unmarshal(bytes []byte, v interface{}) error

Unmarshal implements SchemaLoader.

type Type

type Type = string
const (
	OBJECT     Type = "object"
	OBJECTITEM Type = "objectitem"
	STRING     Type = "string"
	NUMBER     Type = "number"
	INTEGER    Type = "integer"
	BOOLEAN    Type = "boolean"
	ARRAY      Type = "array"
	ARRAYITEM  Type = "arrayitem"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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