Documentation
¶
Index ¶
- Constants
- Variables
- type AMQP1Binding
- type AMQPBinding
- type AnyPointMqBinding
- type Channel
- type ChannelBindings
- type Components
- type Contact
- type CorrelationID
- type Extensions
- type ExternalDocumentation
- type GoTypeImportExtension
- type GoTypeImportName
- type GoTypeImportPath
- type GooglePubSubBinding
- type HTTPBinding
- type IBMMQBinding
- type Info
- type JMSBinding
- type KafkaBinding
- type License
- type MQTT5Binding
- type MQTTBinding
- type MercureBinding
- type Message
- type MessageBindings
- type MessageExample
- type MessageField
- type MessageTrait
- type NATSBinding
- type OAuthFlow
- type OAuthFlows
- type Operation
- type OperationAction
- type OperationBindings
- type OperationReply
- type OperationReplyAddress
- type OperationTrait
- type Parameter
- type PulsarBinding
- type RedisBinding
- type SNSBinding
- type SQSBinding
- type Schema
- func (s *Schema) Follow() *Schema
- func (s Schema) GetAdditionalProperties() *Schema
- func (s Schema) GetIsRequired() bool
- func (s Schema) GetItems() *Schema
- func (s Schema) GetProperties() map[string]*Schema
- func (s Schema) GetType() string
- func (s Schema) IsFieldRequired(field string) bool
- func (s *Schema) MergeWith(spec Specification, s2 Schema) error
- type SchemaType
- type SecurityScheme
- type SecuritySchemeType
- type Server
- type ServerBindings
- type ServerVariable
- type SolaceBinding
- type Specification
- func (s *Specification) AddDependency(path string, spec asyncapi.Specification) error
- func (s Specification) CustomImports() ([]string, error)
- func (s Specification) GetOperationCountByAction() (sendCount, receiveCount uint)
- func (s Specification) MajorVersion() int
- func (s *Specification) Process() error
- func (s Specification) ReferenceChannel(ref string) (*Channel, error)
- func (s Specification) ReferenceChannelBindings(ref string) (*ChannelBindings, error)
- func (s Specification) ReferenceExternalDocumentation(ref string) (*ExternalDocumentation, error)
- func (s Specification) ReferenceMessage(ref string) (*Message, error)
- func (s Specification) ReferenceMessageBindings(ref string) (*MessageBindings, error)
- func (s Specification) ReferenceMessageExample(ref string) (*MessageExample, error)
- func (s Specification) ReferenceMessageTrait(ref string) (*MessageTrait, error)
- func (s Specification) ReferenceOperation(ref string) (*Operation, error)
- func (s Specification) ReferenceOperationBindings(ref string) (*OperationBindings, error)
- func (s Specification) ReferenceOperationReply(ref string) (*OperationReply, error)
- func (s Specification) ReferenceOperationReplyAddress(ref string) (*OperationReplyAddress, error)
- func (s Specification) ReferenceOperationTrait(ref string) (*OperationTrait, error)
- func (s Specification) ReferenceParameter(ref string) (*Parameter, error)
- func (s Specification) ReferenceSchema(ref string) (*Schema, error)
- func (s Specification) ReferenceSecurity(ref string) (*SecurityScheme, error)
- func (s Specification) ReferenceServer(ref string) (*Server, error)
- func (s Specification) ReferenceServerBindings(ref string) (*ServerBindings, error)
- func (s Specification) ReferenceServerVariable(ref string) (*ServerVariable, error)
- func (s Specification) ReferenceTag(ref string) (*Tag, error)
- type StompBinding
- type Tag
- type WsBinding
Constants ¶
const ( // MessageHeadersSuffix is the suffix for the headers schema name. MessageHeadersSuffix = "Headers" // MessagePayloadSuffix is the suffix for the payload schema name. MessagePayloadSuffix = "Payload" )
const (
// BindingsSuffix is the suffix added to the bindings name.
BindingsSuffix = "Bindings"
)
const (
// ChannelSuffix is the suffix added to the channels name.
ChannelSuffix = "Channel"
)
const (
// ExternalDocsNameSuffix is the suffix that is added to the name of external docs.
ExternalDocsNameSuffix = "External_Docs"
)
const (
// MajorVersion is the major version of this AsyncAPI implementation.
MajorVersion = 3
)
Variables ¶
var ( // ErrInvalidReference is sent when a reference is invalid. ErrInvalidReference = fmt.Errorf("%w: invalid reference", extensions.ErrAsyncAPI) )
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 {
// NOTE: the JSON null literal is a valid value for address, which cannot be parsed as a Go string
// Solutions are to change to a *string (a breaking change) or use a wrapper type like sql.NullString
Address string `json:"address,omitempty"`
Messages map[string]*Message `json:"messages,omitempty"`
Title string `json:"title,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Servers []*Server `json:"servers,omitempty"` // Reference only
Parameters map[string]*Parameter `json:"parameters,omitempty"`
Tags []*Tag `json:"tags,omitempty"`
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
Bindings *ChannelBindings `json:"bindings,omitempty"`
Reference string `json:"$ref,omitempty"`
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) GetMessage ¶
GetMessage will return the channel message.
type ChannelBindings ¶
type ChannelBindings struct {
HTTP HTTPBinding `json:"http,omitzero"`
WS WsBinding `json:"ws,omitzero"`
Kafka KafkaBinding `json:"kafka,omitzero"`
AnyPointMQ AnyPointMqBinding `json:"anypointmq,omitzero"`
AMQP AMQPBinding `json:"amqp,omitzero"`
AMQP1 AMQP1Binding `json:"amqp1,omitzero"`
MQTT MQTTBinding `json:"mqtt,omitzero"`
MQTT5 MQTT5Binding `json:"mqtt5,omitzero"`
NATS NATSBinding `json:"nats,omitzero"`
JMS JMSBinding `json:"jms,omitzero"`
SNS SNSBinding `json:"sns,omitzero"`
Solace SolaceBinding `json:"solace,omitzero"`
SQS SQSBinding `json:"sqs,omitzero"`
Stomp StompBinding `json:"stomp,omitzero"`
Redis RedisBinding `json:"redis,omitzero"`
Mercure MercureBinding `json:"mercure,omitzero"`
IBMMQ IBMMQBinding `json:"ibmmq,omitzero"`
GooglePubSub GooglePubSubBinding `json:"googlepubsub,omitzero"`
Pulsar PulsarBinding `json:"pulsar,omitzero"`
Reference string `json:"$ref,omitempty"`
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,omitempty"`
Servers map[string]*Server `json:"servers,omitempty"`
Channels map[string]*Channel `json:"channels,omitempty"`
Operations map[string]*Operation `json:"operations,omitempty"`
Messages map[string]*Message `json:"messages,omitempty"`
SecuritySchemes map[string]*SecurityScheme `json:"securitySchemes,omitempty"`
ServerVariables map[string]*ServerVariable `json:"serverVariables,omitempty"`
Parameters map[string]*Parameter `json:"parameters,omitempty"`
CorrelationIDs map[string]*CorrelationID `json:"correlationIds,omitempty"`
Replies map[string]*OperationReply `json:"replies,omitempty"`
ReplyAddresses map[string]*OperationReplyAddress `json:"replyAddresses,omitempty"`
ExternalDocs map[string]*ExternalDocumentation `json:"externalDocs,omitempty"`
Tags map[string]*Tag `json:"tags,omitempty"`
OperationTraits map[string]*OperationTrait `json:"operationTraits,omitempty"`
MessageTraits map[string]*MessageTrait `json:"messageTraits,omitempty"`
ServerBindings map[string]*ServerBindings `json:"serverBindings,omitempty"`
ChannelBindings map[string]*ChannelBindings `json:"channelBindings,omitempty"`
OperationBindings map[string]*OperationBindings `json:"operationBindings,omitempty"`
MessageBindings map[string]*MessageBindings `json:"messageBindings,omitempty"`
}
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,omitempty"`
URL string `json:"url,omitempty"`
Email string `json:"email,omitempty"`
}
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,omitempty"`
Location string `json:"location,omitempty"`
Reference string `json:"$ref,omitempty"`
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,omitempty"`
// Setting custom import statements for ExtGoType
ExtGoTypeImport *GoTypeImportExtension `json:"x-go-type-import,omitempty"`
// Controls whether to include omitempty in JSON tags
// If false, omitempty will be removed from JSON tags even if the field can be null
ExtOmitEmpty *bool `json:"x-omitempty,omitempty"`
}
Extensions holds additional properties defined for asyncapi-codegen that are out of the AsyncAPI spec.
type ExternalDocumentation ¶
type ExternalDocumentation struct {
Description string `json:"description,omitempty"`
URL string `json:"url"`
Reference string `json:"$ref,omitempty"`
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,omitempty"`
TermsOfService string `json:"termsOfService,omitempty"`
Contact *Contact `json:"contact,omitempty"`
License *License `json:"license,omitempty"`
Tags []*Tag `json:"tags,omitempty"`
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
}
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 ¶
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,omitempty"`
Payload *Schema `json:"payload,omitempty"`
OneOf []*Message `json:"oneOf,omitempty"`
CorrelationID *CorrelationID `json:"correlationID,omitempty"`
ContentType string `json:"contentType,omitempty"`
Name string `json:"name,omitempty"`
Title string `json:"title,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Tags []*Tag `json:"tags,omitempty"`
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
Bindings *MessageBindings `json:"bindings,omitempty"`
Examples []*MessageExample `json:"examples,omitempty"`
Traits []*MessageTrait `json:"traits,omitempty"`
Reference string `json:"$ref,omitempty"`
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) HaveCorrelationID ¶ added in v0.33.0
HaveCorrelationID check that the message have a correlation ID.
type MessageBindings ¶
type MessageBindings struct {
HTTP HTTPBinding `json:"http,omitzero"`
WS WsBinding `json:"ws,omitzero"`
Kafka KafkaBinding `json:"kafka,omitzero"`
AnyPointMQ AnyPointMqBinding `json:"anypointmq,omitzero"`
AMQP AMQPBinding `json:"amqp,omitzero"`
AMQP1 AMQP1Binding `json:"amqp1,omitzero"`
MQTT MQTTBinding `json:"mqtt,omitzero"`
MQTT5 MQTT5Binding `json:"mqtt5,omitzero"`
NATS NATSBinding `json:"nats,omitzero"`
JMS JMSBinding `json:"jms,omitzero"`
SNS SNSBinding `json:"sns,omitzero"`
Solace SolaceBinding `json:"solace,omitzero"`
SQS SQSBinding `json:"sqs,omitzero"`
Stomp StompBinding `json:"stomp,omitzero"`
Redis RedisBinding `json:"redis,omitzero"`
Mercure MercureBinding `json:"mercure,omitzero"`
IBMMQ IBMMQBinding `json:"ibmmq,omitzero"`
GooglePubSub GooglePubSubBinding `json:"googlepubsub,omitzero"`
Pulsar PulsarBinding `json:"pulsar,omitzero"`
Reference string `json:"$ref,omitempty"`
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,omitempty"`
Payload any `json:"payload,omitempty"`
Name string `json:"name,omitempty"`
Summary string `json:"summary,omitempty"`
Reference string `json:"$ref,omitempty"`
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,omitempty"`
// NOTE: "payload" is explicitly disallowed by the AsyncAPI spec:
// https://github.com/asyncapi/spec/blob/c5888f52b70f8eb99f782df9d23a88e1a4dce112/spec/asyncapi.md?plain=1#L1414
Payload *Schema `json:"payload,omitempty"`
CorrelationID *CorrelationID `json:"correlationID,omitempty"`
ContentType string `json:"contentType,omitempty"`
Name string `json:"name,omitempty"`
Title string `json:"title,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Tags []*Tag `json:"tags,omitempty"`
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
Bindings *MessageBindings `json:"bindings,omitempty"`
Examples []*MessageExample `json:"examples,omitempty"`
Reference string `json:"$ref,omitempty"`
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,omitempty"`
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,omitzero"`
Password OAuthFlow `json:"password,omitzero"`
ClientCredentials OAuthFlow `json:"clientCredential,omitzero"`
AuthorizationCode OAuthFlow `json:"authorizationCode,omitzero"`
}
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,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Security []*SecurityScheme `json:"security,omitempty"`
Tags []*Tag `json:"tags,omitempty"`
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
Bindings *OperationBindings `json:"bindings,omitempty"`
Traits []*OperationTrait `json:"traits,omitempty"`
Messages []*Message `json:"messages,omitzero"` // References only
Reply *OperationReply `json:"reply,omitempty"`
Reference string `json:"$ref,omitempty"`
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
NOTE: From the AsyncAPI specification on the "messages" field:
Excluding this property from the Operation implies that all messages from the channel will be included. Explicitly set the messages property to [] if this operation should contain no messages.
Because of this caveat, it must be possible to both serialize the messages slice as an empty JSON array or exclude the key entirely. The omitzero tag is required to enable this.
func (*Operation) ApplyTrait ¶
func (op *Operation) ApplyTrait(ot *OperationTrait, spec Specification)
ApplyTrait applies a trait to the operation.
func (*Operation) Follow ¶
Follow returns referenced operation if specified or the actual operation.
func (Operation) GetMessage ¶
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,omitzero"`
WS WsBinding `json:"ws,omitzero"`
Kafka KafkaBinding `json:"kafka,omitzero"`
AnyPointMQ AnyPointMqBinding `json:"anypointmq,omitzero"`
AMQP AMQPBinding `json:"amqp,omitzero"`
AMQP1 AMQP1Binding `json:"amqp1,omitzero"`
MQTT MQTTBinding `json:"mqtt,omitzero"`
MQTT5 MQTT5Binding `json:"mqtt5,omitzero"`
NATS NATSBinding `json:"nats,omitzero"`
JMS JMSBinding `json:"jms,omitzero"`
SNS SNSBinding `json:"sns,omitzero"`
Solace SolaceBinding `json:"solace,omitzero"`
SQS SQSBinding `json:"sqs,omitzero"`
Stomp StompBinding `json:"stomp,omitzero"`
Redis RedisBinding `json:"redis,omitzero"`
Mercure MercureBinding `json:"mercure,omitzero"`
IBMMQ IBMMQBinding `json:"ibmmq,omitzero"`
GooglePubSub GooglePubSubBinding `json:"googlepubsub,omitzero"`
Pulsar PulsarBinding `json:"pulsar,omitzero"`
Reference string `json:"$ref,omitempty"`
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,omitempty"`
Channel *Channel `json:"channel,omitempty"` // Reference only
Messages []*Message `json:"messages,omitempty"` // References only
Reference string `json:"$ref,omitempty"`
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,omitempty"`
Location string `json:"location"`
Reference string `json:"$ref,omitempty"`
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,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Security []*SecurityScheme `json:"security,omitempty"`
Tags []*Tag `json:"tags,omitempty"`
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
Bindings *OperationBindings `json:"bindings,omitempty"`
Reference string `json:"$ref,omitempty"`
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,omitempty"`
Default string `json:"default,omitempty"`
Description string `json:"description,omitempty"`
Examples []string `json:"examples,omitempty"`
Location string `json:"location,omitempty"`
Reference string `json:"$ref,omitempty"`
// 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,omitempty"`
Type string `json:"type,omitempty"`
Examples []any `json:"examples,omitempty"`
ReadOnly bool `json:"readOnly,omitempty"`
WriteOnly bool `json:"writeOnly,omitempty"`
Properties map[string]*Schema `json:"properties,omitempty"`
PatternProperties map[string]*Schema `json:"patternProperties,omitempty"`
AdditionalProperties *Schema `json:"additionalProperties,omitempty"`
AdditionalItems []*Schema `json:"additionalItems,omitempty"`
Items *Schema `json:"items,omitempty"`
PropertyNames []string `json:"propertyNames,omitempty"`
Contains []*Schema `json:"contains,omitempty"`
AllOf []*Schema `json:"allOf,omitempty"`
AnyOf []*Schema `json:"anyOf,omitempty"`
OneOf []*Schema `json:"oneOf,omitempty"`
Not *Schema `json:"not,omitempty"`
Description string `json:"description,omitempty"`
Format string `json:"format,omitempty"`
Default any `json:"default,omitempty"`
Reference string `json:"$ref,omitempty"`
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
Follow returns referenced schema if specified or the actual schema.
func (Schema) GetAdditionalProperties ¶ added in v0.46.5
GetAdditionalProperties returns the schema additional properties.
func (Schema) GetIsRequired ¶ added in v0.46.5
GetIsRequired returns whether the schema itself is required.
func (Schema) GetProperties ¶ added in v0.46.5
GetProperties returns the schema properties.
func (Schema) IsFieldRequired ¶
IsFieldRequired checks if a field is required in the asyncapi struct.
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,omitempty"`
Name string `json:"name,omitempty"`
In string `json:"in,omitempty"`
Scheme string `json:"scheme,omitempty"`
BearerFormat string `json:"bearerFormat,omitempty"`
Flows OAuthFlows `json:"flows,omitzero"`
OpenIDConnectURL string `json:"openIdConnectUrl,omitempty"`
Scopes []string `json:"scopes,omitempty"`
Reference string `json:"$ref,omitempty"`
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 SecuritySchemeType ¶ added in v0.46.5
type SecuritySchemeType string
SecuritySchemeType is type of a security scheme.
const ( SecuritySchemeUserPassword SecuritySchemeType = "userPassword" SecuritySchemeAPIKey SecuritySchemeType = "apiKey" SecuritySchemeX509 SecuritySchemeType = "X509" SecuritySchemeSymmetricEncryption SecuritySchemeType = "symmetricEncryption" SecuritySchemeASymmetricEncryption SecuritySchemeType = "asymmetricEncryption" SecuritySchemeHTTPAPIKey SecuritySchemeType = "httpApiKey" SecuritySchemeHTTP SecuritySchemeType = "http" SecuritySchemeOAuth2 SecuritySchemeType = "oauth2" SecuritySchemeOpenIDConnect SecuritySchemeType = "openIdConnect" SecuritySchemePlain SecuritySchemeType = "plain" SecuritySchemeScramSha256 SecuritySchemeType = "scramSha256" SecuritySchemeScramSha512 SecuritySchemeType = "scramSha512" SecuritySchemeGSSAPI SecuritySchemeType = "gssapi" )
Security scheme types supported by the AsyncAPI specification. Source: https://www.asyncapi.com/docs/reference/specification/v3.0.0#securitySchemeObject
type Server ¶
type Server struct {
Host string `json:"host"`
Protocol string `json:"protocol"`
ProtocolVersion string `json:"protocolVersion,omitempty"`
PathName string `json:"pathname,omitempty"`
Description string `json:"description,omitempty"`
Title string `json:"title,omitempty"`
Summary string `json:"summary,omitempty"`
Variables map[string]*ServerVariable `json:"variables,omitempty"`
Security []*SecurityScheme `json:"security,omitempty"`
Tags []*Tag `json:"tags,omitempty"`
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
Bindings *ServerBindings `json:"bindings,omitempty"`
Reference string `json:"$ref,omitempty"`
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,omitzero"`
WS WsBinding `json:"ws,omitzero"`
Kafka KafkaBinding `json:"kafka,omitzero"`
AnyPointMQ AnyPointMqBinding `json:"anypointmq,omitzero"`
AMQP AMQPBinding `json:"amqp,omitzero"`
AMQP1 AMQP1Binding `json:"amqp1,omitzero"`
MQTT MQTTBinding `json:"mqtt,omitzero"`
MQTT5 MQTT5Binding `json:"mqtt5,omitzero"`
NATS NATSBinding `json:"nats,omitzero"`
JMS JMSBinding `json:"jms,omitzero"`
SNS SNSBinding `json:"sns,omitzero"`
Solace SolaceBinding `json:"solace,omitzero"`
SQS SQSBinding `json:"sqs,omitzero"`
Stomp StompBinding `json:"stomp,omitzero"`
Redis RedisBinding `json:"redis,omitzero"`
Mercure MercureBinding `json:"mercure,omitzero"`
IBMMQ IBMMQBinding `json:"ibmmq,omitzero"`
GooglePubSub GooglePubSubBinding `json:"googlepubsub,omitzero"`
Pulsar PulsarBinding `json:"pulsar,omitzero"`
Reference string `json:"$ref,omitempty"`
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,omitempty"`
Default string `json:"default,omitempty"`
Description string `json:"description,omitempty"`
Examples []string `json:"examples,omitempty"`
Reference string `json:"$ref,omitempty"`
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,omitempty"`
Info Info `json:"info"`
Servers map[string]*Server `json:"servers,omitempty"`
DefaultContentType string `json:"defaultContentType,omitempty"`
Channels map[string]*Channel `json:"channels,omitempty"`
Operations map[string]*Operation `json:"operations,omitempty"`
Components Components `json:"components,omitzero"`
// 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,omitempty"`
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
Reference string `json:"$ref,omitempty"`
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 ¶
RemoveDuplicateTags removes the tags that have the same name, keeping the first occurrence.
Source Files
¶
- bindings.go
- channel.go
- channel_bindings.go
- components.go
- contact.go
- correlation_id.go
- extensions.go
- external_documentation.go
- info.go
- license.go
- message.go
- message_bindings.go
- message_example.go
- message_trait.go
- operation.go
- operation_bindings.go
- operation_reply.go
- operation_reply_address.go
- operation_trait.go
- parameter.go
- schema.go
- security_scheme.go
- server.go
- server_bindings.go
- server_variable.go
- specification.go
- tag.go
- utils.go