generator

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	YAMLPackage = "gopkg.in/yaml.v3"
)

Variables

View Source
var (
	ErrCannotDumpDefaultSlice = errors.New("cannot dump default slice")
)
View Source
var ErrCannotUnmarshalEnum = fmt.Errorf("cannot unmarshal enum")

Functions

This section is empty.

Types

type Config

type Config struct {
	SchemaMappings []SchemaMapping
	// ExtraImports allows the generator to pull imports from outside the standard library.
	ExtraImports bool
	// Capitalizations configures capitalized forms for identifiers which take precedence over the default algorithm.
	Capitalizations []string
	// ResolveExtensions configures file extensions to use when resolving schema names.
	ResolveExtensions []string
	// YAMLExtensions configures the file extensions that are recognized as YAML files.
	YAMLExtensions []string
	// DefaultPackageName configures the package to declare files under.
	DefaultPackageName string
	// DefaultOutputName configures the file to write.
	DefaultOutputName string
	// StructNameFromTitle configures the generator to use the schema title as the generated struct name.
	StructNameFromTitle bool
	// Warner provides a handler for warning messages.
	Warner func(string)
	// Tags specifies which struct tags should be generated.
	Tags []string
	// OnlyModels configures the generator to omit unmarshal methods, validations, anything but models.
	OnlyModels bool
	// MinSizedInts configures the generator to use the smallest int and uint types based on schema maximum values.
	MinSizedInts bool
	// MinimalNames configures the generator to use the shortest identifier names possible.
	MinimalNames bool
	// Loader provides a schema loader for the generator.
	Loader schemas.Loader
	// When DisableOmitempty is set to true,
	// an "omitempty" tag will never be present in generated struct fields.
	// When DisableOmitempty is set to false,
	// an "omitempty" tag will be present for all fields that are not required.
	DisableOmitempty bool
	// DisableReadOnlyValidation configures the generator to omit validation for read-only fields.
	DisableReadOnlyValidation bool
	// DisableCustomTypesForMaps configures the generator to avoid creating a custom type for maps,
	// and to use the map type directly.
	DisableCustomTypesForMaps bool
	// StructNamePrefix configures the generator to prefix all generated struct names with the specified string.
	StructNamePrefix string
}

type Generator

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

func New

func New(config Config) (*Generator, error)

func (*Generator) AddFile added in v0.0.2

func (g *Generator) AddFile(fileName string, schema *schemas.Schema) error

func (*Generator) DisableOmitempty added in v0.0.2

func (g *Generator) DisableOmitempty() bool

func (*Generator) DoFile

func (g *Generator) DoFile(fileName string) error

func (*Generator) Sources

func (g *Generator) Sources() (map[string][]byte, error)

type SchemaMapping

type SchemaMapping struct {
	SchemaID    string
	PackageName string
	RootType    string
	OutputName  string
}

Jump to

Keyboard shortcuts

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