Documentation
¶
Overview ¶
Package asyncapi loads AsyncAPI 3 documents. Load follows $refs across files, merges message and operation traits, and returns servers, channels, operations and messages in document order. Schemas stay as ordered Object trees, and the Document's Resolver dereferences the $refs inside them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct {
Name string
Address string
Description string
Parameters []*Parameter
Messages []*Message
Location Location
}
Channel is one entry of the channels object.
type Document ¶
type Document struct {
AsyncAPIVersion string
Title string
Version string
Description string
// DefaultContentType applies to messages that set no contentType.
DefaultContentType string
Servers []*Server
Channels []*Channel
Operations []*Operation
// Messages lists every distinct message, in first-seen order.
Messages []*Message
// ComponentSchemas lists components.schemas in document order.
ComponentSchemas []SchemaComponent
// Resolver holds every loaded file and dereferences $refs inside schemas.
Resolver *Resolver
// Root is the location of the document's top level.
Root Location
// contains filtered or unexported fields
}
Document is a loaded AsyncAPI 3 document.
type Located ¶
Located is a value merged in from a trait, together with where it was defined, so $refs inside it still resolve against the trait's document.
type Location ¶
Location identifies a value inside a loaded document by file and JSON pointer. Two $refs that resolve to the same Location point at the same value, so it works as a map key for deduplicating schemas.
type Message ¶
type Message struct {
// Key is the components.messages key, or channel_message for an inline
// message. Keys are unique within a document.
Key string
Name string
Title string
Summary string
Description string
// ContentType is the message's contentType, or the document's
// defaultContentType.
ContentType string
Deprecated bool
// Payload is the payload schema as loaded, usually an *Object. It is nil
// when the message has no payload or its schemaFormat is not AsyncAPI,
// JSON Schema or OpenAPI; UnsupportedFormat names that format.
Payload any
// PayloadAt is where Payload sits, for resolving $refs inside it.
PayloadAt Location
UnsupportedFormat string
// Headers is the application headers schema, or nil.
Headers any
HeadersAt Location
// CorrelationIDLocation is the runtime expression of the correlationId,
// such as "$message.payload#/id", or "".
CorrelationIDLocation string
// Bindings is the protocol bindings object after traits are merged in,
// or nil.
Bindings *Object
Location Location
}
Message is a message definition. Messages referenced from several channels are the same *Message.
type Object ¶
Object is a JSON/YAML mapping that keeps its keys in the order the document lists them. Values are string, int64, float64, bool, nil, []any or *Object.
type Operation ¶
type Operation struct {
Name string
Action Action
Summary string
Description string
Channel *Channel
Messages []*Message
Reply *Reply
}
Operation is one entry of the operations object.
type Reply ¶
type Reply struct {
Channel *Channel
Messages []*Message
// AddressLocation is the runtime expression of a dynamic reply address,
// such as "$message.header#/replyTo", or "".
AddressLocation string
}
Reply is the expected reply to an operation.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver loads documents and follows $ref values between and inside them.
func NewResolver ¶
func NewResolver() *Resolver
NewResolver returns a resolver with no documents loaded.
func (*Resolver) Deref ¶
Deref follows $ref chains starting at value, which lives at location. It returns the first value that is not a reference and where that value lives.
type SchemaComponent ¶
SchemaComponent is one components.schemas entry.
type Server ¶
type Server struct {
Name string
Host string
Pathname string
Protocol string
ProtocolVersion string
Description string
Variables []*ServerVariable
}
Server is one entry of the servers object.
func (*Server) URLTemplate ¶
URLTemplate returns protocol://host/pathname with variables unfilled.