asyncapi

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	Parameters map[string]*Parameter `json:"parameters"`

	Subscribe *Operation `json:"subscribe"`
	Publish   *Operation `json:"publish"`

	// Non AsyncAPI fields
	Name string `json:"-"`
	Path string `json:"-"`
}

Channel is a representation of the corresponding asyncapi object filled from an asyncapi specification that will be used to generate code. Source: https://www.asyncapi.com/docs/reference/specification/v2.6.0#channelItemObject

func (Channel) GetChannelMessage added in v0.2.0

func (c Channel) GetChannelMessage() *Message

GetChannelMessage will return the channel message WARNING: if there is a reference, then it won't be followed.

func (*Channel) Process added in v0.2.0

func (c *Channel) Process(path string, spec Specification)

Process processes the Channel to make it ready for code generation.

type Components

type Components struct {
	Messages   map[string]*Message   `json:"messages"`
	Schemas    map[string]*Schema    `json:"schemas"`
	Parameters map[string]*Parameter `json:"parameters"`
}

Components is a representation of the corresponding asyncapi object filled from an asyncapi specification that will be used to generate code. Source: https://www.asyncapi.com/docs/reference/specification/v2.6.0#componentsObject

func (*Components) Process added in v0.2.0

func (c *Components) Process(spec Specification)

Process processes the Components structure to make it ready for code generation.

type CorrelationID added in v0.1.1

type CorrelationID struct {
	Description string `json:"description"`
	Location    string `json:"location"`
}

CorrelationID is a representation of the corresponding asyncapi object filled from an asyncapi specification that will be used to generate code. Source: https://www.asyncapi.com/docs/reference/specification/v2.6.0#correlationIdObject

type Extensions added in v0.18.0

type Extensions struct {
	// Setting custom Go type when generating schemas
	ExtGoType string `json:"x-go-type"`

	// Setting custom import statements for ExtGoType
	ExtGoTypeImport *GoTypeImportExtension `json:"x-go-type-import"`
}

Extensions holds additional properties defined for asyncapi-codegen that are out of the AsyncAPI spec.

type GoTypeImportExtension added in v0.18.0

type GoTypeImportExtension struct {
	Name GoTypeImportName `json:"name"` // Package name for import, optional
	Path GoTypeImportPath `json:"path"` // Path to package to import
}

GoTypeImportExtension specifies the required import statement for the x-go-type extension. For example, GoTypeImportExtension{Name: "myuuid", Path: "github.com/google/uuid"} will generate `import myuuid github.com/google/uuid`.

type GoTypeImportName added in v0.18.0

type GoTypeImportName string

GoTypeImportName is the import name type for x-go-type-import.

type GoTypeImportPath added in v0.18.0

type GoTypeImportPath string

GoTypeImportPath is the import path type for x-go-type-import.

type Info

type Info struct {
	Title       string `json:"title"`
	Version     string `json:"version"`
	Description string `json:"description"`
}

Info is a representation of the corresponding asyncapi object filled from an asyncapi specification that will be used to generate code. Source: https://www.asyncapi.com/docs/reference/specification/v2.6.0#infoObject

type Message

type Message struct {
	Description   string         `json:"description"`
	Headers       *Schema        `json:"headers"`
	OneOf         []*Message     `json:"oneOf"`
	Payload       *Schema        `json:"payload"`
	CorrelationID *CorrelationID `json:"correlationID"`
	Reference     string         `json:"$ref"`

	// --- Non AsyncAPI fields -------------------------------------------------
	Name        string   `json:"-"`
	ReferenceTo *Message `json:"-"`

	// CorrelationIDLocation will indicate where the correlation id is
	// According to: https://www.asyncapi.com/docs/reference/specification/v2.6.0#correlationIDObject
	CorrelationIDLocation string `json:"-"`
	CorrelationIDRequired bool   `json:"-"`
}

Message is a representation of the corresponding asyncapi object filled from an asyncapi specification that will be used to generate code. Source: https://www.asyncapi.com/docs/reference/specification/v2.6.0#messageObject

func (*Message) MergeWith added in v0.9.0

func (msg *Message) MergeWith(spec Specification, msg2 Message)

MergeWith merges the Message with another one.

func (*Message) Process added in v0.2.0

func (msg *Message) Process(name string, spec Specification)

Process processes the Message to make it ready for code generation.

type Operation

type Operation struct {
	Message Message `json:"message"`
}

Operation is a representation of the corresponding asyncapi object filled from an asyncapi specification that will be used to generate code. Source: https://www.asyncapi.com/docs/reference/specification/v2.6.0#operationObject

type Parameter added in v0.9.0

type Parameter struct {
	Description string  `json:"description"`
	Schema      *Schema `json:"schema"`
	Location    string  `json:"location"`
	Reference   string  `json:"$ref"`

	// Non AsyncAPI fields
	Name        string     `json:"-"`
	ReferenceTo *Parameter `json:"-"`
}

Parameter is a representation of the corresponding asyncapi object filled from an asyncapi specification that will be used to generate code. Source: https://www.asyncapi.com/docs/reference/specification/v2.6.0#parameterObject

func (*Parameter) Process added in v0.9.0

func (p *Parameter) Process(name string, spec Specification)

Process processes the Parameter structure to make it ready for code generation.

type Schema added in v0.21.4

type Schema struct {
	AllOf       []*Schema          `json:"allOf"`
	AnyOf       []*Schema          `json:"anyOf"`
	OneOf       []*Schema          `json:"oneOf"`
	Type        string             `json:"type"`
	Description string             `json:"description"`
	Format      string             `json:"format"`
	Properties  map[string]*Schema `json:"properties"`
	Items       *Schema            `json:"items"`
	Reference   string             `json:"$ref"`
	Required    []string           `json:"required"`

	// Non AsyncAPI fields
	Name        string  `json:"-"`
	ReferenceTo *Schema `json:"-"`
	IsRequired  bool    `json:"-"`

	// Embedded extended fields
	Extensions
}

Schema is a representation of the corresponding asyncapi object filled from an asyncapi specification that will be used to generate code. Source: https://www.asyncapi.com/docs/reference/specification/v2.6.0#schemaObject

func NewSchema added in v0.21.4

func NewSchema() Schema

NewSchema creates a new Schema structure with initialized fields.

func (Schema) IsFieldRequired added in v0.21.4

func (a Schema) IsFieldRequired(field string) bool

IsFieldRequired checks if a field is required in the asyncapi struct.

func (*Schema) MergeWith added in v0.21.4

func (a *Schema) MergeWith(spec Specification, a2 Schema)

MergeWith merges the given Schema structure with another one (basically for AllOf, AnyOf, OneOf, etc).

func (*Schema) Process added in v0.21.4

func (a *Schema) Process(name string, spec Specification, isRequired bool)

Process processes the Schema structure to make it ready for code generation.

type Specification

type Specification struct {
	Version    string              `json:"asyncapi"`
	Info       Info                `json:"info"`
	Channels   map[string]*Channel `json:"channels"`
	Components Components          `json:"components"`
}

Specification is the asyncapi specification struct that will be used to generate code. It should contains every information given in the asyncapi specification. Source: https://www.asyncapi.com/docs/reference/specification/v2.6.0#schema

func (Specification) CustomImports added in v0.18.0

func (s Specification) CustomImports() ([]string, error)

CustomImports collects all custom import paths set by x-go-type-imports in all Schema Objects in the Specification. Returns import strings like `alias "abc.xyz/repo/package"` for code generation. Returns error when import name conflicts.

func (Specification) GetPublishSubscribeCount added in v0.1.2

func (s Specification) GetPublishSubscribeCount() (publishCount, subscribeCount uint)

GetPublishSubscribeCount gets the count of 'publish' channels and the count of 'subscribe' channels inside the Specification.

func (*Specification) Process

func (s *Specification) Process()

Process processes the Specification to make it ready for code generation.

func (Specification) ReferenceMessage

func (s Specification) ReferenceMessage(ref string) *Message

ReferenceMessage returns the Message struct corresponding to the given reference.

func (Specification) ReferenceParameter added in v0.12.0

func (s Specification) ReferenceParameter(ref string) *Parameter

ReferenceParameter returns the Parameter struct corresponding to the given reference.

func (Specification) ReferenceSchema added in v0.21.4

func (s Specification) ReferenceSchema(ref string) *Schema

ReferenceSchema returns the Any struct corresponding to the given reference.

type Type added in v0.21.3

type Type string

Type is a structure that represents the type of a field.

const (
	// TypeIsArray represents the type of an array.
	TypeIsArray Type = "array"
	// TypeIsHeader represents the type of a header.
	TypeIsHeader Type = "header"
	// TypeIsObject represents the type of an object.
	TypeIsObject Type = "object"
	// TypeIsString represents the type of a string.
	TypeIsString Type = "string"
	// TypeIsInteger represents the type of an integer.
	TypeIsInteger Type = "integer"
)

func (Type) String added in v0.21.3

func (t Type) String() string

String returns the string representation of the type.

Jump to

Keyboard shortcuts

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