Documentation
¶
Overview ¶
Package asyncapi publishes immutable AsyncAPI 3.1 documents without connecting to brokers or changing application behavior. Declare channels and operations, then explicitly register Document.Handler or export Document.JSON. Send and Receive describe the application's perspective, not the broker's perspective. Schemas and examples describe wire data; they do not validate runtime traffic. Raw schemas can overlap: callers must ensure their messages are distinguishable.
Example:
document := asyncapi.New("Billing events", "1.0")
data, err := document.JSON()
if err != nil {
log.Fatal(err)
}
_ = data
Index ¶
- type Builder
- func (definition *Builder) Channel(id, address string, configure ...ChannelBuilderFunc) *Builder
- func (definition *Builder) Description(text string) *Builder
- func (definition *Builder) Receive(id, channel string, configure ...OperationBuilderFunc) *Builder
- func (definition *Builder) SecurityScheme(id string, object RawObject) *Builder
- func (definition *Builder) Send(id, channel string, configure ...OperationBuilderFunc) *Builder
- func (definition *Builder) Server(id, host, protocol string, configure ...ServerBuilderFunc) *Builder
- type BuilderFunc
- type ChannelBuilder
- func (channel *ChannelBuilder) Binding(protocol string, object RawObject) *ChannelBuilder
- func (channel *ChannelBuilder) Description(text string) *ChannelBuilder
- func (channel *ChannelBuilder) JSONJob[T any](id string, job queue.Job[T], payload Schema, configure ...MessageBuilderFunc) *ChannelBuilder
- func (channel *ChannelBuilder) JSONTopic[T any](id string, topic broadcast.Topic[T], payload Schema, ...) *ChannelBuilder
- func (channel *ChannelBuilder) Message(id string, wirePayload Schema, configure ...MessageBuilderFunc) *ChannelBuilder
- func (channel *ChannelBuilder) Servers(ids ...string) *ChannelBuilder
- type ChannelBuilderFunc
- type Document
- type MessageBuilder
- func (message *MessageBuilder) Binding(protocol string, object RawObject) *MessageBuilder
- func (message *MessageBuilder) ContentType(media string) *MessageBuilder
- func (message *MessageBuilder) Description(text string) *MessageBuilder
- func (message *MessageBuilder) Summary(text string) *MessageBuilder
- func (message *MessageBuilder) WireExample(name string, value any) *MessageBuilder
- type MessageBuilderFunc
- type OperationBuilder
- func (action *OperationBuilder) Binding(protocol string, object RawObject) *OperationBuilder
- func (action *OperationBuilder) Description(text string) *OperationBuilder
- func (action *OperationBuilder) Messages(ids ...string) *OperationBuilder
- func (action *OperationBuilder) Security(ids ...string) *OperationBuilder
- func (action *OperationBuilder) Summary(text string) *OperationBuilder
- type OperationBuilderFunc
- type RawObject
- type RawSchema
- type Schema
- type ServerBuilder
- func (listener *ServerBuilder) Binding(protocol string, object RawObject) *ServerBuilder
- func (listener *ServerBuilder) Description(text string) *ServerBuilder
- func (listener *ServerBuilder) Pathname(path string) *ServerBuilder
- func (listener *ServerBuilder) ProtocolVersion(version string) *ServerBuilder
- func (listener *ServerBuilder) Security(ids ...string) *ServerBuilder
- type ServerBuilderFunc
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder declares document metadata and graph nodes. It is only a construction draft; retained drafts are detached from published documents.
Example:
_ = asyncapi.New("Events", "1", func(definition *asyncapi.Builder) {
definition.Description("Application event contract")
})
func (*Builder) Channel ¶
func (definition *Builder) Channel(id, address string, configure ...ChannelBuilderFunc) *Builder
Channel registers a unique channel ID and its literal broker address. IDs are reference-safe letters, digits, dots, underscores and hyphens. Addresses are independent of IDs, and unknown addresses export as null.
Example:
_ = asyncapi.New("Events", "1", func(definition *asyncapi.Builder) {
definition.Channel("invoices", "billing.invoices")
})
func (*Builder) Description ¶
Description replaces the information object's human-readable description. An empty string is accepted; this setting does not affect runtime messaging.
Example:
_ = asyncapi.New("Events", "1", func(definition *asyncapi.Builder) {
definition.Description("Public integration contract")
})
func (*Builder) Receive ¶
func (definition *Builder) Receive(id, channel string, configure ...OperationBuilderFunc) *Builder
Receive declares an operation that receives into this application, not a broker's direction. Channel and message references are checked at export.
Example:
_ = asyncapi.New("Events", "1", func(definition *asyncapi.Builder) {
definition.Receive("consume-invoice", "invoices", func(action *asyncapi.OperationBuilder) {
action.Messages("invoice")
})
})
func (*Builder) SecurityScheme ¶
SecurityScheme captures a raw AsyncAPI security scheme under a unique ID. JSON syntax, supported type names, and local references are checked; this is not a full protocol validator and does not configure authentication.
Example:
_ = asyncapi.New("Events", "1", func(definition *asyncapi.Builder) {
definition.SecurityScheme("login", asyncapi.RawObject(`{"type":"userPassword"}`))
})
func (*Builder) Send ¶
func (definition *Builder) Send(id, channel string, configure ...OperationBuilderFunc) *Builder
Send declares a uniquely named operation that sends from this application. The channel and selected messages may be declared later. A message selection is required, and duplicate operation IDs are errors rather than replacements.
Example:
_ = asyncapi.New("Events", "1", func(definition *asyncapi.Builder) {
definition.Send("publish-invoice", "invoices", func(action *asyncapi.OperationBuilder) {
action.Messages("invoice")
})
})
func (*Builder) Server ¶
func (definition *Builder) Server(id, host, protocol string, configure ...ServerBuilderFunc) *Builder
Server declares a uniquely named endpoint. Host is a host or host:port, including bracketed IPv6; credentials, URI schemes, paths and queries are rejected at export. Callbacks still run once for invalid declarations.
Example:
_ = asyncapi.New("Events", "1", func(definition *asyncapi.Builder) {
definition.Server("main", "broker.example:9092", "kafka")
})
type BuilderFunc ¶
type BuilderFunc = func(*Builder)
BuilderFunc configures a fresh document draft synchronously. Callbacks run once, in order, even when inputs are invalid; nil entries panic.
Example:
var configure asyncapi.BuilderFunc = func(definition *asyncapi.Builder) {
definition.Description("Public event contracts")
}
_ = asyncapi.New("Events", "1", configure)
type ChannelBuilder ¶
type ChannelBuilder struct {
// contains filtered or unexported fields
}
ChannelBuilder declares one address and its wire messages. Empty addresses mean an unknown address and export as null; address templates are unsupported.
Example:
_ = asyncapi.New("Events", "1", func(definition *asyncapi.Builder) {
definition.Channel("invoices", "billing.invoices", func(channel *asyncapi.ChannelBuilder) {
channel.Description("Invoice lifecycle")
})
})
func (*ChannelBuilder) Binding ¶
func (channel *ChannelBuilder) Binding(protocol string, object RawObject) *ChannelBuilder
Binding captures a channel-level protocol binding without applying it to a live broker. Duplicate protocol keys become deferred export errors.
Example:
var configure asyncapi.ChannelBuilderFunc = func(channel *asyncapi.ChannelBuilder) {
channel.Binding("kafka", asyncapi.RawObject(`{"bindingVersion":"0.5.0"}`))
}
_ = configure
func (*ChannelBuilder) Description ¶
func (channel *ChannelBuilder) Description(text string) *ChannelBuilder
Description replaces the channel's human-readable description. Empty text is allowed and does not affect message delivery.
Example:
var configure asyncapi.ChannelBuilderFunc = func(channel *asyncapi.ChannelBuilder) {
channel.Description("Invoice lifecycle")
}
_ = configure
func (*ChannelBuilder) JSONJob ¶
func (channel *ChannelBuilder) JSONJob[T any]( id string, job queue.Job[T], payload Schema, configure ...MessageBuilderFunc, ) *ChannelBuilder
JSONJob documents a driver that JSON-marshals queue.Message, not a universal queue transport. The supplied schema describes the decoded logical payload, captured once into components/schemas/<channel>.<id>. The message's x-arkoren-logical-payload annotation points to it as a plain JSON Pointer; standard tools may not display that annotation.
The complete wire schema uses a base64 payload string. Its Draft 7 content annotations do not validate decoded data. Name and queue are constants from the job; attempts remains an integer because deliveries can change it. Job.Err and schema errors are deferred to Document.JSON, without changing dispatch or registration. Callbacks run once even for invalid definitions; nil callbacks panic. ContentType can override the application/json default. Typed helpers reject duplicate discriminator identities on the channel; a job and topic cannot share a name, but jobs on different queues can. Overlap with raw Message schemas remains the caller's responsibility.
Example:
job := queue.NewJob[string]("send-invoice")
document := asyncapi.New("Billing", "1", func(definition *asyncapi.Builder) {
definition.Channel("jobs", job.Queue(), func(channel *asyncapi.ChannelBuilder) {
channel.JSONJob("send", job, asyncapi.RawSchema(`{"type":"string"}`))
})
})
if _, err := document.JSON(); err != nil {
log.Fatal(err)
}
func (*ChannelBuilder) JSONTopic ¶
func (channel *ChannelBuilder) JSONTopic[T any]( id string, topic broadcast.Topic[T], payload Schema, configure ...MessageBuilderFunc, ) *ChannelBuilder
JSONTopic documents a driver that JSON-marshals broadcast.Message, not every possible broadcast transport. The supplied schema describes the decoded logical payload; it is captured once into components/schemas/<channel>.<id>. The message's x-arkoren-logical-payload annotation is a plain JSON Pointer to that component. Standard tools may not display this custom annotation.
The wire payload is a base64 string, not the logical JSON object. Draft 7's contentEncoding and contentMediaType are annotations, not decoding validation. Invalid topic names and schema errors are deferred to Document.JSON without changing publishing behavior. Callbacks run once even for invalid inputs; nil callbacks panic. JSON is the default content type; use ContentType for transports such as MQTT that advertise application/octet-stream. Typed helpers reject duplicate discriminator identities on the channel; a topic and job cannot share a name because their wire schemas overlap. Overlap with raw Message schemas remains the caller's responsibility.
Example:
topic := broadcast.NewTopic[string]("invoice.issued")
document := asyncapi.New("Billing", "1", func(definition *asyncapi.Builder) {
definition.Channel("invoices", topic.Name(), func(channel *asyncapi.ChannelBuilder) {
channel.JSONTopic("issued", topic, asyncapi.RawSchema(`{"type":"string"}`))
})
})
if _, err := document.JSON(); err != nil {
log.Fatal(err)
}
func (*ChannelBuilder) Message ¶
func (channel *ChannelBuilder) Message(id string, wirePayload Schema, configure ...MessageBuilderFunc) *ChannelBuilder
Message declares the schema of the actual wire payload, not a logical DTO hidden inside an envelope. Schemas are captured immediately as draft-07 JSON Schema in an explicit Multi Format Schema Object. JSON content type is the default; MessageBuilder.ContentType can override it.
Example:
var configure asyncapi.ChannelBuilderFunc = func(channel *asyncapi.ChannelBuilder) {
channel.Message("invoice", asyncapi.RawSchema(`{"type":"object"}`))
}
_ = configure
func (*ChannelBuilder) Servers ¶
func (channel *ChannelBuilder) Servers(ids ...string) *ChannelBuilder
Servers appends explicit server selections. Every channel must select at least one server when the document declares any servers. With no declared servers a portable channel may omit this setting. Duplicates are errors.
Example:
var configure asyncapi.ChannelBuilderFunc = func(channel *asyncapi.ChannelBuilder) {
channel.Servers("main")
}
_ = configure
type ChannelBuilderFunc ¶
type ChannelBuilderFunc = func(*ChannelBuilder)
ChannelBuilderFunc configures one channel synchronously, before publication. Supplied nil callbacks panic rather than becoming document errors.
Example:
var configure asyncapi.ChannelBuilderFunc = func(channel *asyncapi.ChannelBuilder) {
channel.Description("Invoice events")
}
_ = configure
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document is an immutable asynchronous API description. Its zero value is invalid; use New. Export results, including errors, are cached concurrently.
Example:
document := asyncapi.New("Events", "1")
data, err := document.JSON()
if err != nil {
log.Fatal(err)
}
_ = data
func New ¶
func New(title, version string, configure ...BuilderFunc) *Document
New captures an AsyncAPI 3.1 description without I/O. All supplied callbacks run once in order, including invalid inputs; nil entries panic. Required title and version and graph errors are reported by JSON and Handler, not by New.
Example:
document := asyncapi.New("Billing", "1.0", func(definition *asyncapi.Builder) {
definition.Description("Billing event contracts")
})
_ = document.Handler()
func (*Document) Handler ¶
Handler serves the same cached JSON as JSON, without registering a route. Validation errors return before headers or body are committed; write failures propagate to the router. HEAD sends headers only, following net/http behavior. Applications own authentication, routing, and broker lifecycle separately.
Example:
routes := router.New()
routes.Get("/asyncapi.json", asyncapi.New("Events", "1").Handler())
Example ¶
ExampleDocument_Handler shows the public handler can serve a HEAD response without opening a listener or connecting to a broker.
package main
import (
"fmt"
"net/http"
"net/http/httptest"
"arkoren.dev/core/asyncapi"
)
func main() {
document := asyncapi.New("Events", "1")
response := httptest.NewRecorder()
request := httptest.NewRequest(http.MethodHead, "/asyncapi.json", nil)
if err := document.Handler()(response, request); err != nil {
fmt.Println(err)
return
}
fmt.Println(response.Header().Get("Content-Type"), response.Body.Len())
}
Output: application/json 0
func (*Document) JSON ¶
JSON returns a detached copy of the deterministic document bytes. Both successful validation and failures are cached once. Nil and zero Documents return an error. Mutating the returned bytes never affects future exports.
Example:
data, err := asyncapi.New("Events", "1").JSON()
if err != nil {
log.Fatal(err)
}
_ = data
type MessageBuilder ¶
type MessageBuilder struct {
// contains filtered or unexported fields
}
MessageBuilder configures documentation for a complete wire message. Values are captured immediately; retaining the draft cannot mutate publication.
Example:
var configure asyncapi.MessageBuilderFunc = func(message *asyncapi.MessageBuilder) {
message.Summary("An invoice was issued").WireExample("issued", map[string]any{"id": "inv-1"})
}
_ = configure
func (*MessageBuilder) Binding ¶
func (message *MessageBuilder) Binding(protocol string, object RawObject) *MessageBuilder
Binding captures message-level protocol metadata. Raw object syntax is checked, but protocol-specific behavior remains the caller's responsibility.
Example:
var configure asyncapi.MessageBuilderFunc = func(message *asyncapi.MessageBuilder) {
message.Binding("kafka", asyncapi.RawObject(`{"bindingVersion":"0.5.0"}`))
}
_ = configure
func (*MessageBuilder) ContentType ¶
func (message *MessageBuilder) ContentType(media string) *MessageBuilder
ContentType replaces the default application/json wire media type. Empty media types are invalid and are reported when the document is exported.
Example:
var configure asyncapi.MessageBuilderFunc = func(message *asyncapi.MessageBuilder) {
message.ContentType("application/cloudevents+json")
}
_ = configure
func (*MessageBuilder) Description ¶
func (message *MessageBuilder) Description(text string) *MessageBuilder
Description replaces the detailed wire-message explanation. It documents semantics without adding or validating runtime fields.
Example:
var configure asyncapi.MessageBuilderFunc = func(message *asyncapi.MessageBuilder) {
message.Description("Published after an invoice is committed")
}
_ = configure
func (*MessageBuilder) Summary ¶
func (message *MessageBuilder) Summary(text string) *MessageBuilder
Summary replaces the short message explanation. Empty text is permitted and has no effect on the actual wire payload.
Example:
var configure asyncapi.MessageBuilderFunc = func(message *asyncapi.MessageBuilder) {
message.Summary("Invoice issued")
}
_ = configure
func (*MessageBuilder) WireExample ¶
func (message *MessageBuilder) WireExample(name string, value any) *MessageBuilder
WireExample appends a named complete wire payload, encoding and copying it immediately. Unsupported JSON values become deferred document errors. These examples are annotations and are not checked against the payload schema.
Example:
var configure asyncapi.MessageBuilderFunc = func(message *asyncapi.MessageBuilder) {
message.WireExample("issued", map[string]any{"id": "inv-1"})
}
_ = configure
type MessageBuilderFunc ¶
type MessageBuilderFunc = func(*MessageBuilder)
MessageBuilderFunc configures a wire message before its containers are copied. Examples are encoded at capture, not when the document is later exported.
Example:
var configure asyncapi.MessageBuilderFunc = func(message *asyncapi.MessageBuilder) {
message.ContentType("application/json")
}
_ = configure
type OperationBuilder ¶
type OperationBuilder struct {
// contains filtered or unexported fields
}
OperationBuilder documents an application's send or receive operation. Messages must explicitly select at least one message on its channel.
Example:
var configure asyncapi.OperationBuilderFunc = func(action *asyncapi.OperationBuilder) {
action.Messages("invoice").Summary("Publish invoices")
}
_ = configure
func (*OperationBuilder) Binding ¶
func (action *OperationBuilder) Binding(protocol string, object RawObject) *OperationBuilder
Binding captures operation-level protocol metadata independently of server, channel and message bindings. Duplicate protocols are deferred errors.
Example:
var configure asyncapi.OperationBuilderFunc = func(action *asyncapi.OperationBuilder) {
action.Binding("kafka", asyncapi.RawObject(`{"bindingVersion":"0.5.0"}`))
}
_ = configure
func (*OperationBuilder) Description ¶
func (action *OperationBuilder) Description(text string) *OperationBuilder
Description replaces the operation's detailed explanation. Empty strings are accepted and do not affect runtime behavior.
Example:
var configure asyncapi.OperationBuilderFunc = func(action *asyncapi.OperationBuilder) {
action.Description("Runs after the invoice transaction commits")
}
_ = configure
func (*OperationBuilder) Messages ¶
func (action *OperationBuilder) Messages(ids ...string) *OperationBuilder
Messages appends explicit channel message IDs, preserving declaration order. Selection is required and duplicates are errors. References always point to channel messages, never to an independent component message collection.
Example:
var configure asyncapi.OperationBuilderFunc = func(action *asyncapi.OperationBuilder) {
action.Messages("invoice", "credit")
}
_ = configure
func (*OperationBuilder) Security ¶
func (action *OperationBuilder) Security(ids ...string) *OperationBuilder
Security appends alternative security scheme references (OR). These apply in addition to server-level requirements, not in place of them. Duplicates and unresolved scheme IDs are deferred export errors.
Example:
var configure asyncapi.OperationBuilderFunc = func(action *asyncapi.OperationBuilder) {
action.Security("publisher-login")
}
_ = configure
func (*OperationBuilder) Summary ¶
func (action *OperationBuilder) Summary(text string) *OperationBuilder
Summary replaces the operation's short explanation. This metadata does not dispatch messages or register a handler.
Example:
var configure asyncapi.OperationBuilderFunc = func(action *asyncapi.OperationBuilder) {
action.Summary("Publish invoice changes")
}
_ = configure
type OperationBuilderFunc ¶
type OperationBuilderFunc = func(*OperationBuilder)
OperationBuilderFunc configures one application's send or receive operation. Callbacks run once in supplied order, including invalid declarations.
Example:
var configure asyncapi.OperationBuilderFunc = func(action *asyncapi.OperationBuilder) {
action.Messages("invoice")
}
_ = configure
type RawObject ¶
type RawObject []byte
RawObject contains an opaque JSON object for protocol bindings or security details. Capture validates JSON syntax and the object root, then copies the exact bytes, preserving large numbers and whitespace. Nested contents are not interpreted as schemas. Empty input, null and nonobjects are invalid. Do not mutate the slice concurrently with definition construction.
Example:
document := asyncapi.New("Events", "1", func(definition *asyncapi.Builder) {
definition.Channel("invoices", "billing.invoices", func(channel *asyncapi.ChannelBuilder) {
channel.Binding("kafka", asyncapi.RawObject(`{"bindingVersion":"0.5.0"}`))
})
})
if _, err := document.JSON(); err != nil {
return err
}
Example ¶
ExampleRawObject demonstrates that Binding takes the protocol separately from its object, rather than receiving an entire protocol-keyed bindings map.
package main
import (
"encoding/json/v2"
"fmt"
"arkoren.dev/core/asyncapi"
)
func main() {
document := asyncapi.New("Events", "1", func(definition *asyncapi.Builder) {
definition.Channel("invoices", "billing.invoices", func(channel *asyncapi.ChannelBuilder) {
channel.Binding("kafka", asyncapi.RawObject(`{"bindingVersion":"0.5.0"}`))
})
})
data, err := document.JSON()
if err != nil {
fmt.Println(err)
return
}
var published struct {
// Channels exposes only the public document path needed by this example.
Channels map[string]struct {
// Bindings maps protocol names to their individual metadata objects.
Bindings map[string]map[string]string `json:"bindings"`
} `json:"channels"`
}
if err := json.Unmarshal(data, &published); err != nil {
fmt.Println(err)
return
}
fmt.Println(published.Channels["invoices"].Bindings["kafka"]["bindingVersion"])
}
Output: 0.5.0
type RawSchema ¶
type RawSchema []byte
RawSchema contains a JSON Schema in the supported, self-contained Draft 7 subset. It accepts boolean schemas, tuple items and composition, but rejects references, identifiers, definitions, unknown keywords and other dialects. Only schema-bearing positions are checked: arbitrary defaults, enum values and x- extension contents remain opaque. Formats and patterns are annotations here; no instance validation, regexp conversion or reference resolution runs. Callers must not mutate the slice concurrently with capture or JSONSchema.
Example:
data, err := asyncapi.RawSchema(`{"type":["string","null"]}`).JSONSchema()
if err != nil {
return err
}
_ = data
func (RawSchema) JSONSchema ¶
JSONSchema validates the supported Draft 7 profile and returns an independent copy without re-encoding numbers or changing whitespace. Empty, malformed and unsupported schemas return errors with a JSON Pointer when available. This checks declaration shapes, not satisfiability or instance validity.
Example:
data, err := asyncapi.RawSchema(`{"minimum":9007199254740993}`).JSONSchema()
if err != nil {
return err
}
_ = data
type Schema ¶
type Schema interface {
// JSONSchema returns one object or boolean schema, or an error. Capture
// invokes this method once and takes an independent copy of its result.
//
// Example:
//
// data, err := asyncapi.RawSchema(`true`).JSONSchema()
// if err != nil {
// return err
// }
// _ = data
JSONSchema() ([]byte, error)
}
Schema supplies a self-contained Draft 7 JSON Schema for documentation. Definitions capture the returned bytes immediately; implementations need not retain their output. Providers must not perform network resolution. Provider errors propagate to the definition that captures the schema.
Example:
var payload asyncapi.Schema = asyncapi.RawSchema(`{"type":"string"}`)
data, err := payload.JSONSchema()
if err != nil {
return err
}
_ = data
type ServerBuilder ¶
type ServerBuilder struct {
// contains filtered or unexported fields
}
ServerBuilder describes a broker endpoint, not a live broker connection. Security references and bindings document requirements without enforcing them.
Example:
_ = asyncapi.New("Events", "1", func(definition *asyncapi.Builder) {
definition.Server("main", "broker.example:9092", "kafka", func(listener *asyncapi.ServerBuilder) {
listener.ProtocolVersion("1.0")
})
})
func (*ServerBuilder) Binding ¶
func (listener *ServerBuilder) Binding(protocol string, object RawObject) *ServerBuilder
Binding captures a protocol-specific server binding object. Duplicate protocols and malformed raw objects become deferred document errors.
Example:
var configure asyncapi.ServerBuilderFunc = func(listener *asyncapi.ServerBuilder) {
listener.Binding("kafka", asyncapi.RawObject(`{"bindingVersion":"0.5.0"}`))
}
_ = configure
func (*ServerBuilder) Description ¶
func (listener *ServerBuilder) Description(text string) *ServerBuilder
Description replaces the endpoint's human-readable explanation. Empty text is allowed and no connection is made when this setting is applied.
Example:
var configure asyncapi.ServerBuilderFunc = func(listener *asyncapi.ServerBuilder) {
listener.Description("Primary event broker")
}
_ = configure
func (*ServerBuilder) Pathname ¶
func (listener *ServerBuilder) Pathname(path string) *ServerBuilder
Pathname replaces the endpoint path independently of its host. This value documents the protocol endpoint and performs no routing or I/O.
Example:
var configure asyncapi.ServerBuilderFunc = func(listener *asyncapi.ServerBuilder) {
listener.Pathname("/events")
}
_ = configure
func (*ServerBuilder) ProtocolVersion ¶
func (listener *ServerBuilder) ProtocolVersion(version string) *ServerBuilder
ProtocolVersion replaces the documented protocol version. It is metadata, not a negotiation setting, and an empty string is accepted.
Example:
var configure asyncapi.ServerBuilderFunc = func(listener *asyncapi.ServerBuilder) {
listener.ProtocolVersion("1.0")
}
_ = configure
func (*ServerBuilder) Security ¶
func (listener *ServerBuilder) Security(ids ...string) *ServerBuilder
Security appends alternative security-scheme references (OR). Server and operation requirements apply independently (AND across these two levels). Referenced scheme IDs may be declared later; duplicates are errors.
Example:
var configure asyncapi.ServerBuilderFunc = func(listener *asyncapi.ServerBuilder) {
listener.Security("broker-login")
}
_ = configure
type ServerBuilderFunc ¶
type ServerBuilderFunc = func(*ServerBuilder)
ServerBuilderFunc configures one server before its detached publication. Retaining the draft cannot change a published document.
Example:
var configure asyncapi.ServerBuilderFunc = func(listener *asyncapi.ServerBuilder) {
listener.Description("Production broker")
}
_ = configure
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
graph
Package graph validates references in completed raw AsyncAPI documents.
|
Package graph validates references in completed raw AsyncAPI documents. |
|
schema
Package schema checks the self-contained Draft 7 documentation profile.
|
Package schema checks the self-contained Draft 7 documentation profile. |