tags in AsyncAPI document
A tag is a label or category that groups related entities in an event-driven system.
In the AsyncAPI document, tags are defined as a list of tag objects within the tags object at the info level.
The individual tags field contains the following properties:
name: The name of the tag.description: A short description explaining the tag's purpose or usage.externalDocs: Additional external documentation for the tag.
Tags have different purposes depending on the context. They can either be used for consistent tag usage across the AsyncAPI document and logical component grouping or be applied to individual components like servers, channels, or operations for more specific purposes.
To reuse tags, you must define them in the components object of an AsyncAPI document and then use reference objects to include them.
tags in info object
Tags specified in the tags property of the info object categorize the entire AsyncAPI document. These globally defined tags provide an overarching context, representing key themes or functional areas within the event-driven system. They group elements like channels or servers by relevance, offering a holistic understanding of the application's structure.
Below is a visual representation of the tags object inside the info object in an AsyncAPI document:
Below is an example of the tags object inside the info object in an AsyncAPI document:
1asyncapi: 3.0.02info:3 title: AsyncAPI Documentation4 version: 1.0.05 description: |6 This AsyncAPI document provides an overview7 of the event-driven system8 tags:9 - name: Applications10 description: All applications related topics11 externalDocs:12 description: More info about applications13 url: https://applications.example.com/docs14 - name: Time15 description: All time related topics16 externalDocs:17 description: More info about time18 url: https://time.example.com/docs
tags in servers object
Tags specified in the tags property of the servers object categorize server configurations and characteristics. They allow for server categorization based on:
- criteria like location, environment type (like production or development), and unique server features.
- specific tags or labels.
Using the tags object under servers is optional.
Below is a visual representation of the tags object inside the servers object in an AsyncAPI document:
Below is an example of the tags object inside the servers object in an AsyncAPI document:
1asyncapi: 3.0.023info:4 title: AsyncAPI Documentation5 version: 1.0.067servers:8 development:9 host: localhost:567210 description: Development AMQP broker11 protocol: amqp12 protocolVersion: 0-9-113 tags:14 - name: env:development15 description: This environment is meant for developers to run their tests16 production:17 host: rabbitmq.in.mycompany.com:567218 description: RabbitMQ broker for the production environment19 protocol: amqp20 protocolVersion: 0-9-121 tags:22 - name: env:production23 description: This environment is the live environment available for final users
tags in channels object
Tags specified in the tags property of the channels object enable logical grouping and categorization based on specific functionalities or business domains.
Using the tags object under the channels object is optional.
Below is a visual representation of the tags object inside the channels object in an AsyncAPI document:
Below is an example of the tags object inside the channels object in an AsyncAPI document:
1asyncapi: 3.0.023info:4 title: AsyncAPI Documentation5 version: 1.0.067channels:8 SignedUp:9 address: 'user.signedup'10 messages:11 userSignedUp:12 payload:13 type: object14 tags:15 - name: user16 description: User-related messages
tags in operations object
Tags specified in the tags property of the operations object facilitate logical grouping and categorization of operation objects by type, functionality, and more.
Using the tags object under the operations object is optional.
Below is a visual representation of the tags object inside the operations object in an AsyncAPI document:
Below is an example of the tags object inside the operations object in an AsyncAPI document:
1operations:2 onUserSignUp:3 title: User sign up4 summary: Action to sign a user up5 description: A longer description6 channel:7 $ref: '#/channels/userSignup'8 action: send9 tags:10 - name: user11 description: operation related to user12 - name: signup13 description: operation related to a user's signUp14 - name: register15 description: operation related to a new registration16 bindings:17 amqp:18 ack: false19 traits:20 - $ref: '#/components/operationTraits/kafka'
tags in message object
Tags specified in the tags property of the message object group and categorize messages based on criteria, requirements, channels, and operations.
Using the tags object under the message object is optional.
Below is a visual representation of the tags object inside the message object in an AsyncAPI document:
Below is an example of the tags object inside the message object in an AsyncAPI document:
1 name: SimpleSignup2summary: A simple UserSignup example message3tags:4 - name: userSignUp5 description: some message related to user signup6headers:7 correlationId: my-correlation-id8 applicationInstanceId: myInstanceId9payload:10 user:11 someUserKey: someUserValue12 signup:13 someSignupKey: someSignupValue
Below is an example of all the tags defined in the components object and referenced in other components like servers and channels:
1asyncapi: 3.0.023components:4 tags:5 speech:6 name: Speech7 description: All speech related topics8 video:9 name: Video10 description: All video related topics1112info:13 title: AsyncAPI Documentation14 version: 1.0.015 description: |16 This AsyncAPI document provides an overview17 of the event-driven system18 tags:19 - $ref: '#/components/tags/speech'20 - $ref: '#/components/tags/video'2122servers:23 speech:24 host: localhost:567225 description: RabbitMQ broker for sending speech data26 protocol: amqp27 tags:28 - $ref: '#/components/tags/speech'29 video:30 host: localhost:567331 description: RabbitMQ broker for video information32 protocol: amqp33 tags:34 - $ref: '#/components/tags/video'3536channels:37 getSpeech:38 address: 'application/speech/get'39 servers:40 - $ref: '#/servers/speech'41 messages:42 voice:43 name: Voice44 summary: Add info about the voice stream data45 tags:46 - $ref: '#/components/tags/speech'47 getVideo:48 address: 'application/video/get'49 servers:50 - $ref: '#/servers/video'51 messages:52 voice:53 name: Video54 summary: Add info about the video data live bitrate and others55 tags:56 - $ref: '#/components/tags/video'5758operations:59 onVoiceStreamed:60 title: Get speech data61 channel:62 $ref: '#/channels/getSpeech'63 action: receive64 tags:65 - $ref: '#/components/tags/speech'6667 onVideoStreamed:68 title: Get video data69 channel:70 $ref: '#/channels/getVideo'71 action: receive72 tags:73 - $ref: '#/components/tags/video'