asyncapiv3

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MessageHeadersSuffix is the suffix for the headers schema name.
	MessageHeadersSuffix = "Headers"
	// MessagePayloadSuffix is the suffix for the payload schema name.
	MessagePayloadSuffix = "Payload"
)
View Source
const (
	// BindingsSuffix is the suffix added to the bindings name.
	BindingsSuffix = "Bindings"
)
View Source
const (
	// ChannelSuffix is the suffix added to the channels name.
	ChannelSuffix = "Channel"
)
View Source
const (
	// ExternalDocsNameSuffix is the suffix that is added to the name of external docs.
	ExternalDocsNameSuffix = "ExternalDocs"
)
View Source
const (
	// MajorVersion is the major version of this AsyncAPI implementation.
	MajorVersion = 3
)

Variables

View Source
var (
	// ErrInvalidReference is sent when a reference is invalid.
	ErrInvalidReference = fmt.Errorf("%w: invalid reference", extensions.ErrAsyncAPI)
)
View Source
var (
	// ErrNoMessageInChannel is the error returned when there is no message in a channel.
	ErrNoMessageInChannel = fmt.Errorf("%w: no message in channel", extensions.ErrAsyncAPI)
)

Functions

This section is empty.

Types

type AMQP1Binding

type AMQP1Binding any

AMQP1Binding represents protocol-specific information for an AMQP 1.0 channel.

type AMQPBinding

type AMQPBinding any

AMQPBinding represents protocol-specific information for an AMQP 0-9-1 channel.

type AnyPointMqBinding

type AnyPointMqBinding any

AnyPointMqBinding represents protocol-specific information for an Anypoint MQ channel.

type Channel

type Channel struct {
	Address      string                 `json:"address"`
	Messages     map[string]*Message    `json:"messages"`
	Title        string                 `json:"title"`
	Summary      string                 `json:"summary"`
	Description  string                 `json:"description"`
	Servers      []*Server              `json:"servers"` // Reference only
	Parameters   map[string]*Parameter  `json:"parameters"`
	Tags         []*Tag                 `json:"tags"`
	ExternalDocs *ExternalDocumentation `json:"externalDocs"`
	Bindings     *ChannelBindings       `json:"bindings"`
	Reference    string                 `json:"$ref"`

	Name        string   `json:"-"`
	ReferenceTo *Channel `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/v3.0.0#channelObject

func (*Channel) Follow

func (ch *Channel) Follow() *Channel

Follow returns referenced channel if specified or the actual channel.

func (Channel) GetMessage

func (ch Channel) GetMessage() (*Message, error)

GetMessage will return the channel message.

type ChannelBindings

type ChannelBindings struct {
	HTTP         HTTPBinding         `json:"http"`
	WS           WsBinding           `json:"ws"`
	Kafka        KafkaBinding        `json:"kafka"`
	AnyPointMQ   AnyPointMqBinding   `json:"anypointmq"`
	AMQP         AMQPBinding         `json:"amqp"`
	AMQP1        AMQP1Binding        `json:"amqp1"`
	MQTT         MQTTBinding         `json:"mqtt"`
	MQTT5        MQTT5Binding        `json:"mqtt5"`
	NATS         NATSBinding         `json:"nats"`
	JMS          JMSBinding          `json:"jms"`
	SNS          SNSBinding          `json:"sns"`
	Solace       SolaceBinding       `json:"solace"`
	SQS          SQSBinding          `json:"sqs"`
	Stomp        StompBinding        `json:"stomp"`
	Redis        RedisBinding        `json:"redis"`
	Mercure      MercureBinding      `json:"mercure"`
	IBMMQ        IBMMQBinding        `json:"ibmmq"`
	GooglePubSub GooglePubSubBinding `json:"googlepubsub"`
	Pulsar       PulsarBinding       `json:"pulsar"`
	Reference    string              `json:"$ref"`

	Name        string           `json:"-"`
	ReferenceTo *ChannelBindings `json:"-"`
}

ChannelBindings 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/v3.0.0#channelBindingsObject

type Components

type Components struct {
	Schemas           map[string]*Schema                `json:"schemas"`
	Servers           map[string]*Server                `json:"servers"`
	Channels          map[string]*Channel               `json:"channels"`
	Operations        map[string]*Operation             `json:"operations"`
	Messages          map[string]*Message               `json:"messages"`
	SecuritySchemes   map[string]*SecurityScheme        `json:"securitySchemes"`
	ServerVariables   map[string]*ServerVariable        `json:"serverVariables"`
	Parameters        map[string]*Parameter             `json:"parameters"`
	CorrelationIDs    map[string]*CorrelationID         `json:"correlationIds"`
	Replies           map[string]*OperationReply        `json:"replies"`
	ReplyAddresses    map[string]*OperationReplyAddress `json:"replyAddresses"`
	ExternalDocs      map[string]*ExternalDocumentation `json:"externalDocs"`
	Tags              map[string]*Tag                   `json:"tags"`
	OperationTraits   map[string]*OperationTrait        `json:"operationTraits"`
	MessageTraits     map[string]*MessageTrait          `json:"messageTraits"`
	ServerBindings    map[string]*ServerBindings        `json:"serverBindings"`
	ChannelBindings   map[string]*ChannelBindings       `json:"channelBindings"`
	OperationBindings map[string]*OperationBindings     `json:"operationBindings"`
	MessageBindings   map[string]*MessageBindings       `json:"messageBindings"`
}

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/v3.0.0#componentsObject

type Contact

type Contact struct {
	Name  string `json:"name"`
	URL   string `json:"url"`
	Email string `json:"email"`
}

Contact 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/v3.0.0#contactObject

type CorrelationID

type CorrelationID struct {
	Description string `json:"description"`
	Location    string `json:"location"`
	Reference   string `json:"$ref"`

	Name        string   `json:"-"`
	ReferenceTo *Channel `json:"-"`
}

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/v3.0.0#correlationIdObject

func (*CorrelationID) Exists added in v0.33.0

func (c *CorrelationID) Exists() bool

Exists checks that the correlation exists (and that the location is set).

type Extensions

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 ExternalDocumentation

type ExternalDocumentation struct {
	Description string `json:"description"`
	URL         string `json:"url"`
	Reference   string `json:"$ref"`

	Name        string                 `json:"-"`
	ReferenceTo *ExternalDocumentation `json:"-"`
}

ExternalDocumentation 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/v3.0.0#externalDocumentationObject

type GoTypeImportExtension

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

type GoTypeImportName string

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

type GoTypeImportPath

type GoTypeImportPath string

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

type GooglePubSubBinding

type GooglePubSubBinding any

GooglePubSubBinding represents protocol-specific information for a Google Cloud Pub/Sub channel.

type HTTPBinding

type HTTPBinding any

HTTPBinding represents protocol-specific information for an HTTP channel.

type IBMMQBinding

type IBMMQBinding any

IBMMQBinding represents protocol-specific information for an IBM MQ channel.

type Info

type Info struct {
	Title          string                 `json:"title"`
	Version        string                 `json:"version"`
	Description    string                 `json:"description"`
	TermsOfService string                 `json:"termsOfService"`
	Contact        *Contact               `json:"contact"`
	License        *License               `json:"license"`
	Tags           []*Tag                 `json:"tags"`
	ExternalDocs   *ExternalDocumentation `json:"externalDocs"`
}

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/v3.0.0#infoObject

type JMSBinding

type JMSBinding any

JMSBinding represents protocol-specific information for a JMS channel.

type KafkaBinding

type KafkaBinding any

KafkaBinding represents protocol-specific information for a Kafka channel.

type License

type License struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

License 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/v3.0.0#licenseObject

type MQTT5Binding

type MQTT5Binding any

MQTT5Binding represents protocol-specific information for an MQTT 5 channel.

type MQTTBinding

type MQTTBinding any

MQTTBinding represents protocol-specific information for an MQTT channel.

type MercureBinding

type MercureBinding any

MercureBinding represents protocol-specific information for a Mercure channel.

type Message

type Message struct {
	Headers       *Schema                `json:"headers"`
	Payload       *Schema                `json:"payload"`
	OneOf         []*Message             `json:"oneOf"`
	CorrelationID *CorrelationID         `json:"correlationID"`
	ContentType   string                 `json:"contentType"`
	Name          string                 `json:"name"`
	Title         string                 `json:"title"`
	Summary       string                 `json:"summary"`
	Description   string                 `json:"description"`
	Tags          []*Tag                 `json:"tags"`
	ExternalDocs  *ExternalDocumentation `json:"externalDocs"`
	Bindings      *MessageBindings       `json:"bindings"`
	Examples      []*MessageExample      `json:"examples"`
	Traits        []*MessageTrait        `json:"traits"`
	Reference     string                 `json:"$ref"`

	ReferenceTo *Message `json:"-"`

	// CorrelationIDLocation will indicate where the correlation id is
	// According to: https://www.asyncapi.com/docs/reference/specification/v3.0.0#correlationIdObject
	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/v3.0.0#messageObject

func (*Message) ApplyTrait

func (msg *Message) ApplyTrait(mt *MessageTrait, spec Specification) error

ApplyTrait applies a trait to the message.

func (*Message) Follow

func (msg *Message) Follow() *Message

Follow returns referenced message if specified or the actual message.

func (Message) HaveCorrelationID added in v0.33.0

func (msg Message) HaveCorrelationID() bool

HaveCorrelationID check that the message have a correlation ID.

func (*Message) MergeWith

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

MergeWith merges the Message with another one.

type MessageBindings

type MessageBindings struct {
	HTTP         HTTPBinding         `json:"http"`
	WS           WsBinding           `json:"ws"`
	Kafka        KafkaBinding        `json:"kafka"`
	AnyPointMQ   AnyPointMqBinding   `json:"anypointmq"`
	AMQP         AMQPBinding         `json:"amqp"`
	AMQP1        AMQP1Binding        `json:"amqp1"`
	MQTT         MQTTBinding         `json:"mqtt"`
	MQTT5        MQTT5Binding        `json:"mqtt5"`
	NATS         NATSBinding         `json:"nats"`
	JMS          JMSBinding          `json:"jms"`
	SNS          SNSBinding          `json:"sns"`
	Solace       SolaceBinding       `json:"solace"`
	SQS          SQSBinding          `json:"sqs"`
	Stomp        StompBinding        `json:"stomp"`
	Redis        RedisBinding        `json:"redis"`
	Mercure      MercureBinding      `json:"mercure"`
	IBMMQ        IBMMQBinding        `json:"ibmmq"`
	GooglePubSub GooglePubSubBinding `json:"googlepubsub"`
	Pulsar       PulsarBinding       `json:"pulsar"`
	Reference    string              `json:"$ref"`

	Name        string           `json:"-"`
	ReferenceTo *MessageBindings `json:"-"`
}

MessageBindings 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/v3.0.0#messageBindingsObject

type MessageExample

type MessageExample struct {
	Headers   map[string]any `json:"headers"`
	Payload   map[string]any `json:"payload"`
	Name      string         `json:"name"`
	Summary   string         `json:"summary"`
	Reference string         `json:"$ref"`

	ReferenceTo *MessageExample `json:"-"`
}

MessageExample 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/v3.0.0#messageExampleObject

type MessageField

type MessageField string

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

const (
	// MessageFieldIsHeader represents the message field of a header.
	MessageFieldIsHeader MessageField = "header"
	// MessageFieldIsPayload represents the message field of a payload.
	MessageFieldIsPayload MessageField = "payload"
)

func (MessageField) String

func (t MessageField) String() string

String returns the string representation of the type.

type MessageTrait

type MessageTrait struct {
	Headers       *Schema                `json:"headers"`
	Payload       *Schema                `json:"payload"`
	CorrelationID *CorrelationID         `json:"correlationID"`
	ContentType   string                 `json:"contentType"`
	Name          string                 `json:"name"`
	Title         string                 `json:"title"`
	Summary       string                 `json:"summary"`
	Description   string                 `json:"description"`
	Tags          []*Tag                 `json:"tags"`
	ExternalDocs  *ExternalDocumentation `json:"externalDocs"`
	Bindings      *MessageBindings       `json:"bindings"`
	Examples      []*MessageExample      `json:"examples"`
	Reference     string                 `json:"$ref"`

	ReferenceTo *MessageTrait `json:"-"`

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

MessageTrait 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/v3.0.0#messageTraitObject

func (*MessageTrait) Follow

func (mt *MessageTrait) Follow() *MessageTrait

Follow returns referenced MessageTrait if specified or the actual MessageTrait.

type NATSBinding

type NATSBinding any

NATSBinding represents protocol-specific information for a NATS channel.

type OAuthFlow

type OAuthFlow struct {
	AuthorizationURL string            `json:"authorizationUrl"`
	TokenURL         string            `json:"tokenUrl"`
	RefreshURL       string            `json:"refreshUrl"`
	AvailableScopes  map[string]string `json:"availableScopes"`
}

OAuthFlow 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/v3.0.0#oauthFlowObject

type OAuthFlows

type OAuthFlows struct {
	Implicit          OAuthFlow `json:"implicit"`
	Password          OAuthFlow `json:"password"`
	ClientCredentials OAuthFlow `json:"clientCredential"`
	AuthorizationCode OAuthFlow `json:"authorizationCode"`
}

OAuthFlows 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/v3.0.0#oauthFlowsObject

type Operation

type Operation struct {
	Action       OperationAction        `json:"action"`
	Channel      *Channel               `json:"channel"` // Reference only
	Title        string                 `json:"title"`
	Summary      string                 `json:"summary"`
	Description  string                 `json:"string"`
	Security     []*SecurityScheme      `json:"security"`
	Tags         []*Tag                 `json:"tags"`
	ExternalDocs *ExternalDocumentation `json:"externalDocs"`
	Bindings     *OperationBindings     `json:"bindings"`
	Traits       []*OperationTrait      `json:"traits"`
	Messages     []*Message             `json:"messages"` // References only
	Reply        *OperationReply        `json:"reply"`
	Reference    string                 `json:"$ref"`

	Name        string     `json:"-"`
	ReplyIs     *Operation `json:"-"`
	ReplyOf     *Operation `json:"-"`
	ReferenceTo *Operation `json:"-"`
}

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/v3.0.0#operationObject

func (*Operation) ApplyTrait

func (op *Operation) ApplyTrait(ot *OperationTrait, spec Specification)

ApplyTrait applies a trait to the operation.

func (*Operation) Follow

func (op *Operation) Follow() *Operation

Follow returns referenced operation if specified or the actual operation.

func (Operation) GetMessage

func (op Operation) GetMessage() (*Message, error)

GetMessage will return the operation message.

type OperationAction

type OperationAction string

OperationAction represents an OperationAction.

const (
	// OperationActionIsSend represents a send action.
	OperationActionIsSend OperationAction = "send"
	// OperationActionIsReceive represents a receive action.
	OperationActionIsReceive OperationAction = "receive"
)

func (OperationAction) IsReceive

func (oa OperationAction) IsReceive() bool

IsReceive returns true if the operation action is receive.

func (OperationAction) IsSend

func (oa OperationAction) IsSend() bool

IsSend returns true if the operation action is send.

type OperationBindings

type OperationBindings struct {
	HTTP         HTTPBinding         `json:"http"`
	WS           WsBinding           `json:"ws"`
	Kafka        KafkaBinding        `json:"kafka"`
	AnyPointMQ   AnyPointMqBinding   `json:"anypointmq"`
	AMQP         AMQPBinding         `json:"amqp"`
	AMQP1        AMQP1Binding        `json:"amqp1"`
	MQTT         MQTTBinding         `json:"mqtt"`
	MQTT5        MQTT5Binding        `json:"mqtt5"`
	NATS         NATSBinding         `json:"nats"`
	JMS          JMSBinding          `json:"jms"`
	SNS          SNSBinding          `json:"sns"`
	Solace       SolaceBinding       `json:"solace"`
	SQS          SQSBinding          `json:"sqs"`
	Stomp        StompBinding        `json:"stomp"`
	Redis        RedisBinding        `json:"redis"`
	Mercure      MercureBinding      `json:"mercure"`
	IBMMQ        IBMMQBinding        `json:"ibmmq"`
	GooglePubSub GooglePubSubBinding `json:"googlepubsub"`
	Pulsar       PulsarBinding       `json:"pulsar"`
	Reference    string              `json:"$ref"`

	Name        string             `json:"-"`
	ReferenceTo *OperationBindings `json:"-"`
}

OperationBindings 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/v3.0.0#operationBindingsObject

type OperationReply

type OperationReply struct {
	Address   *OperationReplyAddress `json:"address"`
	Channel   *Channel               `json:"channel"`  // Reference only
	Messages  []*Message             `json:"messages"` // References only
	Reference string                 `json:"$ref"`

	Name        string          `json:"-"`
	ReferenceTo *OperationReply `json:"-"`
}

OperationReply 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/v3.0.0#operationReplyObject

func (*OperationReply) Follow added in v0.34.0

func (or *OperationReply) Follow() *OperationReply

Follow returns referenced operation if specified or the actual operation.

type OperationReplyAddress

type OperationReplyAddress struct {
	Description string `json:"description"`
	Location    string `json:"location"`
	Reference   string `json:"$ref"`

	Name             string                 `json:"-"`
	ReferenceTo      *OperationReplyAddress `json:"-"`
	LocationRequired bool                   `json:"-"`
}

OperationReplyAddress 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/v3.0.0#operationReplyAddressObject

type OperationTrait

type OperationTrait struct {
	Title        string                 `json:"title"`
	Summary      string                 `json:"summary"`
	Description  string                 `json:"description"`
	Security     []*SecurityScheme      `json:"security"`
	Tags         []*Tag                 `json:"tags"`
	ExternalDocs *ExternalDocumentation `json:"externalDocs"`
	Bindings     *OperationBindings     `json:"bindings"`
	Reference    string                 `json:"$ref"`

	Name        string          `json:"-"`
	ReferenceTo *OperationTrait `json:"-"`
}

OperationTrait 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/v3.0.0#msgerationTraitObject

func (*OperationTrait) Follow added in v0.33.1

func (ot *OperationTrait) Follow() *OperationTrait

Follow returns referenced MessageTrait if specified or the actual MessageTrait.

type Parameter

type Parameter struct {
	Enum        []string `json:"enum"`
	Default     string   `json:"default"`
	Description string   `json:"description"`
	Examples    []string `json:"examples"`
	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/v3.0.0#parameterObject

type PulsarBinding

type PulsarBinding any

PulsarBinding represents protocol-specific information for a Pulsar channel.

type RedisBinding

type RedisBinding any

RedisBinding represents protocol-specific information for a Redis channel.

type SNSBinding

type SNSBinding any

SNSBinding represents protocol-specific information for an SNS channel.

type SQSBinding

type SQSBinding any

SQSBinding represents protocol-specific information for an SQS channel.

type Schema

type Schema struct {
	Title                string             `json:"title"`
	Type                 string             `json:"type"`
	Examples             []any              `json:"examples"`
	ReadOnly             bool               `json:"readOnly"`
	WriteOnly            bool               `json:"writeOnly"`
	Properties           map[string]*Schema `json:"properties"`
	PatternProperties    map[string]*Schema `json:"patternProperties"`
	AdditionalProperties *Schema            `json:"additionalProperties"`
	AdditionalItems      []*Schema          `json:"additionalItems"`
	Items                *Schema            `json:"items"`
	PropertyNames        []string           `json:"propertyNames"`
	Contains             []*Schema          `json:"contains"`
	AllOf                []*Schema          `json:"allOf"`
	AnyOf                []*Schema          `json:"anyOf"`
	OneOf                []*Schema          `json:"oneOf"`
	Not                  *Schema            `json:"not"`

	Description string `json:"description"`
	Format      string `json:"format"`
	Default     any    `json:"default"`

	Reference string `json:"$ref"`

	Name        string  `json:"-"`
	ReferenceTo *Schema `json:"-"`

	// Embedded validation fields
	asyncapi.Validations[Schema]

	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/v3.0.0#schemaObject

func NewSchema

func NewSchema() Schema

NewSchema creates a new Schema structure with initialized fields.

func (*Schema) Follow added in v0.33.5

func (s *Schema) Follow() *Schema

Follow returns referenced schema if specified or the actual schema.

func (Schema) IsFieldRequired

func (s Schema) IsFieldRequired(field string) bool

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

func (*Schema) MergeWith

func (s *Schema) MergeWith(spec Specification, s2 Schema) error

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

type SchemaType added in v0.35.1

type SchemaType string

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

const (
	// SchemaTypeIsArray represents the type of an array.
	SchemaTypeIsArray SchemaType = "array"
	// SchemaTypeIsObject represents the type of an object.
	SchemaTypeIsObject SchemaType = "object"
	// SchemaTypeIsString represents the type of a string.
	SchemaTypeIsString SchemaType = "string"
	// SchemaTypeIsInteger represents the type of an integer.
	SchemaTypeIsInteger SchemaType = "integer"
)

func (SchemaType) String added in v0.35.1

func (st SchemaType) String() string

String returns the string representation of the type.

type SecurityScheme

type SecurityScheme struct {
	Type             string     `json:"type"`
	Description      string     `json:"description"`
	Name             string     `json:"name"`
	In               string     `json:"in"`
	Scheme           string     `json:"scheme"`
	BearerFormat     string     `json:"bearerFormat"`
	Flows            OAuthFlows `json:"flows"`
	OpenIDConnectURL string     `json:"openIdConnectUrl"`
	Scopes           []string   `json:"scopes"`
	Reference        string     `json:"$ref"`

	ReferenceTo *SecurityScheme `json:"-"`
}

SecurityScheme 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/v3.0.0#securitySchemeObject

func RemoveDuplicateSecuritySchemes

func RemoveDuplicateSecuritySchemes(securities []*SecurityScheme) []*SecurityScheme

RemoveDuplicateSecuritySchemes removes the security schemes that have the same name, keeping the first occurrence.

type Server

type Server struct {
	Host            string                     `json:"host"`
	Protocol        string                     `json:"protocol"`
	ProtocolVersion string                     `json:"protocolVersion"`
	PathName        string                     `json:"pathname"`
	Description     string                     `json:"description"`
	Title           string                     `json:"title"`
	Summary         string                     `json:"summary"`
	Variables       map[string]*ServerVariable `json:"variables"`
	Security        *SecurityScheme            `json:"security"`
	Tags            []*Tag                     `json:"tags"`
	ExternalDocs    *ExternalDocumentation     `json:"externalDocs"`
	Bindings        *ServerBindings            `json:"bindings"`
	Reference       string                     `json:"$ref"`

	Name        string  `json:"-"`
	ReferenceTo *Server `json:"-"`
}

Server 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/v3.0.0#serverObject

type ServerBindings

type ServerBindings struct {
	HTTP         HTTPBinding         `json:"http"`
	WS           WsBinding           `json:"ws"`
	Kafka        KafkaBinding        `json:"kafka"`
	AnyPointMQ   AnyPointMqBinding   `json:"anypointmq"`
	AMQP         AMQPBinding         `json:"amqp"`
	AMQP1        AMQP1Binding        `json:"amqp1"`
	MQTT         MQTTBinding         `json:"mqtt"`
	MQTT5        MQTT5Binding        `json:"mqtt5"`
	NATS         NATSBinding         `json:"nats"`
	JMS          JMSBinding          `json:"jms"`
	SNS          SNSBinding          `json:"sns"`
	Solace       SolaceBinding       `json:"solace"`
	SQS          SQSBinding          `json:"sqs"`
	Stomp        StompBinding        `json:"stomp"`
	Redis        RedisBinding        `json:"redis"`
	Mercure      MercureBinding      `json:"mercure"`
	IBMMQ        IBMMQBinding        `json:"ibmmq"`
	GooglePubSub GooglePubSubBinding `json:"googlepubsub"`
	Pulsar       PulsarBinding       `json:"pulsar"`
	Reference    string              `json:"$ref"`

	Name        string          `json:"-"`
	ReferenceTo *ServerBindings `json:"-"`
}

ServerBindings 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/v3.0.0#serverBindingsObject

type ServerVariable

type ServerVariable struct {
	Enum        []string `json:"enum"`
	Default     string   `json:"default"`
	Description string   `json:"description"`
	Examples    []string `json:"examples"`
	Reference   string   `json:"$ref"`

	Name        string          `json:"-"`
	ReferenceTo *ServerVariable `json:"-"`
}

ServerVariable 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/v3.0.0#serverVariableObject

type SolaceBinding

type SolaceBinding any

SolaceBinding represents protocol-specific information for a Solace channel.

type Specification

type Specification struct {
	Version            string                `json:"asyncapi"`
	ID                 string                `json:"id"`
	Info               Info                  `json:"info"`
	Servers            map[string]*Server    `json:"servers"`
	DefaultContentType string                `json:"defaultContentType"`
	Channels           map[string]*Channel   `json:"channels"`
	Operations         map[string]*Operation `json:"operations"`
	Components         Components            `json:"components"`
	// contains filtered or unexported fields
}

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/v3.0.0#schema

func FromUnknownVersion added in v0.39.0

func FromUnknownVersion(s asyncapi.Specification) (*Specification, error)

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

func NewSpecification added in v0.39.0

func NewSpecification() *Specification

NewSpecification creates a new Specification struct.

func (*Specification) AddDependency added in v0.39.0

func (s *Specification) AddDependency(path string, spec asyncapi.Specification) error

AddDependency adds a specification dependency to the Specification.

func (Specification) CustomImports

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) GetOperationCountByAction

func (s Specification) GetOperationCountByAction() (sendCount, receiveCount uint)

GetOperationCountByAction gets the count of 'sending' operations and the count of 'reception' operations inside the Specification.

func (Specification) MajorVersion

func (s Specification) MajorVersion() int

MajorVersion returns the asyncapi major version of this document. This function is used mainly by the interface.

func (*Specification) Process

func (s *Specification) Process() error

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

func (Specification) ReferenceChannel

func (s Specification) ReferenceChannel(ref string) (*Channel, error)

ReferenceChannel returns the Channel struct corresponding to the given reference.

func (Specification) ReferenceChannelBindings

func (s Specification) ReferenceChannelBindings(ref string) (*ChannelBindings, error)

ReferenceChannelBindings returns the ChannelBindings struct corresponding to the given reference.

func (Specification) ReferenceExternalDocumentation

func (s Specification) ReferenceExternalDocumentation(ref string) (*ExternalDocumentation, error)

ReferenceExternalDocumentation returns the ExternalDocumentation struct corresponding to the given reference.

func (Specification) ReferenceMessage

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

ReferenceMessage returns the Message struct corresponding to the given reference.

func (Specification) ReferenceMessageBindings

func (s Specification) ReferenceMessageBindings(ref string) (*MessageBindings, error)

ReferenceMessageBindings returns the MessageBindings struct corresponding to the given reference.

func (Specification) ReferenceMessageExample

func (s Specification) ReferenceMessageExample(ref string) (*MessageExample, error)

ReferenceMessageExample returns the MessageExample struct corresponding to the given reference.

func (Specification) ReferenceMessageTrait

func (s Specification) ReferenceMessageTrait(ref string) (*MessageTrait, error)

ReferenceMessageTrait returns the MessageTrait struct corresponding to the given reference.

func (Specification) ReferenceOperation

func (s Specification) ReferenceOperation(ref string) (*Operation, error)

ReferenceOperation returns the Operation struct corresponding to the given reference.

func (Specification) ReferenceOperationBindings

func (s Specification) ReferenceOperationBindings(ref string) (*OperationBindings, error)

ReferenceOperationBindings returns the OperationBindings struct corresponding to the given reference.

func (Specification) ReferenceOperationReply

func (s Specification) ReferenceOperationReply(ref string) (*OperationReply, error)

ReferenceOperationReply returns the OperationReply struct corresponding to the given reference.

func (Specification) ReferenceOperationReplyAddress

func (s Specification) ReferenceOperationReplyAddress(ref string) (*OperationReplyAddress, error)

ReferenceOperationReplyAddress returns the OperationReplyAddress struct corresponding to the given reference.

func (Specification) ReferenceOperationTrait

func (s Specification) ReferenceOperationTrait(ref string) (*OperationTrait, error)

ReferenceOperationTrait returns the OperationTrait struct corresponding to the given reference.

func (Specification) ReferenceParameter

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

ReferenceParameter returns the Parameter struct corresponding to the given reference.

func (Specification) ReferenceSchema

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

ReferenceSchema returns the Schema struct corresponding to the given reference.

func (Specification) ReferenceSecurity

func (s Specification) ReferenceSecurity(ref string) (*SecurityScheme, error)

ReferenceSecurity returns the SecurityScheme struct corresponding to the given reference.

func (Specification) ReferenceServer

func (s Specification) ReferenceServer(ref string) (*Server, error)

ReferenceServer returns the Server struct corresponding to the given reference.

func (Specification) ReferenceServerBindings

func (s Specification) ReferenceServerBindings(ref string) (*ServerBindings, error)

ReferenceServerBindings returns the ServerBindings struct corresponding to the given reference.

func (Specification) ReferenceServerVariable

func (s Specification) ReferenceServerVariable(ref string) (*ServerVariable, error)

ReferenceServerVariable returns the ServerVariable struct corresponding to the given reference.

func (Specification) ReferenceTag

func (s Specification) ReferenceTag(ref string) (*Tag, error)

ReferenceTag returns the Tag struct corresponding to the given reference.

type StompBinding

type StompBinding any

StompBinding represents protocol-specific information for a STOMP channel.

type Tag

type Tag struct {
	Name         string                 `json:"name"`
	Description  string                 `json:"description"`
	ExternalDocs *ExternalDocumentation `json:"externalDocs"`
	Reference    string                 `json:"$ref"`

	ReferenceTo *Tag `json:"-"`
}

Tag 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/v3.0.0#tagsObject

func RemoveDuplicateTags

func RemoveDuplicateTags(tags []*Tag) []*Tag

RemoveDuplicateTags removes the tags that have the same name, keeping the first occurrence.

type WsBinding

type WsBinding any

WsBinding represents protocol-specific information for a WebSockets channel.

Jump to

Keyboard shortcuts

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