v2

package
v0.0.0-...-3b29339 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperationTypePublish   asyncapi.OperationType = "publish"
	OperationTypeSubscribe asyncapi.OperationType = "subscribe"
)

Constants for Operation Types.

Variables

This section is empty.

Functions

func Decode

func Decode(b []byte, dst interface{}) error

Decode implements the Decoder interface. Decodes AsyncAPI V2.x.x documents.

Types

type Channel

type Channel struct {
	Extendable
	Describable     `mapstructure:",squash"`
	PathField       string                      `mapstructure:"path" json:"path"`
	ParametersField map[string]ChannelParameter `mapstructure:"parameters" json:"parameters"`
	Subscribe       *SubscribeOperation         `mapstructure:"subscribe" json:"subscribe"`
	Publish         *PublishOperation           `mapstructure:"publish" json:"publish"`
}

func NewChannel

func NewChannel(path string) *Channel

NewChannel creates a new Channel. Useful for testing.

func (Channel) HasParameters

func (c Channel) HasParameters() bool

func (Channel) ID

func (c Channel) ID() string

func (Channel) IDField

func (c Channel) IDField() string

func (Channel) Messages

func (c Channel) Messages() []asyncapi.Message

func (Channel) Operations

func (c Channel) Operations() []asyncapi.Operation

func (Channel) Parameters

func (c Channel) Parameters() []asyncapi.ChannelParameter

func (Channel) Path

func (c Channel) Path() string

type ChannelParameter

type ChannelParameter struct {
	Extendable
	Describable
	NameField   string  `mapstructure:"name"`
	SchemaField *Schema `mapstructure:"schema"`
}

func (ChannelParameter) ID

func (c ChannelParameter) ID() string

func (ChannelParameter) IDField

func (c ChannelParameter) IDField() string

func (ChannelParameter) Name

func (c ChannelParameter) Name() string

func (ChannelParameter) Schema

func (c ChannelParameter) Schema() asyncapi.Schema

type Describable

type Describable struct {
	DescriptionField string `mapstructure:"description" json:"description"`
}

func (Describable) Description

func (d Describable) Description() string

func (Describable) HasDescription

func (d Describable) HasDescription() bool

type Document

type Document struct {
	Extendable
	InfoField     Info               `mapstructure:"info" json:"info"`
	ServersField  map[string]Server  `mapstructure:"servers" json:"servers"`
	ChannelsField map[string]Channel `mapstructure:"channels" json:"channels"`
}

func (Document) ApplicationPublishOperations

func (d Document) ApplicationPublishOperations() []asyncapi.Operation

func (Document) ApplicationPublishableChannels

func (d Document) ApplicationPublishableChannels() []asyncapi.Channel

func (Document) ApplicationPublishableMessages

func (d Document) ApplicationPublishableMessages() []asyncapi.Message

func (Document) ApplicationSubscribableChannels

func (d Document) ApplicationSubscribableChannels() []asyncapi.Channel

func (Document) ApplicationSubscribableMessages

func (d Document) ApplicationSubscribableMessages() []asyncapi.Message

func (Document) ApplicationSubscribeOperations

func (d Document) ApplicationSubscribeOperations() []asyncapi.Operation

func (Document) Channels

func (d Document) Channels() []asyncapi.Channel

func (Document) ClientPublishOperations

func (d Document) ClientPublishOperations() []asyncapi.Operation

func (Document) ClientPublishableChannels

func (d Document) ClientPublishableChannels() []asyncapi.Channel

func (Document) ClientPublishableMessages

func (d Document) ClientPublishableMessages() []asyncapi.Message

func (Document) ClientSubscribableChannels

func (d Document) ClientSubscribableChannels() []asyncapi.Channel

func (Document) ClientSubscribableMessages

func (d Document) ClientSubscribableMessages() []asyncapi.Message

func (Document) ClientSubscribeOperations

func (d Document) ClientSubscribeOperations() []asyncapi.Operation

func (Document) HasChannels

func (d Document) HasChannels() bool

func (Document) HasServers

func (d Document) HasServers() bool

func (Document) Info

func (d Document) Info() asyncapi.Info

func (Document) Messages

func (d Document) Messages() []asyncapi.Message

func (Document) Server

func (d Document) Server(name string) (asyncapi.Server, bool)

func (Document) Servers

func (d Document) Servers() []asyncapi.Server

type Extendable

type Extendable struct {
	Raw map[string]interface{} `mapstructure:",remain" json:"-"`
}

func (Extendable) Extension

func (e Extendable) Extension(name string) interface{}

func (Extendable) HasExtension

func (e Extendable) HasExtension(name string) bool

type FalsifiableSchema

type FalsifiableSchema struct {
	// contains filtered or unexported fields
}

func NewFalsifiableSchema

func NewFalsifiableSchema(val interface{}) *FalsifiableSchema

NewFalsifiableSchema creates a new FalsifiableSchema.

func (FalsifiableSchema) IsFalse

func (f FalsifiableSchema) IsFalse() bool

func (FalsifiableSchema) IsSchema

func (f FalsifiableSchema) IsSchema() bool

func (FalsifiableSchema) Schema

func (f FalsifiableSchema) Schema() asyncapi.Schema

type Info

type Info struct {
	TitleField   string `mapstructure:"title" json:"title"`
	VersionField string `mapstructure:"version" json:"version"`
}

func (*Info) Title

func (info *Info) Title() string

func (*Info) Version

func (info *Info) Version() string

type MapStructureDefaultsProvider

type MapStructureDefaultsProvider interface {
	MapStructureDefaults() map[string]interface{}
}

MapStructureDefaultsProvider tells to mapstructure setDefaultsHook the defaults value for that type.

type Message

type Message struct {
	Extendable
	Describable      `mapstructure:",squash"`
	NameField        string  `mapstructure:"name" json:"name"`
	TitleField       string  `mapstructure:"title" json:"title"`
	SummaryField     string  `mapstructure:"summary" json:"summary"`
	ContentTypeField string  `mapstructure:"contentType" json:"contentType"`
	PayloadField     *Schema `mapstructure:"payload" json:"payload"`
}

func (Message) ContentType

func (m Message) ContentType() string

func (Message) HasSummary

func (m Message) HasSummary() bool

func (Message) HasTitle

func (m Message) HasTitle() bool

func (Message) Name

func (m Message) Name() string

func (Message) Payload

func (m Message) Payload() asyncapi.Schema

func (Message) Summary

func (m Message) Summary() string

func (Message) Title

func (m Message) Title() string

func (Message) UID

func (m Message) UID() string

type Messages

type Messages struct {
	Message    `mapstructure:",squash"`
	OneOfField []*Message `mapstructure:"oneOf" json:"oneOf"`
}

Messages is a variadic type for Message object, which can be either one message or oneOf. See https://www.asyncapi.com/docs/specifications/v2.0.0#operationObject.

func NewMessages

func NewMessages(msgs []*Message) *Messages

NewMessages creates Messages.

func (*Messages) Messages

func (m *Messages) Messages() []*Message

type Operation

type Operation struct {
	Extendable
	Describable      `mapstructure:",squash"`
	OperationIDField string                 `mapstructure:"operationId" json:"operationId"`
	MessageField     Messages               `mapstructure:"message" json:"message"`
	OperationType    asyncapi.OperationType `mapstructure:"operationType" json:"operationType"` // set by hook
	SummaryField     string                 `mapstructure:"summary" json:"summary"`
}

func NewOperation

func NewOperation(operationType asyncapi.OperationType, msgs ...*Message) *Operation

NewOperation creates a new Operation. Useful for testing.

func (Operation) HasSummary

func (o Operation) HasSummary() bool

func (Operation) ID

func (o Operation) ID() string

func (Operation) IsApplicationPublishing

func (o Operation) IsApplicationPublishing() bool

func (Operation) IsApplicationSubscribing

func (o Operation) IsApplicationSubscribing() bool

func (Operation) IsClientPublishing

func (o Operation) IsClientPublishing() bool

func (Operation) IsClientSubscribing

func (o Operation) IsClientSubscribing() bool

func (Operation) Messages

func (o Operation) Messages() []asyncapi.Message

func (Operation) Summary

func (o Operation) Summary() string

func (Operation) Type

func (o Operation) Type() asyncapi.OperationType

type PublishOperation

type PublishOperation struct {
	Operation
}

func NewPublishOperation

func NewPublishOperation(msgs ...*Message) *PublishOperation

NewPublishOperation creates a new PublishOperation. Useful for testing.

func (PublishOperation) MapStructureDefaults

func (o PublishOperation) MapStructureDefaults() map[string]interface{}

type Schema

type Schema struct {
	Extendable
	AdditionalItemsField      interface{}       `mapstructure:"additionalItems" json:"additionalItems,omitempty"`
	AdditionalPropertiesField interface{}       `mapstructure:"additionalProperties" json:"additionalProperties,omitempty"` // Schema || false
	AllOfField                []asyncapi.Schema `mapstructure:"allOf" json:"allOf,omitempty"`
	AnyOfField                []asyncapi.Schema `mapstructure:"anyOf" json:"anyOf,omitempty"`
	ConstField                interface{}       `mapstructure:"const" json:"const,omitempty"`
	ContainsField             *Schema           `mapstructure:"contains" json:"contains,omitempty"`
	ContentEncodingField      string            `mapstructure:"contentEncoding" json:"contentEncoding,omitempty"`
	ContentMediaTypeField     string            `mapstructure:"contentMediaType" json:"contentMediaType,omitempty"`
	DefaultField              interface{}       `mapstructure:"default" json:"default,omitempty"`
	DefinitionsField          Schemas           `mapstructure:"definitions" json:"definitions,omitempty"`
	DependenciesField         Schemas           `mapstructure:"dependencies" json:"dependencies,omitempty"`
	DeprecatedField           bool              `mapstructure:"deprecated" json:"deprecated,omitempty"`
	DescriptionField          string            `mapstructure:"description" json:"description,omitempty"`
	DiscriminatorField        string            `mapstructure:"discriminator" json:"discriminator,omitempty"`
	ElseField                 *Schema           `mapstructure:"else" json:"else,omitempty"`
	EnumField                 []interface{}     `mapstructure:"enum" json:"enum,omitempty"`
	ExamplesField             []interface{}     `mapstructure:"examples" json:"examples,omitempty"`
	ExclusiveMaximumField     *float64          `mapstructure:"exclusiveMaximum" json:"exclusiveMaximum,omitempty"`
	ExclusiveMinimumField     *float64          `mapstructure:"exclusiveMinimum" json:"exclusiveMinimum,omitempty"`
	FormatField               string            `mapstructure:"format" json:"format,omitempty"`
	IDField                   string            `mapstructure:"$id" json:"$id,omitempty"`
	IfField                   *Schema           `mapstructure:"if" json:"if,omitempty"`
	ItemsField                []asyncapi.Schema `mapstructure:"items" json:"items,omitempty"`
	MaximumField              *float64          `mapstructure:"maximum" json:"maximum,omitempty"`
	MaxItemsField             *float64          `mapstructure:"maxItems" json:"maxItems,omitempty"`
	MaxLengthField            *float64          `mapstructure:"maxLength" json:"maxLength,omitempty"`
	MaxPropertiesField        *float64          `mapstructure:"maxProperties" json:"maxProperties,omitempty"`
	MinimumField              *float64          `mapstructure:"minimum" json:"minimum,omitempty"`
	MinItemsField             *float64          `mapstructure:"minItems" json:"minItems,omitempty"`
	MinLengthField            *float64          `mapstructure:"minLength" json:"minLength,omitempty"`
	MinPropertiesField        *float64          `mapstructure:"minProperties" json:"minProperties,omitempty"`
	MultipleOfField           *float64          `mapstructure:"multipleOf" json:"multipleOf,omitempty"`
	NotField                  *Schema           `mapstructure:"not" json:"not,omitempty"`
	OneOfField                []asyncapi.Schema `mapstructure:"oneOf" json:"oneOf,omitempty"`
	PatternField              string            `mapstructure:"pattern" json:"pattern,omitempty"`
	PatternPropertiesField    Schemas           `mapstructure:"patternProperties" json:"patternProperties,omitempty"`
	PropertiesField           Schemas           `mapstructure:"properties" json:"properties,omitempty"`
	PropertyNamesField        *Schema           `mapstructure:"propertyNames" json:"propertyNames,omitempty"`
	ReadOnlyField             bool              `mapstructure:"readOnly" json:"readOnly,omitempty"`
	RequiredField             []string          `mapstructure:"required" json:"required,omitempty"`
	ThenField                 *Schema           `mapstructure:"then" json:"then,omitempty"`
	TitleField                string            `mapstructure:"title" json:"title,omitempty"`
	TypeField                 interface{}       `mapstructure:"type" json:"type,omitempty"` // string | []string
	UniqueItemsField          bool              `mapstructure:"uniqueItems" json:"uniqueItems,omitempty"`
	WriteOnlyField            bool              `mapstructure:"writeOnly" json:"writeOnly,omitempty"`
	// contains filtered or unexported fields
}

func (*Schema) AdditionalItems

func (s *Schema) AdditionalItems() asyncapi.FalsifiableSchema

func (*Schema) AdditionalProperties

func (s *Schema) AdditionalProperties() asyncapi.FalsifiableSchema

func (*Schema) AllOf

func (s *Schema) AllOf() []asyncapi.Schema

func (*Schema) AnyOf

func (s *Schema) AnyOf() []asyncapi.Schema

func (*Schema) CircularProps

func (s *Schema) CircularProps() []string

func (*Schema) Const

func (s *Schema) Const() interface{}

func (*Schema) Contains

func (s *Schema) Contains() asyncapi.Schema

func (*Schema) ContentEncoding

func (s *Schema) ContentEncoding() string

func (*Schema) ContentMediaType

func (s *Schema) ContentMediaType() string

func (*Schema) Default

func (s *Schema) Default() interface{}

func (*Schema) Definitions

func (s *Schema) Definitions() map[string]asyncapi.Schema

func (*Schema) Dependencies

func (s *Schema) Dependencies() map[string]asyncapi.Schema

func (*Schema) Deprecated

func (s *Schema) Deprecated() bool

func (*Schema) Description

func (s *Schema) Description() string

func (*Schema) Discriminator

func (s *Schema) Discriminator() string

func (*Schema) Else

func (s *Schema) Else() asyncapi.Schema

func (*Schema) Enum

func (s *Schema) Enum() []interface{}

func (*Schema) Examples

func (s *Schema) Examples() []interface{}

func (*Schema) ExclusiveMaximum

func (s *Schema) ExclusiveMaximum() *float64

func (*Schema) ExclusiveMinimum

func (s *Schema) ExclusiveMinimum() *float64

func (*Schema) Format

func (s *Schema) Format() string

func (*Schema) HasCircularProps

func (s *Schema) HasCircularProps() bool

func (*Schema) ID

func (s *Schema) ID() string

func (*Schema) If

func (s *Schema) If() asyncapi.Schema

func (*Schema) IsCircular

func (s *Schema) IsCircular() bool

func (*Schema) Items

func (s *Schema) Items() []asyncapi.Schema

func (*Schema) MaxItems

func (s *Schema) MaxItems() *float64

func (*Schema) MaxLength

func (s *Schema) MaxLength() *float64

func (*Schema) MaxProperties

func (s *Schema) MaxProperties() *float64

func (*Schema) Maximum

func (s *Schema) Maximum() *float64

func (*Schema) MinItems

func (s *Schema) MinItems() *float64

func (*Schema) MinLength

func (s *Schema) MinLength() *float64

func (*Schema) MinProperties

func (s *Schema) MinProperties() *float64

func (*Schema) Minimum

func (s *Schema) Minimum() *float64

func (*Schema) MultipleOf

func (s *Schema) MultipleOf() *float64

func (*Schema) Not

func (s *Schema) Not() asyncapi.Schema

func (*Schema) OneOf

func (s *Schema) OneOf() []asyncapi.Schema

func (*Schema) Pattern

func (s *Schema) Pattern() string

func (*Schema) PatternProperties

func (s *Schema) PatternProperties() map[string]asyncapi.Schema

func (*Schema) Properties

func (s *Schema) Properties() map[string]asyncapi.Schema

func (*Schema) Property

func (s *Schema) Property(name string) asyncapi.Schema

func (*Schema) PropertyNames

func (s *Schema) PropertyNames() asyncapi.Schema

func (*Schema) ReadOnly

func (s *Schema) ReadOnly() bool

func (*Schema) Required

func (s *Schema) Required() []string

func (*Schema) Then

func (s *Schema) Then() asyncapi.Schema

func (*Schema) Title

func (s *Schema) Title() string

func (*Schema) Type

func (s *Schema) Type() []string

func (*Schema) UID

func (s *Schema) UID() string

func (*Schema) UniqueItems

func (s *Schema) UniqueItems() bool

func (*Schema) WriteOnly

func (s *Schema) WriteOnly() bool

type Schemas

type Schemas map[string]*Schema

func (Schemas) ToInterface

func (s Schemas) ToInterface(dst map[string]asyncapi.Schema) map[string]asyncapi.Schema

type Server

type Server struct {
	Extendable
	Describable    `mapstructure:",squash"`
	NameField      string                    `mapstructure:"name" json:"name"`
	ProtocolField  string                    `mapstructure:"protocol" json:"protocol"`
	URLField       string                    `mapstructure:"url" json:"url"`
	VariablesField map[string]ServerVariable `mapstructure:"variables" json:"variables"`
}

func (Server) HasName

func (s Server) HasName() bool

func (Server) HasProtocol

func (s Server) HasProtocol() bool

func (Server) HasURL

func (s Server) HasURL() bool

func (Server) ID

func (s Server) ID() string

func (Server) IDField

func (s Server) IDField() string

func (Server) Name

func (s Server) Name() string

func (Server) Protocol

func (s Server) Protocol() string

func (Server) URL

func (s Server) URL() string

func (Server) Variables

func (s Server) Variables() []asyncapi.ServerVariable

type ServerVariable

type ServerVariable struct {
	Extendable
	NameField string   `mapstructure:"name" json:"name"`
	Default   string   `mapstructure:"default" json:"default"`
	Enum      []string `mapstructure:"enum" json:"enum"`
}

func (ServerVariable) AllowedValues

func (s ServerVariable) AllowedValues() []string

func (ServerVariable) DefaultValue

func (s ServerVariable) DefaultValue() string

func (ServerVariable) HasName

func (s ServerVariable) HasName() bool

func (ServerVariable) ID

func (s ServerVariable) ID() string

func (ServerVariable) IDField

func (s ServerVariable) IDField() string

func (ServerVariable) Name

func (s ServerVariable) Name() string

type SubscribeOperation

type SubscribeOperation struct {
	Operation
}

func NewSubscribeOperation

func NewSubscribeOperation(msgs ...*Message) *SubscribeOperation

NewSubscribeOperation creates a new SubscribeOperation. Useful for testing.

func (SubscribeOperation) MapStructureDefaults

func (o SubscribeOperation) MapStructureDefaults() map[string]interface{}

Jump to

Keyboard shortcuts

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