-
-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: introduce AsyncAPI document #1868
Changes from 2 commits
794df9f
ec1a11f
e85bc07
6c2a3ca
96f9e6e
ab377cd
48f1e25
2293882
609a499
b57b70a
7e8e288
a9a89be
df73a80
e288e2f
8e3dbd0
adaae21
f5895b4
49ba858
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
title: 'AsyncAPI Document' | ||
weight: 50 | ||
--- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
title: 'Introduction' | ||
weight: 1 | ||
quetzalliwrites marked this conversation as resolved.
Show resolved
Hide resolved
|
||
--- | ||
|
||
quetzalliwrites marked this conversation as resolved.
Show resolved
Hide resolved
|
||
The AsyncAPI document is a YAML or JSON file that describes your implementation of the AsyncAPI specification. Providing a standardized way to document and describe asynchronous and event-driven systems, the AsyncAPI document generates documentation/code and defines the different components of your event-driven application, such as the events, channels, and message formats. | ||
quetzalliwrites marked this conversation as resolved.
Show resolved
Hide resolved
quetzalliwrites marked this conversation as resolved.
Show resolved
Hide resolved
quetzalliwrites marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Primarily, it provides a method to produce comprehensive, consistent, and standardized AsyncAPI documentation. Additionally, it serves as a contract for communication between consumers and producers in an event-driven system. It specifies what should be included in the payload when a service produces a message and provides information to the consumer about the properties in the message. | ||
quetzalliwrites marked this conversation as resolved.
Show resolved
Hide resolved
quetzalliwrites marked this conversation as resolved.
Show resolved
Hide resolved
quetzalliwrites marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```YAML | ||
asyncapi: 3.0.0 | ||
info: | ||
title: Cool Example | ||
version: 0.1.0 | ||
channels: | ||
user/signedup: | ||
subscribe: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually an invalid document. Version 3 changed how channels, operations, and messages are described and linked. Ok, probably too much info there to digest 😓 . Let's start with some of the changes in v3 that affect this example:
Applying all the previous, your document will look like this: asyncapi: 3.0.0
info:
title: Cool Example
version: 0.1.0
channels:
userSignedUp:
address: user/signedup
messages:
userSignedUp:
description: An event describing that a user just signed up.
payload:
type: object
additionalProperties: false
properties:
fullName:
type: string
email:
type: string
format: email
age:
type: integer
minimum: 18
operations:
userSignedUp:
action: send
channel:
$ref: '#/channels/userSignedUp' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whoa, this was a lot of info but I really appreciate how fully you described everything. Thank you 🙏 !!! One thing slightly confuses me... When you wrote
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reality is that the approach or point of view of the documented API changes. In v3, we now clearly state that:
Meaning the document describes the API of the application that offers the AsyncAPI document. |
||
message: | ||
description: An event describing that a user just signed up. | ||
payload: | ||
type: object | ||
additionalProperties: false | ||
quetzalliwrites marked this conversation as resolved.
Show resolved
Hide resolved
|
||
properties: | ||
fullName: | ||
type: string | ||
email: | ||
type: string | ||
format: email | ||
age: | ||
type: integer | ||
minimum: 18 | ||
``` | ||
|
||
## AsyncAPI document components | ||
quetzalliwrites marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The AsyncAPI document follows a specific structure with certain headers or fields: | ||
quetzalliwrites marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- **`asyncapi`**: This is a required field that specifies the AsyncAPI specification version that your document adheres to. | ||
|
||
- **`info`**: This required field holds metadata about the API. The `info` section must include the following sub-fields: | ||
|
||
- `title`: A descriptive title of the API. | ||
|
||
- `version`: An API version identifier. | ||
|
||
Optional fields within the `info` section could include `description`, `termsOfService`, `contact` (with subfields for `name`, `url`, `email`), and `license` (with `name` and `url` subfields). | ||
|
||
- **`servers`**: An optional field specifying the server(s) where the API is available. Each server must have a `url` and may have `protocol`, `protocolVersion`, `description`, `variables`, `security`, and `bindings`. | ||
|
||
- **`channels`**: This required field describes the paths available to the API and must include at least one channel. Each channel could include fields such as `description`, `subscribe`, `publish`, `parameters`, and `bindings`. | ||
|
||
- **`components`**: An optional section for defining reusable components like `messages`, `schemas`, `securitySchemes`, and others. | ||
|
||
- **`tags`**: An optional array of tags used by the specification with additional metadata. Each tag object can have `name` and `description`. | ||
|
||
- **`externalDocs`**: An optional section to provide more information, such as a link to the API’s external documentation with a `description` and a `url`. | ||
quetzalliwrites marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
<Remember> | ||
You might have additional fields depending on the implemented protocol (i.e., MQTT, AMQP, Kafka, etc.). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would clarify this with an example There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you, noted. Added an example, you let me know if you like it.
quetzalliwrites marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</Remember> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with subsections it works this way that the "starting weight" is the weight of the
_section.md
so change it to 50 or more and all the next documents should follow. This way you fix preview and make sure it shows in the UI