codegen

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: Apache-2.0 Imports: 10 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 = errors.New("invalid broker")

	// ErrInvalidFileFormat is returned when using an invalid format for AsyncAPI specification
	ErrInvalidFileFormat = errors.New("invalid file format")
)

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