Documentation ¶
Overview ¶
Package spec parses and writes AsyncAPIv2 specification documents.
Does not cover all elements of AsyncAPIv2.
See https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md
Index ¶
- Variables
- func ValidateIdentifier(value string) error
- type Channel
- type ChannelBindings
- type ChannelBindingsRef
- type ChannelRef
- type Channels
- type ChannelsBindings
- type Components
- type CorrelationID
- type CorrelationIDRef
- type CorrelationIDs
- type Message
- type MessageBindings
- type MessageBindingsRef
- type MessageOneOf
- type MessageRef
- type MessageTrait
- type MessageTraitRef
- type Messages
- type MessagesBindings
- type MessagesTraits
- type OAuthFlowObject
- type OAuthFlows
- type Operation
- type OperationBindings
- type OperationBindingsRef
- type OperationRef
- type OperationTrait
- type OperationTraitRef
- type OperationsBindings
- type OperationsTraits
- type Parameter
- type ParameterRef
- type Parameters
- type ParametersRefs
- type Ref
- type RefG
- type SecurityRequirements
- type SecurityScheme
- type SecuritySchemes
- type Server
- type ServerBindings
- type ServerBindingsRef
- type ServerVariable
- type Servers
- type ServersBindings
- type T
Constants ¶
This section is empty.
Variables ¶
var (
ErrServerKeyInvalid = fmt.Errorf("server should match pattern %q", serverKeyRegexp.String())
)
var (
ErrUnresolvedRef = errors.New("found unresolved ref")
)
var IdentifierRegExp = regexp.MustCompile(identifierPattern)
IdentifierRegExp verifies whether Component object key matches 'identifierPattern' pattern, according to OpenAPI v3.x.0. However, to be able supporting legacy OpenAPI v2.x, there is a need to customize above pattern in order not to fail converted v2-v3 validation
Functions ¶
func ValidateIdentifier ¶
Types ¶
type Channel ¶
type Channel struct { Extensions map[string]interface{} `json:"-" yaml:"-"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Subscribe *OperationRef `json:"subscribe,omitempty" yaml:"subscribe,omitempty"` Publish *OperationRef `json:"publish,omitempty" yaml:"publish,omitempty"` Parameters ParametersRefs `json:"parameters,omitempty" yaml:"parameters,omitempty"` Bindings *ChannelBindingsRef `json:"bindings,omitempty" yaml:"bindings,omitempty"` }
Channel is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#channel-item-object
func (*Channel) MarshalJSON ¶
func (*Channel) UnmarshalJSON ¶
type ChannelBindings ¶
type ChannelBindings struct { Extensions map[string]interface{} `json:"-" yaml:"-"` Http *bindings.HttpChannel `json:"http,omitempty" yaml:"http,omitempty"` Ws *bindings.WsChannel `json:"ws,omitempty" yaml:"ws,omitempty"` Kafka *bindings.KafkaChannel `json:"kafka,omitempty" yaml:"kafka,omitempty"` Amqp interface{} `json:"amqp,omitempty" yaml:"amqp,omitempty"` Amqp1 interface{} `json:"amqp1,omitempty" yaml:"amqp1,omitempty"` Mqtt interface{} `json:"mqtt,omitempty" yaml:"mqtt,omitempty"` Mqtt5 interface{} `json:"mqtt5,omitempty" yaml:"mqtt5,omitempty"` Nats interface{} `json:"nats,omitempty" yaml:"nats,omitempty"` Jms interface{} `json:"jms,omitempty" yaml:"jms,omitempty"` Sns interface{} `json:"sns,omitempty" yaml:"sns,omitempty"` Sqs interface{} `json:"sqs,omitempty" yaml:"sqs,omitempty"` Stomp interface{} `json:"stomp,omitempty" yaml:"stomp,omitempty"` Redis interface{} `json:"redis,omitempty" yaml:"redis,omitempty"` }
ChannelBindings is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#channel-bindings-object
func (*ChannelBindings) MarshalJSON ¶
func (value *ChannelBindings) MarshalJSON() ([]byte, error)
func (*ChannelBindings) UnmarshalJSON ¶
func (value *ChannelBindings) UnmarshalJSON(data []byte) error
type ChannelBindingsRef ¶
type ChannelBindingsRef = RefG[*ChannelBindings]
type ChannelRef ¶
type Channels ¶
Channels is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#channels-object
type ChannelsBindings ¶
type ChannelsBindings map[string]*ChannelBindings
type Components ¶
type Components struct { Extensions map[string]interface{} `json:"-" yaml:"-"` Schemas openapi3.Schemas `json:"schemas,omitempty" yaml:"schemas,omitempty"` Messages Messages `json:"messages,omitempty" yaml:"messages,omitempty"` SecuritySchemes SecuritySchemes `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"` Parameters Parameters `json:"parameters,omitempty" yaml:"parameters,omitempty"` CorrelationIds CorrelationIDs `json:"correlationIds,omitempty" yaml:"correlationIds,omitempty"` OperationTraits OperationsTraits `json:"operationTraits,omitempty" yaml:"operationTraits,omitempty"` MessageTraits MessagesTraits `json:"messageTraits,omitempty" yaml:"messageTraits,omitempty"` ServerBindings ServersBindings `json:"serverBindings,omitempty" yaml:"serverBindings,omitempty"` ChannelBindings ChannelsBindings `json:"channelBindings,omitempty" yaml:"channelBindings,omitempty"` OperationBindings OperationsBindings `json:"operationBindings,omitempty" yaml:"operationBindings,omitempty"` MessageBindings MessagesBindings `json:"messageBindings,omitempty" yaml:"messageBindings,omitempty"` }
Components scheme is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#componentsObject
func (*Components) MarshalJSON ¶
func (components *Components) MarshalJSON() ([]byte, error)
func (*Components) UnmarshalJSON ¶
func (components *Components) UnmarshalJSON(data []byte) error
type CorrelationID ¶
type CorrelationID struct { Extensions map[string]interface{} `json:"-" yaml:"-"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Location string `json:"location" yaml:"location"` }
CorrelationID is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#correlationIdObject
func (*CorrelationID) MarshalJSON ¶
func (value *CorrelationID) MarshalJSON() ([]byte, error)
func (*CorrelationID) UnmarshalJSON ¶
func (value *CorrelationID) UnmarshalJSON(data []byte) error
type CorrelationIDRef ¶
type CorrelationIDRef = RefG[*CorrelationID]
type CorrelationIDs ¶
type CorrelationIDs map[string]*CorrelationID
type Message ¶
type Message struct { MessageTrait Payload *openapi3.SchemaRef `json:"payload,omitempty" yaml:"payload,omitempty"` Traits []*MessageTraitRef `json:"traits,omitempty" yaml:"traits,omitempty"` }
Message is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#message-object
func (*Message) MarshalJSON ¶
func (*Message) UnmarshalJSON ¶
type MessageBindings ¶
type MessageBindings struct { Extensions map[string]interface{} `json:"-" yaml:"-"` Http *bindings.HttpMessage `json:"http,omitempty" yaml:"http,omitempty"` Ws *bindings.WsMessage `json:"ws,omitempty" yaml:"ws,omitempty"` Kafka *bindings.KafkaMessage `json:"kafka,omitempty" yaml:"kafka,omitempty"` Amqp interface{} `json:"amqp,omitempty" yaml:"amqp,omitempty"` Amqp1 interface{} `json:"amqp1,omitempty" yaml:"amqp1,omitempty"` Mqtt interface{} `json:"mqtt,omitempty" yaml:"mqtt,omitempty"` Mqtt5 interface{} `json:"mqtt5,omitempty" yaml:"mqtt5,omitempty"` Nats interface{} `json:"nats,omitempty" yaml:"nats,omitempty"` Jms interface{} `json:"jms,omitempty" yaml:"jms,omitempty"` Sns interface{} `json:"sns,omitempty" yaml:"sns,omitempty"` Sqs interface{} `json:"sqs,omitempty" yaml:"sqs,omitempty"` Stomp interface{} `json:"stomp,omitempty" yaml:"stomp,omitempty"` Redis interface{} `json:"redis,omitempty" yaml:"redis,omitempty"` }
MessageBindings is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#message-bindings-object
func (*MessageBindings) MarshalJSON ¶
func (value *MessageBindings) MarshalJSON() ([]byte, error)
func (*MessageBindings) UnmarshalJSON ¶
func (value *MessageBindings) UnmarshalJSON(data []byte) error
type MessageBindingsRef ¶
type MessageBindingsRef = RefG[*MessageBindings]
type MessageOneOf ¶
type MessageOneOf struct { MessageRef OneOf []*MessageRef }
func (*MessageOneOf) MarshalJSON ¶
func (value *MessageOneOf) MarshalJSON() ([]byte, error)
func (*MessageOneOf) UnmarshalJSON ¶
func (value *MessageOneOf) UnmarshalJSON(data []byte) error
type MessageRef ¶
type MessageTrait ¶
type MessageTrait struct { Extensions map[string]interface{} `json:"-" yaml:"-"` Headers *openapi3.SchemaRef `json:"headers,omitempty" yaml:"headers,omitempty"` CorrelationID *CorrelationIDRef `json:"correlationId,omitempty" yaml:"correlationId,omitempty"` SchemaFormat string `json:"schemaFormat,omitempty" yaml:"schemaFormat,omitempty"` ContentType string `json:"contentType,omitempty" yaml:"contentType,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` Title string `json:"title,omitempty" yaml:"title,omitempty"` Summary string `json:"summary,omitempty" yaml:"summary,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Tags openapi3.Tags `json:"tags,omitempty" yaml:"tags,omitempty"` ExternalDocs *openapi3.ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` Bindings *MessageBindings `json:"bindings,omitempty" yaml:"bindings,omitempty"` Examples []map[string]interface{} `json:"examples,omitempty" yaml:"examples,omitempty"` }
MessageTrait is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#message-trait-object
func (*MessageTrait) MarshalJSON ¶
func (value *MessageTrait) MarshalJSON() ([]byte, error)
func (*MessageTrait) UnmarshalJSON ¶
func (value *MessageTrait) UnmarshalJSON(data []byte) error
type MessageTraitRef ¶
type MessageTraitRef = RefG[*MessageTrait]
type MessagesBindings ¶
type MessagesBindings map[string]*MessageBindings
type MessagesTraits ¶
type MessagesTraits map[string]*MessageTrait
type OAuthFlowObject ¶
type OAuthFlowObject struct { Extensions map[string]interface{} `json:"-" yaml:"-"` AuthorizationUrl string `json:"authorizationUrl,omitempty" yaml:"authorizationUrl,omitempty"` TokenUrl string `json:"tokenUrl,omitempty" yaml:"tokenUrl,omitempty"` RefreshUrl string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty"` Scopes map[string]string `json:"scopes" yaml:"scopes"` }
OAuthFlowObject is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#oauth-flow-object
func (*OAuthFlowObject) MarshalJSON ¶
func (value *OAuthFlowObject) MarshalJSON() ([]byte, error)
func (*OAuthFlowObject) UnmarshalJSON ¶
func (value *OAuthFlowObject) UnmarshalJSON(data []byte) error
type OAuthFlows ¶
type OAuthFlows struct { Extensions map[string]interface{} `json:"-" yaml:"-"` Implicit *OAuthFlowObject `json:"implicit,omitempty" yaml:"implicit,omitempty"` Password *OAuthFlowObject `json:"password,omitempty" yaml:"password,omitempty"` ClientCredentials *OAuthFlowObject `json:"clientCredentials,omitempty" yaml:"clientCredentials,omitempty"` AuthorizationCode *OAuthFlowObject `json:"authorizationCode,omitempty" yaml:"authorizationCode,omitempty"` }
OAuthFlows is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#oauthFlowsObject
func (*OAuthFlows) MarshalJSON ¶
func (value *OAuthFlows) MarshalJSON() ([]byte, error)
func (*OAuthFlows) UnmarshalJSON ¶
func (value *OAuthFlows) UnmarshalJSON(data []byte) error
type Operation ¶
type Operation struct { OperationTrait Traits []*OperationTraitRef `json:"traits,omitempty" yaml:"traits,omitempty"` Message *MessageOneOf `json:"message,omitempty" yaml:"message,omitempty"` }
Operation is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#operation-object
func (*Operation) MarshalJSON ¶
func (*Operation) UnmarshalJSON ¶
type OperationBindings ¶
type OperationBindings struct { Extensions map[string]interface{} `json:"-" yaml:"-"` Http *bindings.HttpOperation `json:"http,omitempty" yaml:"http,omitempty"` Ws *bindings.WsOperation `json:"ws,omitempty" yaml:"ws,omitempty"` Kafka *bindings.KafkaOperation `json:"kafka,omitempty" yaml:"kafka,omitempty"` Amqp interface{} `json:"amqp,omitempty" yaml:"amqp,omitempty"` Amqp1 interface{} `json:"amqp1,omitempty" yaml:"amqp1,omitempty"` Mqtt interface{} `json:"mqtt,omitempty" yaml:"mqtt,omitempty"` Mqtt5 interface{} `json:"mqtt5,omitempty" yaml:"mqtt5,omitempty"` Nats interface{} `json:"nats,omitempty" yaml:"nats,omitempty"` Jms interface{} `json:"jms,omitempty" yaml:"jms,omitempty"` Sns interface{} `json:"sns,omitempty" yaml:"sns,omitempty"` Sqs interface{} `json:"sqs,omitempty" yaml:"sqs,omitempty"` Stomp interface{} `json:"stomp,omitempty" yaml:"stomp,omitempty"` Redis interface{} `json:"redis,omitempty" yaml:"redis,omitempty"` }
OperationBindings is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#operation-bindings-object
func (*OperationBindings) MarshalJSON ¶
func (value *OperationBindings) MarshalJSON() ([]byte, error)
func (*OperationBindings) UnmarshalJSON ¶
func (value *OperationBindings) UnmarshalJSON(data []byte) error
type OperationBindingsRef ¶
type OperationBindingsRef = RefG[*OperationBindings]
type OperationRef ¶
type OperationTrait ¶
type OperationTrait struct { Extensions map[string]interface{} `json:"-" yaml:"-"` OperationID string `json:"operationId,omitempty" yaml:"operationId,omitempty"` Summary string `json:"summary,omitempty" yaml:"summary,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Tags openapi3.Tags `json:"tags,omitempty" yaml:"tags,omitempty"` ExternalDocs *openapi3.ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` Bindings *OperationBindings `json:"bindings,omitempty" yaml:"bindings,omitempty"` }
OperationTrait is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#operationTraitObject
func (*OperationTrait) MarshalJSON ¶
func (value *OperationTrait) MarshalJSON() ([]byte, error)
func (*OperationTrait) UnmarshalJSON ¶
func (value *OperationTrait) UnmarshalJSON(data []byte) error
type OperationTraitRef ¶
type OperationTraitRef = RefG[*OperationTrait]
type OperationsBindings ¶
type OperationsBindings map[string]*OperationBindings
type OperationsTraits ¶
type OperationsTraits map[string]*OperationTrait
type Parameter ¶
type Parameter struct { Extensions map[string]interface{} `json:"-" yaml:"-"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Schema *openapi3.Schema `json:"schema,omitempty" yaml:"schema,omitempty"` Location string `json:"location,omitempty" yaml:"location,omitempty"` }
Parameter is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#parameterObject
func (*Parameter) MarshalJSON ¶
func (*Parameter) UnmarshalJSON ¶
type ParameterRef ¶
type Parameters ¶
type ParametersRefs ¶
type ParametersRefs map[string]*ParameterRef
ParametersRefs is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#parameters-object
type RefG ¶
type RefG[V interface { comparable json.Marshaler json.Unmarshaler Validate(ctx context.Context) error }] struct { Ref string Value V }
func (*RefG[V]) MarshalJSON ¶
func (*RefG[V]) UnmarshalJSON ¶
type SecurityRequirements ¶
SecurityRequirements is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#securityRequirementObject
type SecurityScheme ¶
type SecurityScheme struct { Extensions map[string]interface{} `json:"-" yaml:"-"` Type string `json:"type" yaml:"type"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` In string `json:"in,omitempty" yaml:"in,omitempty"` Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"` BearerFormat string `json:"bearerFormat,omitempty" yaml:"bearerFormat,omitempty"` Flows *OAuthFlows `json:"flows,omitempty" yaml:"flows,omitempty"` OpenIDConnectUrl string `json:"openIdConnectUrl,omitempty" yaml:"openIdConnectUrl,omitempty"` }
SecurityScheme is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#security-scheme-object
func (*SecurityScheme) MarshalJSON ¶
func (value *SecurityScheme) MarshalJSON() ([]byte, error)
func (*SecurityScheme) UnmarshalJSON ¶
func (value *SecurityScheme) UnmarshalJSON(data []byte) error
type SecuritySchemes ¶
type SecuritySchemes map[string]*SecurityScheme
type Server ¶
type Server struct { Extensions map[string]interface{} `json:"-" yaml:"-"` URL string `json:"url" yaml:"url"` Protocol string `json:"protocol" yaml:"protocol"` ProtocolVersion string `json:"protocolVersion,omitempty" yaml:"protocolVersion,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Security []SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"` Bindings *ServerBindings `json:"bindings,omitempty" yaml:"bindings,omitempty"` Variables map[string]*ServerVariable `json:"variables,omitempty" yaml:"variables,omitempty"` }
Server is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#serverObject
func (*Server) MarshalJSON ¶
func (*Server) MatchRawURL ¶
func (*Server) ParameterNames ¶
func (*Server) UnmarshalJSON ¶
type ServerBindings ¶
type ServerBindings struct { Extensions map[string]interface{} `json:"-" yaml:"-"` Http *bindings.HttpServer `json:"http,omitempty" yaml:"http,omitempty"` Ws *bindings.WsServer `json:"ws,omitempty" yaml:"ws,omitempty"` Kafka *bindings.KafkaServer `json:"kafka,omitempty" yaml:"kafka,omitempty"` Amqp interface{} `json:"amqp,omitempty" yaml:"amqp,omitempty"` Amqp1 interface{} `json:"amqp1,omitempty" yaml:"amqp1,omitempty"` Mqtt interface{} `json:"mqtt,omitempty" yaml:"mqtt,omitempty"` Mqtt5 interface{} `json:"mqtt5,omitempty" yaml:"mqtt5,omitempty"` Nats interface{} `json:"nats,omitempty" yaml:"nats,omitempty"` Jms interface{} `json:"jms,omitempty" yaml:"jms,omitempty"` Sns interface{} `json:"sns,omitempty" yaml:"sns,omitempty"` Sqs interface{} `json:"sqs,omitempty" yaml:"sqs,omitempty"` Stomp interface{} `json:"stomp,omitempty" yaml:"stomp,omitempty"` Redis interface{} `json:"redis,omitempty" yaml:"redis,omitempty"` }
ServerBindings is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#server-bindings-object
func (*ServerBindings) MarshalJSON ¶
func (value *ServerBindings) MarshalJSON() ([]byte, error)
func (*ServerBindings) UnmarshalJSON ¶
func (value *ServerBindings) UnmarshalJSON(data []byte) error
type ServerBindingsRef ¶
type ServerBindingsRef = RefG[*ServerBindings]
type ServerVariable ¶
type ServerVariable struct { Extensions map[string]interface{} `json:"-" yaml:"-"` Enum []string `json:"enum,omitempty" yaml:"enum,omitempty"` Default string `json:"default,omitempty" yaml:"default,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` }
ServerVariable is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#serverVariableObject
func (*ServerVariable) MarshalJSON ¶
func (value *ServerVariable) MarshalJSON() ([]byte, error)
func (*ServerVariable) UnmarshalJSON ¶
func (value *ServerVariable) UnmarshalJSON(data []byte) error
type Servers ¶
Servers object is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#serversObject
type ServersBindings ¶
type ServersBindings map[string]*ServerBindings
type T ¶
type T struct { Extensions map[string]interface{} `json:"-" yaml:"-"` AsyncAPI string `json:"asyncapi" yaml:"asyncapi"` ID string `json:"id,omitempty" yaml:"id,omitempty"` Info *openapi3.Info `json:"info" yaml:"info"` DefaultContentType string `json:"defaultContentType" yaml:"defaultContentType"` Servers Servers `json:"servers,omitempty" yaml:"servers,omitempty"` Channels Channels `json:"channels,omitempty" yaml:"channels,omitempty"` Components *Components `json:"components,omitempty" yaml:"components,omitempty"` Tags openapi3.Tags `json:"tags,omitempty" yaml:"tags,omitempty"` ExternalDocs *openapi3.ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` }
T is the root of an OpenAPI v3 document T is defined in AsyncAPI spec: https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md#A2SObject