Skip to content

AsyncAPI documentation: render it locally, then publish it from Git

Last checked and updated

An AsyncAPI document is meant to be read by the teams that send or receive its messages, so the usual way to share it is a documentation page: the servers, then every channel with its messages and payload fields, then the operations. With APIGit you check it with apigit lint, look at the page with apigit preview before you commit, and publish a version from a commit. AsyncAPI 2.x and 3.x files are both rendered.

1. Check the file

$ apigit lint asyncapi.yaml
asyncapi.yaml
  1:11  info   asyncapi-latest-version  The latest version is not used. You should update to the "3.1.0" version.  (asyncapi)

1 problem (0 errors, 0 warnings, 1 info, 0 hints)

The file is the order service from AsyncAPI channels, operations and messages. What makes the rendered page useful is what the linter's warnings ask for: an info.description (CommonMark, in AsyncAPI 3.0), a contact, a server, and a description on each operation. Lint an AsyncAPI file lists them.

2. See the page before you commit

In the folder of a git repository:

$ apigit preview --port 4713 --no-open
Site settings: none (no repository found); showing the default look
Preview of .../order-events at http://127.0.0.1:4713/ (Ctrl+C to stop)

The first run downloads the viewer of the published pages (the CLI documentation gives about 9 MB) and keeps it; later runs work offline. The page reloads when you save. The first line means the folder is not a clone of a repository on APIGit, so the preview uses the default look; in a clone, signed in, it reads the repository's saved site settings. Without --port it listens on 4011, and without --no-open it opens the browser.

The page for this file showed, from top to bottom:

  • the title and version (Orders events 1.0.0), the description, the contact (name, URL, email) and the license;
  • Servers: production, broker.example.com:5672;
  • the channel orders.created, "Accepts the following message:", the orderCreated payload as a table of fields and a generated sample, {"orderId": "string", "total": 0};
  • the operation publishOrderCreated under Send, with its description.

What the preview shows is your working copy: the files git tracks plus new ones it does not ignore, with uncommitted edits. A file that does not parse is shown with the error and its source instead of a reference.

3. Commit, push, publish

A publish uses a commit that is already on APIGit. A version is "a name pointing at a commit", and it includes "the OpenAPI specs, AsyncAPI documents and GraphQL schemas at that commit", the Markdown documents, and "the navigation and theme from that commit's apigit.json".

In the browser: open the repository, switch to the branch, click Publish and choose Publish API & Doc; the dialog asks for a version name, the update strategy (pin to the commit, or follow the branch on paid plans) and the access. From a terminal, in a clone:

$ apigit --dry-run doc publish --version 1.0.0 --access public -R acme/order-events
Using HEAD a88a67f of the working directory (it must be pushed)
Would send POST /api/v1/app/apispec/acme/order-events/create
{
  "version": "1.0.0",
  "commit_sha": "a88a67fe38a3a3536b489129bdf0fce46183434d",
  "access": 2,
  "enable_tryit": false
}

--dry-run prints the request and sends nothing; without it, the same command publishes. Inside a clone whose origin is the repository on APIGit, -R is not needed; outside one, the command stops with error: no repository: pass -R <owner>/<name>, set "repo" in apigit.yaml, or run inside a clone whose origin is the APIGit repository. --access takes member, public or viewers; the default is member.

What a published AsyncAPI version has

AsyncAPINote
Reference page with servers, channels, messages, operationsYesthe page above
Navigation and theme from apigit.jsonYeslist the file by its repository path
Copy page and original-file downloadYesthe browser also offers a bundled download
One generated Markdown page for AI agents, in llms.txt and the document MCP searchYesper file, not per operation
Try It OutNoOpenAPI only
Mock serverNo"It does not run an event broker or provide an AsyncAPI mock server."

To put several files in one site, an event API beside a REST API and a GraphQL schema, see GraphQL and OpenAPI in one repository; the same apigit.json lists an AsyncAPI file by its path.

Sources

Related pages

  • AsyncAPI linter: every finding apigit lint reports, with its fix

    apigit lint checks AsyncAPI 2.x and 3.x files offline with Spectral's AsyncAPI rules. The findings it printed on real documents, what each rule asks for, how to fix it, how to change the rule set, and the version string that stops every rule.

  • AsyncAPI 2 to 3 migration: the same API in 2.6 and 3.0, side by side

    One small event API written in AsyncAPI 2.6 and in 3.0: publish and subscribe become operations with action send or receive, the channel key becomes an id with an address, messages move under the channel, servers split url into host and pathname. With the linter's output for each version and for a 2.6 file that only had its version changed.

  • AsyncAPI channels, operations and messages: the 3.0 structure, step by step

    In AsyncAPI 3.0 a channel is an address with the messages on it, an operation says whether the application sends to or receives from a channel, and messages live under the channel. Each part built up in a working document, with the linter's message when it is missing or wrong, and four mistakes the linter does not catch.

  • What is AsyncAPI? A minimal 3.0 document, linted and rendered

    AsyncAPI describes message-driven APIs: the channels an application sends to or receives from, and the messages on them. How it differs from OpenAPI, a 21-line AsyncAPI 3.0 document, what a linter says about it, and how it renders as documentation.

Try it with your own API

Create a free workspace, add an OpenAPI file, and publish its documentation and a mock server from the same repository.

Free for individuals. No credit card.

$ npm install -g @apigit/cli$ apigit auth login$ apigit doc publish