Skip to content

API documentation with OpenAPI and AsyncAPI: specs and an interface catalog

B2Bnetwork team · · 5 min

Integrations, data and cloud

In brief

Integration documentation belongs in files in the code repository, not in a Word document. OpenAPI describes REST interfaces: paths, requests, responses and errors. AsyncAPI describes messages on queues and Kafka topics. An interface catalog lists every connection in one place with its owner, version and consumers. The files generate the documentation site, contract tests and mocks, and a CI check catches any change that would break a consumer.

Three layers of documentation

Questions about an integration come at three levels. A partner's developer asks how to call an operation. A team that consumes events asks what a message looks like. An architect or auditor asks which systems connect at all and who is responsible. Each level has its own document.

LayerWhat it describesStandardWho reads it
request and response interfacespaths, parameters, bodies, error codes, authenticationOpenAPIdevelopers of API clients, testers
messages and eventschannels, send and receive operations, message shape, broker settingsAsyncAPIteams producing and consuming events
the map of connectionswhich systems connect, owner, version, data, monitoringinterface catalogarchitects, operations, audit

OpenAPI in practice

The current version of the specification is OpenAPI 3.2.1, published in September 2026 as a patch to 3.2.0 from September 2025. Data schemas are written in the JSON Schema vocabulary, and a separate `webhooks` field describes messages your system sends to its consumers. A good specification contains more than a list of paths:

  • examples of requests and responses for every operation, including the error case;
  • errors in a single format, for example following RFC 9457 (problem details): type, title, detail, the field concerned;
  • authentication: which OAuth flow, which scopes for which operation;
  • pagination, rate limits and idempotency: how to fetch the next page, how many requests per minute, which header prevents an order from being created twice;
  • field descriptions in business language: "the date from which the policy covers the customer", not "start date".
openapi: 3.2.0
info:
  title: API zamówień
  version: 2.3.0
paths:
  /zamowienia:
    post:
      summary: Utwórz zamówienie
      parameters:
        - name: Idempotency-Key
          in: header
          required: true
          schema: { type: string }
      responses:
        "201": { description: Zamówienie utworzone }
        "409": { description: Zamówienie z tym kluczem już istnieje }

AsyncAPI for events and queues

Event-driven integrations are usually documented worse than REST, because there is no URL you can open in a browser. AsyncAPI 3.0.0 describes servers (brokers), channels, send and receive operations, and messages. Broker-specific settings, such as the partition key in Kafka or the queue in AMQP, go into the bindings section.

asyncapi: 3.0.0
info:
  title: Zdarzenia magazynu
  version: 1.4.0
channels:
  stanyZmienione:
    address: magazyn.stany.zmienione.v1
    messages:
      stanZmieniony:
        payload:
          type: object
          required: [indeks, magazyn, ilosc, wersja]
operations:
  publikujStan:
    action: send
    channel: { $ref: "#/channels/stanyZmienione" }

The most important information in event documentation is the guarantees: can a message arrive twice, is ordering preserved per key, how long does the broker keep history. Without that, the consuming team guesses, and guessing ends with double bookings. The same questions apply to webhooks, as covered in Reliable webhooks.

The interface catalog

The catalog is a register of every connection between systems, including those without a specification: SFTP file transfers, EDI exchanges, a database view read by a report. A simple table is enough, as long as it is current.

FieldExample
name and IDINT-042 Orders from the online store to the ERP
ownerdigital sales team, contact person
producer and consumersstore → ERP, warehouse
technology and specificationREST, link to the OpenAPI file in the repository
version and status2.3, active; 1.x being retired by the end of the quarter
personal datayes: customer name, address, phone
expected volume and hours2,000–5,000 messages a day, evening peak
monitoringlink to the dashboard and alert

The catalog answers questions that come up with every change and every audit: who is affected when an old system is switched off, where personal data flows, who picks up the phone at night. In financial services, such a register also helps meet DORA's requirements on identifying ICT assets and the dependencies between them (Article 8).

Documentation in the delivery process

Documentation stays current only when changing it is part of changing the code. Two approaches work in practice:

  1. Contract first. The team writes the specification and agrees it with consumers before writing code. Consumers can start work right away against a mock generated from the specification.
  2. Specification from code. A library generates the file from code annotations on every build. Faster at the start, but descriptions and examples still have to be written by hand.

Either way, the CI pipeline should validate the file, compare it with the previous version and stop breaking changes (a removed field, a new required field, a changed type), publish the documentation site and run contract tests. How contract tests work is described in API contract testing, and the role of the gateway in API gateway.

At B2Bnetwork we build documentation and contracts together with the integrations themselves, as part of our System integration service. One example is the API platform for comparison sites and multi-agencies, where every intermediary uses a single API described by an OpenAPI contract.

Questions and answers

Where do we start when nobody has documented the integrations?

With the catalog, not the specifications. List the connections from logs, API gateway configuration, job schedules and conversations with teams, and record an owner for each. Then describe in OpenAPI or AsyncAPI the interfaces that change most often or have the most consumers. The rest can wait.

OpenAPI or AsyncAPI for Kafka topics?

AsyncAPI. OpenAPI describes request and response communication over HTTP, while AsyncAPI describes channels, send and receive operations and broker settings. Message schemas can live in one place and be referenced from both specifications, and with Kafka also from a schema registry.

Who should maintain the documentation?

The team that owns the interface, because only it changes the code. An architect or integration team looks after shared rules: the error format, naming, versioning and the catalog. A change without an updated specification should not pass code review or the CI pipeline.

Can documentation be generated entirely from code?

The skeleton, yes: paths, parameters, types. Field descriptions in business language, examples, delivery guarantees and versioning rules are written by a person. A generated specification without them tells you how to call an operation, but not what to do with the response.

What it looks like in a project

Connecting systems or moving them to the cloud? Talk to an architect.

Let's talk

Read more: Integrations, data and cloud

All in Integrations, data and cloud →