Documentation
¶
Overview ¶
Package asyncapi generates AsyncAPI 3.1.0 documents from captured WebSocket sessions.
Index ¶
Constants ¶
const AsyncAPIVersion = "3.1.0"
AsyncAPIVersion is the AsyncAPI specification version emitted by the generator.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Channel ¶
type Channel struct {
Address string `json:"address,omitempty"`
Messages map[string]Ref `json:"messages,omitempty"`
Parameters map[string]ChannelParameter `json:"parameters,omitempty"`
}
Channel describes one WebSocket endpoint: an addressable component with the messages that can be exchanged on it.
type ChannelParameter ¶
ChannelParameter describes a path parameter of a channel address.
type Components ¶
type Components struct {
Schemas map[string]map[string]any `json:"schemas,omitempty"`
Messages map[string]Message `json:"messages,omitempty"`
SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty"`
}
Components holds reusable schemas, messages, and security schemes.
type Document ¶
type Document struct {
AsyncAPI string `json:"asyncapi"`
Info Info `json:"info"`
Servers map[string]Server `json:"servers,omitempty"`
Channels map[string]Channel `json:"channels"`
Operations map[string]Operation `json:"operations"`
Components Components `json:"components,omitempty"`
}
Document is an AsyncAPI 3.1.0 document. The JSON tags are the source of truth for both JSON and YAML serialization.
The 3.x model separates channels (addressable components) from operations (what the documented application does): channels declare the messages exchanged on an address, and a top-level operations map references them with an action of "send" or "receive".
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator generates AsyncAPI documents from captured WebSocket sessions.
func NewGenerator ¶
NewGenerator creates a generator with the given configuration.
func (*Generator) AddSession ¶
func (g *Generator) AddSession(session proxy.WebSocketSession)
AddSession adds a captured WebSocket session to be analyzed.
func (*Generator) LoadWebSocketSessionsFromDirectory ¶
LoadWebSocketSessionsFromDirectory loads sessions from all ws-session-*.json files in a directory. HTTP session files are ignored.
func (*Generator) LoadWebSocketSessionsFromFile ¶
LoadWebSocketSessionsFromFile loads sessions from a ws-session JSON file (either an array of sessions or a single session object).
type Info ¶
type Info struct {
Title string `json:"title"`
Version string `json:"version"`
Description string `json:"description,omitempty"`
}
Info carries document metadata.
type Message ¶
type Message struct {
Name string `json:"name"`
ContentType string `json:"contentType,omitempty"`
Payload map[string]any `json:"payload"`
}
Message describes one message type exchanged on a channel.
type Operation ¶
type Operation struct {
Action string `json:"action"`
Channel Ref `json:"channel"`
Messages []Ref `json:"messages,omitempty"`
Security []Ref `json:"security,omitempty"`
}
Operation is an operation the documented application MUST implement. Action is "send" (the application sends to the channel) or "receive" (the application receives from the channel).