The AsyncAPI Specification defines a set of fields that can be used in an AsyncAPI document to describe an application’s API. While the document may reference other files for additional details or shared fields, it usually serves as a single, primary document that encapsulates the API description.
Furthermore, the AsyncAPI document acts as a communication contract between receivers and senders within an event-driven system. It specifies the payload content necessary for a service to send a message and provides clear guidance to the receiver about the message's properties.
1asyncapi: 3.0.0
2info:
3 title: Cool Example
4 version: 0.1.0
5channels:
6 userSignedUp:
7 address: user/signedup
8 messages:
9 userSignedUp:
10 description: An event describing that a user just signed up.
11 payload:
12 type: object
13 properties:
14 fullName:
15 type: string
16 email:
17 type: string
18 format: email
19 age:
20 type: integer
21 minimum: 18
22operations:
23 userSignedUp:
24 action: send
25 channel:
26 $ref: '#/channels/userSignedUp'
Remember
Depending on the implemented protocol (such as MQTT, AMQP, Kafka, etc.), you may have additional fields in your AsyncAPI document. For example, for configuring Kafka bindings.