asyncapi

package
v0.0.0-...-4ba87e4 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChannelsKey        = "channels"
	SubscribeKey       = "subscribe"
	MessageKey         = "message"
	PayloadKey         = "payload"
	PropertiesKey      = "properties"
	EnumKey            = "enum"
	ServersKey         = "servers"
	URLKey             = "url"
	ProtocolKey        = "protocol"
	ProtocolVersionKey = "protocolVersion"
	DescriptionKey     = "description"
	NameKey            = "name"
	TitleKey           = "title"
	SummaryKey         = "summary"
	TypeKey            = "type"
	FormatKey          = "format"
	MinimumKey         = "minimum"
	MaximumKey         = "maximum"
	OperationIDKey     = "operationId"
	SecurityKey        = "security"
	BindingsKey        = "bindings"
	KafkaKey           = "kafka"
	TraitsKey          = "traits"
	ParametersKey      = "parameters"
	SchemaKey          = "schema"
	InfoKey            = "info"
	VersionKey         = "version"
)

Variables

This section is empty.

Functions

func ImportAsyncAPIDocumentByte

func ImportAsyncAPIDocumentByte(input []byte) (*ast.Document, operationreport.Report)

ImportAsyncAPIDocumentByte reads a byte array containing an AsyncAPI document and returns the parsed document as an ast.Document and an operationreport.Report. It first calls ParseAsyncAPIDocument to parse the input byte array into an AsyncAPI struct. If parsing fails, an internal error is added to the report and nil values are returned. Otherwise, it calls ImportParsedAsyncAPIDocument to convert the parsed AsyncAPI struct into an ast.Document using a converter. The resulting ast.Document and the report are returned.

func ImportAsyncAPIDocumentString

func ImportAsyncAPIDocumentString(input string) (*ast.Document, operationreport.Report)

ImportAsyncAPIDocumentString imports an AsyncAPI document from a string input. It internally calls ImportAsyncAPIDocumentByte to parse and import the document. The input is expected to be a valid AsyncAPI document in string format. It returns the imported document as *ast.Document and an operationreport.Report. If there are any parsing or importing errors, the report will contain the error details.

func ImportParsedAsyncAPIDocument

func ImportParsedAsyncAPIDocument(parsed *AsyncAPI, report *operationreport.Report) *ast.Document

ImportParsedAsyncAPIDocument imports a parsed AsyncAPI document and returns a GraphQL Document. The function creates a converter instance and initializes the data structure for introspection.

Types

type AsyncAPI

type AsyncAPI struct {
	Info     *Info
	Channels map[string]*ChannelItem
	Servers  map[string]*Server
}

func ParseAsyncAPIDocument

func ParseAsyncAPIDocument(input []byte) (*AsyncAPI, error)

ParseAsyncAPIDocument parses the input byte slice as an AsyncAPI document and returns an AsyncAPI object and an error. The input byte slice should contain the AsyncAPI document in JSON/YAML format.

type Binding

type Binding struct {
	Value     []byte
	ValueType jsonparser.ValueType
}

type ChannelItem

type ChannelItem struct {
	Kind        ChannelItemKind
	Message     *Message
	Parameters  map[string]string
	OperationID string
	Traits      []*OperationTrait
	Servers     []string
}

ChannelItem object is defined here: https://www.asyncapi.com/docs/reference/specification/v2.4.0#channelItemObject

type ChannelItemKind

type ChannelItemKind string
const (
	ChannelItemKindSubscription ChannelItemKind = "subscription"
)

type Enum

type Enum struct {
	Value     []byte
	ValueType jsonparser.ValueType
}

type Info

type Info struct {
	Title   string
	Version string
}

type Message

type Message struct {
	Name        string
	Summary     string
	Title       string
	Description string
	Payload     *Payload
}

Message object is defined here: https://www.asyncapi.com/docs/reference/specification/v2.4.0#messageObject

type OperationTrait

type OperationTrait struct {
	Bindings map[string]map[string]*Binding
}

OperationTrait object is defined here: https://www.asyncapi.com/docs/reference/specification/v2.4.0#operationTraitObject

type Payload

type Payload struct {
	Type       string
	Properties map[string]*Property
}

Payload is definition of the message payload. It can be of any type but defaults to Schema object. It must match the schema format, including encoding type - e.g Avro should be inlined as either a YAML or JSON object NOT a string to be parsed as YAML or JSON.

type Property

type Property struct {
	Description string
	Minimum     int
	Maximum     int
	Type        string
	Format      string
	Enum        []*Enum
}

Property object is derived from Schema object. https://www.asyncapi.com/docs/reference/specification/v2.4.0#schemaObject

type SecurityRequirement

type SecurityRequirement struct {
	Requirements map[string][]string
}

type Server

type Server struct {
	URL             string
	Protocol        string
	ProtocolVersion string
	Description     string
	Security        []*SecurityRequirement
	Bindings        map[string]map[string]*Binding
}

Server object is defined here: https://www.asyncapi.com/docs/reference/specification/v2.4.0#serverObject

Jump to

Keyboard shortcuts

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