go-asyncapi
Loads AsyncAPI 3 documents in Go. Point asyncapi.Load at a YAML or JSON file and you get servers, channels, operations and messages as plain structs, with every $ref followed, across files too, and every message and operation trait merged in. gen-asyncapi is built on it.
It reads and resolves, nothing more. It does not validate messages against their schemas and it does not generate code. Payload and header schemas come back as ordered trees for you to walk.
Install
go get github.com/psyb0t/go-asyncapi
The package name is asyncapi and the module path ends in go-asyncapi, so import it with an explicit name:
import asyncapi "github.com/psyb0t/go-asyncapi"
The module declares go 1.26.10 in its go.mod. Its only runtime dependencies are ctxerrors and gopkg.in/yaml.v3.
Quick look
document, err := asyncapi.Load("asyncapi.yaml")
if err != nil {
return err
}
for _, server := range document.Servers {
fmt.Println(server.Name, server.URL()) // production wss://eu.example.com:443/v2/ws
}
for _, operation := range document.Operations {
for _, message := range operation.Messages {
fmt.Println(operation.Action, operation.Channel.Address, message.Name)
}
}
Where to go next
| You want to | Read |
|---|---|
Know what Load reads, what it skips, and how $refs and traits behave | Loading documents |
Walk a payload or header schema and follow the $refs inside it | Walking schemas |
| Look up a type, field or method | API reference |
Match a failure with errors.Is | Errors |
| Teach a coding agent to use the library | Agent skill |
| Build, lint and test the library itself | Development |
The Go package docs are on pkg.go.dev, and the source is on GitHub.