Created
November 21, 2024 16:34
-
-
Save AceTheCreator/1651bd1fa1eed947441e5828d357ac4f to your computer and use it in GitHub Desktop.
Simple Chat Application AsyncAPI Document
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
asyncapi: 3.0.0 | |
info: | |
title: Simple Chat API | |
version: 1.0.0 | |
description: A simple real-time chat API using WebSocket protocol | |
servers: | |
production: | |
host: chat.example.com | |
protocol: ws | |
description: Production server | |
security: | |
- $ref: '#/components/securitySchemes/apiKeyHeader' | |
channels: | |
chat: | |
address: / | |
bindings: | |
ws: | |
query: | |
type: object | |
properties: | |
roomId: | |
type: string | |
descritpion: The unique identifier of the chat room | |
pattern: ^[a-zA-Z0-9-]+$ | |
additionalProperties: false | |
messages: | |
chatMessage: | |
$ref: '#/components/messages/chat' | |
userJoined: | |
description: Event when a user joins the chat room | |
$ref: '#/components/messages/status' | |
userLeft: | |
description: Event when a user leaves the chat room | |
$ref: '#/components/messages/status' | |
operations: | |
sendMessage: | |
action: send | |
channel: | |
$ref: '#/channels/chat' | |
messages: | |
- $ref: '#/channels/chat/messages/chatMessage' | |
summary: Send a chat message | |
description: Allows users to send messages to the chat room | |
receiveMessage: | |
action: receive | |
channel: | |
$ref: '#/channels/chat' | |
messages: | |
- $ref: '#/channels/chat/messages/chatMessage' | |
summary: Receive chat messages | |
description: Allows users to receive messages from the chat room | |
userJoin: | |
action: receive | |
channel: | |
$ref: '#/channels/chat' | |
messages: | |
- $ref: '#/channels/chat/messages/userJoined' | |
summary: User join notification | |
description: Notifies when a new user joins the chat room | |
userLeave: | |
action: receive | |
channel: | |
$ref: '#/channels/chat' | |
messages: | |
- $ref: '#/channels/chat/messages/userLeft' | |
summary: User leave notification | |
description: Notifies when a user leaves the chat room | |
components: | |
messages: | |
chat: | |
description: A message sent in the chat room | |
payload: | |
type: object | |
properties: | |
messageId: | |
type: string | |
format: uuid | |
description: Unique identifier for the message | |
senderId: | |
type: string | |
description: ID of the user sending the message | |
content: | |
type: string | |
maxLength: 1000 | |
description: The message content | |
timestamp: | |
type: string | |
format: date-time | |
description: Time when the message was sent | |
required: | |
- messageId | |
- senderId | |
- content | |
- timestamp | |
status: | |
payload: | |
type: object | |
properties: | |
userId: | |
type: string | |
description: ID of the user status[join/leave] | |
type: | |
type: string | |
enum: | |
- join | |
- leave | |
username: | |
type: string | |
description: Display name of the user | |
timestamp: | |
type: string | |
format: date-time | |
required: | |
- userId | |
- username | |
- timestamp | |
securitySchemes: | |
apiKeyHeader: | |
type: httpApiKey | |
in: header | |
name: X-API-Key | |
description: API key passed in header |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment