From a2e8fb790e5fd42fc68b8cfe0284edb8db66cbaa Mon Sep 17 00:00:00 2001 From: kaua-alves-queiros Date: Tue, 3 Feb 2026 19:50:58 -0400 Subject: [PATCH 1/7] feat(docs): add ChatId schema definition to swagger.json --- swagger.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/swagger.js b/swagger.js index ae36902..0381a8d 100644 --- a/swagger.js +++ b/swagger.js @@ -80,6 +80,11 @@ const doc = { GetSessionsResponse: { success: true, result: ['session1', 'session2'] + }, + ChatId: { + server: 'c.us | g.us', + user: '1234567890', + _serialized: '1234567890@c.us', } } } From e58bdf99338a7f56389a77327b351f16f5110eb5 Mon Sep 17 00:00:00 2001 From: kaua-alves-queiros Date: Tue, 3 Feb 2026 19:56:02 -0400 Subject: [PATCH 2/7] feat(docs): integrate ChatId and define base of Chat schema. --- swagger.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/swagger.js b/swagger.js index 0381a8d..98745cf 100644 --- a/swagger.js +++ b/swagger.js @@ -85,6 +85,18 @@ const doc = { server: 'c.us | g.us', user: '1234567890', _serialized: '1234567890@c.us', + }, + Chat: { + id: { $ref: '#/definitions/ChatId' }, + name: 'John Doe', + isGroup: false, + unreadCount: 0, + timestamp: 1770140061, + archived: false, + pinned: false, + isMuted: false, + muteExpiration: 0, + // Add other chat properties as needed after create definitions } } } From 018c4b6456438da87159697905aab90fa864a893 Mon Sep 17 00:00:00 2001 From: kaua-alves-queiros Date: Tue, 3 Feb 2026 19:59:43 -0400 Subject: [PATCH 3/7] feat(docs): add response schema for chat listing --- src/controllers/clientController.js | 21 +++++- swagger.js | 5 ++ swagger.json | 113 +++++++++++++++++++++++++++- 3 files changed, 133 insertions(+), 6 deletions(-) diff --git a/src/controllers/clientController.js b/src/controllers/clientController.js index 7ccbaba..d13f298 100644 --- a/src/controllers/clientController.js +++ b/src/controllers/clientController.js @@ -348,8 +348,16 @@ const getContacts = async (req, res) => { * @throws {Error} If the operation fails, an error is thrown. */ const getChats = async (req, res) => { - /* - #swagger.summary = 'Get all current chats' + /* #swagger.summary = 'Get all current chats' + #swagger.description = 'Retrieve all chats for the given session ID.' + #swagger.responses[200] = { + description: 'Retrieved all chats.', + content: { + 'application/json': { + schema: { "$ref": "#/definitions/GetChatsResponse" } + } + } + } */ try { const client = sessions.get(req.params.sessionId) @@ -377,6 +385,7 @@ const getChats = async (req, res) => { const getChatsWithSearch = async (req, res) => { /* #swagger.summary = 'Get all current chats with optional search parameters' + #swagger.description = 'Retrieve all chats for the given session ID with optional search parameters.' #swagger.requestBody = { required: true, schema: { @@ -399,6 +408,14 @@ const getChatsWithSearch = async (req, res) => { } }, } + #swagger.responses[200] = { + description: 'Retrieved all chats with search parameters.', + content: { + 'application/json': { + schema: {"$ref": "#/definitions/GetChatsResponse"} + } + } + } */ try { const { searchOptions = {} } = req.body diff --git a/swagger.js b/swagger.js index 98745cf..0f2bed7 100644 --- a/swagger.js +++ b/swagger.js @@ -97,6 +97,11 @@ const doc = { isMuted: false, muteExpiration: 0, // Add other chat properties as needed after create definitions + }, + GetChatsResponse: { + success: true, + chats: [ { $ref: '#/definitions/Chat' } ], + error: 'error message if any', } } } diff --git a/swagger.json b/swagger.json index 4b7a9a6..e677c9a 100644 --- a/swagger.json +++ b/swagger.json @@ -1541,7 +1541,7 @@ "Client" ], "summary": "Get all current chats", - "description": "", + "description": "Retrieve all chats for the given session ID.", "parameters": [ { "name": "sessionId", @@ -1556,7 +1556,14 @@ ], "responses": { "200": { - "description": "OK" + "description": "Retrieved all chats.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetChatsResponse" + } + } + } }, "403": { "description": "Forbidden.", @@ -1610,7 +1617,7 @@ "Client" ], "summary": "Get all current chats with optional search parameters", - "description": "", + "description": "Retrieve all chats for the given session ID with optional search parameters.", "parameters": [ { "name": "sessionId", @@ -1625,7 +1632,14 @@ ], "responses": { "200": { - "description": "OK" + "description": "Retrieved all chats with search parameters.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetChatsResponse" + } + } + } }, "403": { "description": "Forbidden.", @@ -15071,6 +15085,97 @@ "xml": { "name": "GetSessionsResponse" } + }, + "ChatId": { + "type": "object", + "properties": { + "server": { + "type": "string", + "example": "c.us | g.us" + }, + "user": { + "type": "string", + "example": "1234567890" + }, + "_serialized": { + "type": "string", + "example": "1234567890@c.us" + } + }, + "xml": { + "name": "ChatId" + } + }, + "Chat": { + "type": "object", + "properties": { + "id": { + "xml": { + "name": "chatid" + }, + "$ref": "#/components/schemas/ChatId" + }, + "name": { + "type": "string", + "example": "John Doe" + }, + "isGroup": { + "type": "boolean", + "example": false + }, + "unreadCount": { + "type": "number", + "example": 0 + }, + "timestamp": { + "type": "number", + "example": 1770140061 + }, + "archived": { + "type": "boolean", + "example": false + }, + "pinned": { + "type": "boolean", + "example": false + }, + "isMuted": { + "type": "boolean", + "example": false + }, + "muteExpiration": { + "type": "number", + "example": 0 + } + }, + "xml": { + "name": "Chat" + } + }, + "GetChatsResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "example": true + }, + "chats": { + "type": "array", + "items": { + "xml": { + "name": "chat" + }, + "$ref": "#/components/schemas/Chat" + } + }, + "error": { + "type": "string", + "example": "error message if any" + } + }, + "xml": { + "name": "GetChatsResponse" + } } }, "securitySchemes": { From e2dd22764789443d4b42c025d651783d391ca560 Mon Sep 17 00:00:00 2001 From: kaua-alves-queiros Date: Tue, 3 Mar 2026 09:59:11 -0400 Subject: [PATCH 4/7] feat(docs): enhance Swagger documentation for GetAllLabels endpoint --- src/controllers/clientController.js | 9 +++++ swagger.js | 8 ++++ swagger.json | 57 +++++++++++++++++++++++++++-- 3 files changed, 71 insertions(+), 3 deletions(-) diff --git a/src/controllers/clientController.js b/src/controllers/clientController.js index d13f298..2268853 100644 --- a/src/controllers/clientController.js +++ b/src/controllers/clientController.js @@ -883,6 +883,15 @@ const getLabelById = async (req, res) => { const getLabels = async (req, res) => { /* #swagger.summary = 'Get all current labels' + #swagger.description = 'Retrieve all labels for the given session ID.' + #swagger.responses[200] = { + description: 'Retrieved all chats.', + content: { + 'application/json': { + schema: { "$ref": "#/definitions/GetAllLabelsResponse" } + } + } + } */ try { const client = sessions.get(req.params.sessionId) diff --git a/swagger.js b/swagger.js index 0f2bed7..c99bfb6 100644 --- a/swagger.js +++ b/swagger.js @@ -102,6 +102,14 @@ const doc = { success: true, chats: [ { $ref: '#/definitions/Chat' } ], error: 'error message if any', + }, + Label: { + id: '1', + name: 'Not Read', + }, + GetAllLabelsResponse: { + success: true, + labels: [ { $ref: '#/definitions/Label' } ], } } } diff --git a/swagger.json b/swagger.json index e677c9a..a26ee17 100644 --- a/swagger.json +++ b/swagger.json @@ -2128,7 +2128,14 @@ ], "responses": { "200": { - "description": "OK" + "description": "Retrieved all chats.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetAllLabelsResponse" + } + } + } }, "403": { "description": "Forbidden.", @@ -2313,7 +2320,7 @@ "Client" ], "summary": "Get all current labels", - "description": "", + "description": "Retrieve all labels for the given session ID.", "parameters": [ { "name": "sessionId", @@ -2328,7 +2335,14 @@ ], "responses": { "200": { - "description": "OK" + "description": "Retrieved all chats.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetAllLabelsResponse" + } + } + } }, "403": { "description": "Forbidden.", @@ -15176,6 +15190,43 @@ "xml": { "name": "GetChatsResponse" } + }, + "Label": { + "type": "object", + "properties": { + "id": { + "type": "string", + "example": "1" + }, + "name": { + "type": "string", + "example": "Not Read" + } + }, + "xml": { + "name": "Label" + } + }, + "GetAllLabelsResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "example": true + }, + "labels": { + "type": "array", + "items": { + "xml": { + "name": "label" + }, + "$ref": "#/components/schemas/Label" + } + } + }, + "xml": { + "name": "GetAllLabelsResponse" + } } }, "securitySchemes": { From 6b0418cb020abf0789d3958c8f8dde338897ef05 Mon Sep 17 00:00:00 2001 From: kaua-alves-queiros Date: Tue, 3 Mar 2026 10:11:13 -0400 Subject: [PATCH 5/7] feat(docs): add Swagger documentation for GetLabelById response --- src/controllers/clientController.js | 8 ++++++++ swagger.js | 4 ++++ swagger.json | 27 ++++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/controllers/clientController.js b/src/controllers/clientController.js index 2268853..d64f3ac 100644 --- a/src/controllers/clientController.js +++ b/src/controllers/clientController.js @@ -859,6 +859,14 @@ const getLabelById = async (req, res) => { } }, } + #swagger.responses[200] = { + description: 'Retrieved the label.', + content: { + 'application/json': { + schema: { "$ref": "#/definitions/GetLabelByIdResponse" } + } + } + } */ try { const { labelId } = req.body diff --git a/swagger.js b/swagger.js index c99bfb6..9b73518 100644 --- a/swagger.js +++ b/swagger.js @@ -110,6 +110,10 @@ const doc = { GetAllLabelsResponse: { success: true, labels: [ { $ref: '#/definitions/Label' } ], + }, + GetLabelByIdResponse: { + success: true, + label: { $ref: '#/definitions/Label' }, } } } diff --git a/swagger.json b/swagger.json index a26ee17..5923fb8 100644 --- a/swagger.json +++ b/swagger.json @@ -2235,7 +2235,14 @@ ], "responses": { "200": { - "description": "OK" + "description": "Retrieved the label.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetLabelByIdResponse" + } + } + } }, "403": { "description": "Forbidden.", @@ -15227,6 +15234,24 @@ "xml": { "name": "GetAllLabelsResponse" } + }, + "GetLabelByIdResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "example": true + }, + "label": { + "xml": { + "name": "label" + }, + "$ref": "#/components/schemas/Label" + } + }, + "xml": { + "name": "GetLabelByIdResponse" + } } }, "securitySchemes": { From 8f6d8e51c7f9b698b787af844ed8c112d496f60d Mon Sep 17 00:00:00 2001 From: kaua-alves-queiros Date: Tue, 3 Mar 2026 11:41:43 -0400 Subject: [PATCH 6/7] fix(docs): correct Swagger documentation description for getLabels endpoint --- src/controllers/clientController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/clientController.js b/src/controllers/clientController.js index d64f3ac..03c99d8 100644 --- a/src/controllers/clientController.js +++ b/src/controllers/clientController.js @@ -893,7 +893,7 @@ const getLabels = async (req, res) => { #swagger.summary = 'Get all current labels' #swagger.description = 'Retrieve all labels for the given session ID.' #swagger.responses[200] = { - description: 'Retrieved all chats.', + description: 'Retrieved all labels.', content: { 'application/json': { schema: { "$ref": "#/definitions/GetAllLabelsResponse" } From a599b36c04dc8a799524a12bba81d7a907ac43f5 Mon Sep 17 00:00:00 2001 From: kaua-alves-queiros Date: Tue, 3 Mar 2026 12:04:54 -0400 Subject: [PATCH 7/7] docs: improve swagger documentation by adding new response schemas, updating definition names for labels, and documenting getChatLabels, getChatsByLabelId, and addOrRemoveLabels endpoints --- src/controllers/clientController.js | 28 ++++++++- swagger.js | 15 ++++- swagger.json | 88 +++++++++++++++++++++++------ 3 files changed, 109 insertions(+), 22 deletions(-) diff --git a/src/controllers/clientController.js b/src/controllers/clientController.js index 03c99d8..e286e18 100644 --- a/src/controllers/clientController.js +++ b/src/controllers/clientController.js @@ -665,6 +665,14 @@ const getChatLabels = async (req, res) => { } }, } + #swagger.responses[200] = { + description: 'Retrieved all labels for the chat.', + content: { + 'application/json': { + schema: { "$ref": "#/definitions/GetChatLabelsResponse" } + } + } + } */ try { const { chatId } = req.body @@ -704,6 +712,14 @@ const getChatsByLabelId = async (req, res) => { } }, } + #swagger.responses[200] = { + description: 'Retrieved all chats.', + content: { + 'application/json': { + schema: { "$ref": "#/definitions/GetChatsResponse" } + } + } + } */ try { const { labelId } = req.body @@ -863,7 +879,7 @@ const getLabelById = async (req, res) => { description: 'Retrieved the label.', content: { 'application/json': { - schema: { "$ref": "#/definitions/GetLabelByIdResponse" } + schema: { "$ref": "#/definitions/GetLabelResponse" } } } } @@ -896,7 +912,7 @@ const getLabels = async (req, res) => { description: 'Retrieved all labels.', content: { 'application/json': { - schema: { "$ref": "#/definitions/GetAllLabelsResponse" } + schema: { "$ref": "#/definitions/GetLabelsResponse" } } } } @@ -940,6 +956,14 @@ const addOrRemoveLabels = async (req, res) => { } }, } + #swagger.responses[200] = { + description: 'Labels changed successfully.', + content: { + 'application/json': { + schema: { "$ref": "#/definitions/SuccessResponse" } + } + } + } */ try { const { labelIds, chatIds } = req.body diff --git a/swagger.js b/swagger.js index 9b73518..b1dd1a3 100644 --- a/swagger.js +++ b/swagger.js @@ -1,3 +1,5 @@ +const { getChatLabels } = require('./src/controllers/clientController') + const swaggerAutogen = require('swagger-autogen')({ openapi: '3.0.0', autoBody: false }) const outputFile = './swagger.json' @@ -81,6 +83,9 @@ const doc = { success: true, result: ['session1', 'session2'] }, + SuccessResponse: { + success: true, + }, ChatId: { server: 'c.us | g.us', user: '1234567890', @@ -107,13 +112,17 @@ const doc = { id: '1', name: 'Not Read', }, - GetAllLabelsResponse: { + GetLabelResponse: { + success: true, + label: { $ref: '#/definitions/Label' }, + }, + GetLabelsResponse: { success: true, labels: [ { $ref: '#/definitions/Label' } ], }, - GetLabelByIdResponse: { + GetChatLabelsResponse: { success: true, - label: { $ref: '#/definitions/Label' }, + chatLabels: [ { $ref: '#/definitions/Label' } ], } } } diff --git a/swagger.json b/swagger.json index 5923fb8..c34ea3d 100644 --- a/swagger.json +++ b/swagger.json @@ -1456,7 +1456,14 @@ ], "responses": { "200": { - "description": "OK" + "description": "Retrieved all labels for the chat.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetChatLabelsResponse" + } + } + } }, "403": { "description": "Forbidden.", @@ -1757,7 +1764,14 @@ ], "responses": { "200": { - "description": "OK" + "description": "Retrieved all chats.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetChatsResponse" + } + } + } }, "403": { "description": "Forbidden.", @@ -2128,11 +2142,11 @@ ], "responses": { "200": { - "description": "Retrieved all chats.", + "description": "Labels changed successfully.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GetAllLabelsResponse" + "$ref": "#/components/schemas/SuccessResponse" } } } @@ -2239,7 +2253,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GetLabelByIdResponse" + "$ref": "#/components/schemas/GetLabelResponse" } } } @@ -2342,11 +2356,11 @@ ], "responses": { "200": { - "description": "Retrieved all chats.", + "description": "Retrieved all labels.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GetAllLabelsResponse" + "$ref": "#/components/schemas/GetLabelsResponse" } } } @@ -2420,7 +2434,14 @@ ], "responses": { "200": { - "description": "OK" + "description": "Labels changed successfully.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SuccessResponse" + } + } + } }, "403": { "description": "Forbidden.", @@ -15107,6 +15128,18 @@ "name": "GetSessionsResponse" } }, + "SuccessResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "example": true + } + }, + "xml": { + "name": "SuccessResponse" + } + }, "ChatId": { "type": "object", "properties": { @@ -15214,7 +15247,25 @@ "name": "Label" } }, - "GetAllLabelsResponse": { + "GetLabelResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "example": true + }, + "label": { + "xml": { + "name": "label" + }, + "$ref": "#/components/schemas/Label" + } + }, + "xml": { + "name": "GetLabelResponse" + } + }, + "GetLabelsResponse": { "type": "object", "properties": { "success": { @@ -15232,25 +15283,28 @@ } }, "xml": { - "name": "GetAllLabelsResponse" + "name": "GetLabelsResponse" } }, - "GetLabelByIdResponse": { + "GetChatLabelsResponse": { "type": "object", "properties": { "success": { "type": "boolean", "example": true }, - "label": { - "xml": { - "name": "label" - }, - "$ref": "#/components/schemas/Label" + "chatLabels": { + "type": "array", + "items": { + "xml": { + "name": "label" + }, + "$ref": "#/components/schemas/Label" + } } }, "xml": { - "name": "GetLabelByIdResponse" + "name": "GetChatLabelsResponse" } } },