generators

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnumConstantsAsMap added in v1.0.5

func GetEnumConstantsAsMap(t reflect.Type) map[string]interface{}

GetEnumConstantsAsMap extracts enum constants associated with the given type and returns a map of "constant name" -> "constant value"

func GetIoTsEnumText added in v1.0.5

func GetIoTsEnumText(t reflect.Type) string

func IsEnumType added in v1.0.5

func IsEnumType(t reflect.Type) bool

IsEnumType checks if the given reflect.Type has any matching constants in its package.

Types

type CodeBuilder added in v1.0.3

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

CodeBuilder handles the assembly of generated code

func NewCodeBuilder added in v1.0.3

func NewCodeBuilder() *CodeBuilder

NewCodeBuilder creates a new CodeBuilder instance

func (*CodeBuilder) AddTypeDefinition added in v1.0.3

func (cb *CodeBuilder) AddTypeDefinition(typeDef string)

AddTypeDefinition adds a type definition to the builder

func (*CodeBuilder) Build added in v1.0.3

func (cb *CodeBuilder) Build() string

Build assembles the final code output

func (*CodeBuilder) IsTypeProcessed added in v1.0.3

func (cb *CodeBuilder) IsTypeProcessed(typeKey string) bool

IsTypeProcessed checks if a type has already been processed

func (*CodeBuilder) MarkTypeProcessed added in v1.0.3

func (cb *CodeBuilder) MarkTypeProcessed(typeKey string)

MarkTypeProcessed marks a type as processed

type DefaultTypeConverter added in v1.0.3

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

DefaultTypeConverter is the default implementation of TypeConverter

func (*DefaultTypeConverter) Convert added in v1.0.3

func (tc *DefaultTypeConverter) Convert(goType reflect.Type, isOptional bool) string

Convert converts a Go type to its corresponding io-ts type

type FieldProcessor added in v1.0.3

type FieldProcessor interface {
	ProcessField(field reflect.StructField) string
	ProcessInlineField(field reflect.StructField) []string
}

FieldProcessor defines an interface for processing struct fields

type IoTsGenerator

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

IoTsGenerator encapsulates the logic to generate io-ts types

func NewIoTsGenerator

func NewIoTsGenerator(options ...TypeScriptGeneratorOptions) *IoTsGenerator

NewIoTsGenerator creates a new instance of NewIoTsGenerator with the provided options

func (*IoTsGenerator) Generate

func (g *IoTsGenerator) Generate(inputStruct interface{}) (string, error)

Generate takes any struct and generates its corresponding io-ts type

type TypeConverter added in v1.0.3

type TypeConverter interface {
	Convert(goType reflect.Type, isOptional bool) string
}

TypeConverter defines an interface for converting Go types to io-ts types

type TypeScriptGeneratorOptions

type TypeScriptGeneratorOptions struct {
	TreatArraysAsOptional bool
}

TypeScriptGeneratorOptions defines options for generating TypeScript interfaces

Jump to

Keyboard shortcuts

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