codegen

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidBroker is an error raised when using an unknown broker.
	ErrInvalidBroker = fmt.Errorf("%w: invalid broker", extensions.ErrAsyncAPI)

	// ErrInvalidFileFormat is returned when using an invalid format for AsyncAPI specification.
	ErrInvalidFileFormat = fmt.Errorf("%w: invalid file format", extensions.ErrAsyncAPI)
)

Functions

This section is empty.

Types

type CodeGen

type CodeGen struct {
	Specification asyncapi.Specification
	ModulePath    string
	ModuleVersion string
}

CodeGen is the main structure for the code generation.

func FromFile

func FromFile(path string) (CodeGen, error)

FromFile parses the AsyncAPI specification either from a YAML file or a JSON file.

func FromJSON

func FromJSON(data []byte) (CodeGen, error)

FromJSON parses the AsyncAPI specification from a JSON file.

func FromYAML

func FromYAML(data []byte) (CodeGen, error)

FromYAML parses the AsyncAPI specification from a YAML file.

func New

func New(spec asyncapi.Specification) CodeGen

New creates a new code generation structure that can be used to generate code.

func (CodeGen) Generate

func (cg CodeGen) Generate(opt Options) error

Generate generates code from the code generation structure, that have already processed the AsyncAPI file when creating it.

type Options

type Options struct {
	// OutputPath is the path to the generated code file
	OutputPath string

	// PackageName is the package name of the generated code
	PackageName string

	// Generate contains options regarding which golang code should be generated
	Generate generators.Options

	// DisableFormatting states if the formatting should be disabled when
	// writing the generated code
	DisableFormatting bool
}

Options is the struct that gather configuration of codegen.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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