Documentation
¶
Index ¶
- func Generate(t reflect.Type, description string) map[string]any
- type AsyncAPIDocument
- func (doc *AsyncAPIDocument) AddChannel(address, description string) *Channel
- func (doc *AsyncAPIDocument) AddHttpOperation(channel *Channel, action string, httpMethod string) *Operation
- func (doc *AsyncAPIDocument) AddOperation(channel *Channel, action string) *Operation
- func (doc *AsyncAPIDocument) AddServer(serverKey, host, protocol, description string) *Server
- func (doc *AsyncAPIDocument) GenerateHtml() string
- func (doc *AsyncAPIDocument) Handler(w http.ResponseWriter, r *http.Request)
- type AsyncAPIInfo
- type Channel
- type ChannelRef
- type Components
- type KafkaConsumerGroupIDSchema
- type Message
- type Operation
- type OperationReply
- type SecurityScheme
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AsyncAPIDocument ¶
type AsyncAPIDocument struct {
AsyncAPI string `json:"asyncapi"`
Info AsyncAPIInfo `json:"info"`
Servers map[string]*Server `json:"servers,omitempty"`
Channels map[string]*Channel `json:"channels,omitempty"`
Operations map[string]*Operation `json:"operations,omitempty"`
Components *Components `json:"components,omitempty"`
}
func NewAsyncAPI ¶
func NewAsyncAPI(title, version, description string) *AsyncAPIDocument
NewAsyncAPI initializes a new AsyncAPI v3 document.
func (*AsyncAPIDocument) AddChannel ¶
func (doc *AsyncAPIDocument) AddChannel(address, description string) *Channel
AddChannel registers a new topic, queue, or endpoint.
func (*AsyncAPIDocument) AddHttpOperation ¶
func (doc *AsyncAPIDocument) AddHttpOperation(channel *Channel, action string, httpMethod string) *Operation
AddHttpOperation safely links an action and defines the HTTP method binding.
func (*AsyncAPIDocument) AddOperation ¶
func (doc *AsyncAPIDocument) AddOperation(channel *Channel, action string) *Operation
AddOperation links an action (send or receive) to a registered channel.
func (*AsyncAPIDocument) AddServer ¶
func (doc *AsyncAPIDocument) AddServer(serverKey, host, protocol, description string) *Server
AddServer registers a new message broker or web server to the documentation.
func (*AsyncAPIDocument) GenerateHtml ¶
func (doc *AsyncAPIDocument) GenerateHtml() string
GenerateHtml returns the full HTML string containing the AsyncAPI React component.
func (*AsyncAPIDocument) Handler ¶
func (doc *AsyncAPIDocument) Handler(w http.ResponseWriter, r *http.Request)
Handler is a standard HTTP handler function to serve the AsyncAPI UI.
type AsyncAPIInfo ¶
type Channel ¶
type Channel struct {
Address string `json:"address"`
Description string `json:"description,omitempty"`
Messages map[string]*Message `json:"messages,omitempty"`
}
func (*Channel) AddMessage ¶
AddMessage reflects on a Go struct to automatically generate the payload schema.
type ChannelRef ¶
type ChannelRef struct {
Ref string `json:"$ref"`
}
type Components ¶
type Components struct {
Messages map[string]*Message `json:"messages,omitempty"`
SecuritySchemes map[string]*SecurityScheme `json:"securitySchemes,omitempty"`
}
type Operation ¶
type Operation struct {
Action string `json:"action"` // "send" or "receive"
Channel *ChannelRef `json:"channel"`
Bindings map[string]any `json:"bindings,omitempty"`
Reply *OperationReply `json:"reply,omitempty"`
}
func (*Operation) SetKafkaConsumerGroup ¶
func (op *Operation) SetKafkaConsumerGroup(groupID string) *KafkaConsumerGroupIDSchema
SetKafkaConsumerGroup safely links a consumer group ID to the operation and returns the schema object for direct access.
type OperationReply ¶
type OperationReply struct {
Channel *ChannelRef `json:"channel"`
}
type SecurityScheme ¶
type Server ¶
type Server struct {
Host string `json:"host"`
Protocol string `json:"protocol"`
Description string `json:"description,omitempty"`
Bindings map[string]any `json:"bindings,omitempty"`
Security []*SecurityScheme `json:"security,omitempty"`
}
func (*Server) SetAPIKeyAuth ¶
SetAPIKeyAuth configures API Key authentication injected via headers.
func (*Server) SetBasicAuth ¶
SetBasicAuth configures standard HTTP Basic Authentication (Username/Password).
func (*Server) SetJWTAuth ¶
SetJWTAuth configures standard HTTP Bearer (JWT) authentication.
func (*Server) SetKafkaSASL ¶
SetKafkaSASL configures SCRAM-SHA-256 authentication for a Kafka server.