generator

package module
v0.0.1-alpha7 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultTypeOption

func GetDefaultTypeOption() map[mapping.EsType]TypeOption

Types

type DefaultOption

type DefaultOption struct {
	IsOptional                option.Option[bool]
	IsSingle                  option.Option[bool]
	PreferStringBoolean       option.Option[bool]
	PreferMarshalDateToNumber option.Option[bool]
	PerTypDefault             map[mapping.EsType]TypeOption
}

type GenerateTypeName

type GenerateTypeName func(fieldNames []string, typeName mapping.EsType) string
var (
	ChainFieldName GenerateTypeName = func(fieldNames []string, typeName mapping.EsType) string {
		names := make([]string, len(fieldNames)+1)
		for idx, v := range fieldNames {
			names[idx] = pascalCase(exportName(escapeNonId(v)))
		}
		names[len(names)-1] = pascalCase(string(typeName))
		return strings.Join(names, "")
	}
)

type GeneratorOption

type GeneratorOption struct {
	RootTypeName     string
	Mapping          mapping.TypeMapping
	GenerateTypeName GenerateTypeName
	DefaultOption    DefaultOption
	MappingOption    MappingOption
}

func (GeneratorOption) Gen

func (g GeneratorOption) Gen(f *jen.File)

type MappingOption

type MappingOption map[string]PropertyOption

type PropertyOption

type PropertyOption struct {
	TypeName                  string
	IsOptional                option.Option[bool]
	IsSingle                  option.Option[bool]
	PreferStringBoolean       option.Option[bool]
	PreferMarshalDateToNumber option.Option[bool]
	Children                  MappingOption
}

func (PropertyOption) GetTypeName

func (o PropertyOption) GetTypeName(
	generateTypeName func() string,
) string

type TypeOption

type TypeOption struct {
	IsOptional option.Option[bool]
	IsSingle   option.Option[bool]
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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