Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.
Coding
Gen Asyncapi
Try itGenerates Go or TypeScript code from an AsyncAPI 3 spec, providing typed models, strict decoding, validation, message dispatch, and a WebSocket client.
What it does
Generates Go or TypeScript from an AsyncAPI 3 document: types, strict decoding with validation, message dispatch and a WebSocket client. The generated code is regular source that gets committed next to the spec and regenerated when the spec changes.
The skill document
gen-asyncapi
Generates Go or TypeScript from an AsyncAPI 3 document: types, strict decoding with validation, message dispatch and a WebSocket client. The generated code is regular source that gets committed next to the spec and regenerated when the spec changes.
Install paths, every config key and the generated API are in references/setup.md.
Security & safety
- The generator only reads the spec, the files it references and the config, and writes the single output file. It never runs code from the spec.
- Never hand-edit a
*.gen.goor*.gen.tsfile. Change the spec or the config and regenerate; the next run overwrites manual edits. - The generated client opens a connection only when your code dials one. Put tokens in
gorillaws.WithBearerTokenor the transport you build, never in the spec or config.
When to use
- A Go service or client talks to a WebSocket (or other message) API described by an AsyncAPI 3 spec and wants typed messages, strict decoding and a ready client.
- A web front end needs TypeScript types, validators and a client for the same spec.
- The repository already has a
gen.gowithgo tool gen-asyncapiand the spec or config changed.
When NOT to use
- The spec is AsyncAPI 2.x; the generator loads 3.x only.
- You only need to read a spec in Go, not generate code. Use go-asyncapi, the loader the generator is built on.
- HTTP APIs described by OpenAPI; this generator reads AsyncAPI only.
Go: set up
go get -tool github.com/psyb0t/gen-asyncapi/cmd/gen-asyncapi@latest
# config.yaml, next to gen.go
package: chat
output: chat.gen.go
// gen.go
package chat
//go:generate go tool gen-asyncapi --config=config.yaml ../../api/asyncapi.yaml
Run go generate ./.... Paths in the config and on the command line are relative to the directory holding gen.go.
Go: use the client
conn, err := gorillaws.Dial(ctx, chat.ServerProductionURL, gorillaws.WithBearerToken(token))
if err != nil {
return err
}
client := chat.NewClient(conn)
defer client.Close()
if err := client.JoinRoom(ctx, chat.JoinRequest{ID: id, Room: "lobby"}); err != nil {
return err // the payload failed Validate, or the write failed
}
type handler struct {
chat.UnimplementedHandler
}
func (handler) HandleAck(ctx context.Context, ack chat.Ack) error {
return nil
}
err = client.Run(ctx, handler{}) // reads until ctx ends or the connection drops
Send method names come from the operation names in the spec, handler methods are Handle, and const properties fill themselves in on marshal. Decoding errors wrap ctxerrors/commerr sentinels such as commerr.ErrValidationFailed and commerr.ErrRequiredFieldNotSet.
TypeScript
go run github.com/psyb0t/gen-asyncapi/cmd/gen-asyncapi@latest -language=typescript -o=src/chat.gen.ts asyncapi.yaml
const socket = new WebSocket(ServerProductionURL);
const client = new Client(socket);
await client.joinRoom({ type: "join", id: crypto.randomUUID(), room: "lobby" });
socket.addEventListener("message", (message) => {
client
.receive(message.data, {
handleAck: (ack) => render(ack.ok),
})
.catch(report);
});
In TypeScript, const properties are literal types the caller writes out. Validation failures throw ValidationError with a path; unmatched frames go to handleUnknownMessage or reject with UnknownMessageError.
Two messages with the same shape
When the client cannot tell incoming messages apart by const properties or strict decoding, pin each one with a JSON pointer in the config:
output-options:
message-matchers:
Notice:
/messages/0/type: notice
Alert:
/messages/0/type: alert
Related skills
Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.
Write, debug, and tune Playwright specs with locator strategy, trace diagnosis, and CI-aware timeouts.
Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.
Fetch raw ad creative, app, ranking, and revenue data from AdMapix as structured JSON.
Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.
More from psyb0t
Browse all skillsDrive a user-deployed mt5-httpapi MetaTrader 5 bridge over HTTP, with per-action confirmation on every real-money call.
Docker-packaged browser automation for QA against anti-bot stacks and authorized detection testing.
Self-hosted OpenAI-compatible speech service — transcription, translation, and synthesis from one container.
Run ffmpeg, sox, and ImageMagick jobs against your files in a fixed-allowlist SSH sandbox.
Generate speech audio via Qwen3-TTS over SSH with preset voices, voice cloning, and voice design.
Drive one or more IMAP/SMTP mailboxes through a single REST + MCP endpoint — read, search, send, mark-seen, and delete across accounts in parallel.