asyncapi

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

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

	// ErrInvalidVersion is returned when the version is either unsupported or invalid.
	ErrInvalidVersion = fmt.Errorf("%w: unsupported/invalid version", extensions.ErrAsyncAPI)
)
View Source
var SupportedVersions = []string{
	"2.0.0",
	"2.1.0",
	"2.2.0",
	"2.3.0",
	"2.4.0",
	"2.5.0",
	"2.6.0",

	"3.0.0",
}

SupportedVersions describe the asyncapi-codegen supported versions.

Functions

func IsVersionSupported added in v0.32.0

func IsVersionSupported(version string) bool

IsVersionSupported checks that the version is supported.

func ToV2 added in v0.32.0

ToV2 returns an AsyncAPI specification V2 from interface, if compatible. Note: Before using this, you should make sure that parsed data is in version 2.

func ToV3 added in v0.32.0

ToV3 returns an AsyncAPI specification V3 from interface, if compatible. Note: Before using this, you should make sure that parsed data is in version 3.

Types

type Specification

type Specification interface {
	// MajorVersion returns the major version of the AsyncAPI specification.
	MajorVersion() int
	// Process processes all information in specification in order to link the
	// references, apply the traits and generating other information for code
	// generation.
	//
	// WARNING: this will alter the specification as you will find, by example,
	// traits applied in the specification.
	Process() error
}

Specification only contains common functions between each version. This should be casted to get all other functions, base on the version.

func FromFile added in v0.32.0

func FromFile(path string) (Specification, error)

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

NOTE: It returns the Specification with filled fields, but this doesn't link references, apply traits, etc. You have to call method `Process` for this.

func FromJSON added in v0.32.0

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

FromJSON parses the AsyncAPI specification from a JSON file.

NOTE: It returns the Specification with filled fields, but this doesn't link references, apply traits, etc. You have to call method `Process` for this.

func FromYAML added in v0.32.0

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

FromYAML parses the AsyncAPI specification from a YAML file.

NOTE: It returns the Specification with filled fields, but this doesn't link references, apply traits, etc. You have to call method `Process` for this.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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