diff --git a/src/controllers/clientController.js b/src/controllers/clientController.js index d13f298..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 @@ -859,6 +875,14 @@ const getLabelById = async (req, res) => { } }, } + #swagger.responses[200] = { + description: 'Retrieved the label.', + content: { + 'application/json': { + schema: { "$ref": "#/definitions/GetLabelResponse" } + } + } + } */ try { const { labelId } = req.body @@ -883,6 +907,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 labels.', + content: { + 'application/json': { + schema: { "$ref": "#/definitions/GetLabelsResponse" } + } + } + } */ try { const client = sessions.get(req.params.sessionId) @@ -923,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 0f2bed7..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', @@ -102,6 +107,22 @@ const doc = { success: true, chats: [ { $ref: '#/definitions/Chat' } ], error: 'error message if any', + }, + Label: { + id: '1', + name: 'Not Read', + }, + GetLabelResponse: { + success: true, + label: { $ref: '#/definitions/Label' }, + }, + GetLabelsResponse: { + success: true, + labels: [ { $ref: '#/definitions/Label' } ], + }, + GetChatLabelsResponse: { + success: true, + chatLabels: [ { $ref: '#/definitions/Label' } ], } } } diff --git a/swagger.json b/swagger.json index f051151..5d89a1b 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,7 +2142,14 @@ ], "responses": { "200": { - "description": "OK" + "description": "Labels changed successfully.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SuccessResponse" + } + } + } }, "403": { "description": "Forbidden.", @@ -2228,7 +2249,14 @@ ], "responses": { "200": { - "description": "OK" + "description": "Retrieved the label.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetLabelResponse" + } + } + } }, "403": { "description": "Forbidden.", @@ -2313,7 +2341,7 @@ "Client" ], "summary": "Get all current labels", - "description": "", + "description": "Retrieve all labels for the given session ID.", "parameters": [ { "name": "sessionId", @@ -2328,7 +2356,14 @@ ], "responses": { "200": { - "description": "OK" + "description": "Retrieved all labels.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetLabelsResponse" + } + } + } }, "403": { "description": "Forbidden.", @@ -2399,7 +2434,14 @@ ], "responses": { "200": { - "description": "OK" + "description": "Labels changed successfully.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SuccessResponse" + } + } + } }, "403": { "description": "Forbidden.", @@ -15196,6 +15238,18 @@ "name": "GetSessionsResponse" } }, + "SuccessResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "example": true + } + }, + "xml": { + "name": "SuccessResponse" + } + }, "ChatId": { "type": "object", "properties": { @@ -15286,6 +15340,82 @@ "xml": { "name": "GetChatsResponse" } + }, + "Label": { + "type": "object", + "properties": { + "id": { + "type": "string", + "example": "1" + }, + "name": { + "type": "string", + "example": "Not Read" + } + }, + "xml": { + "name": "Label" + } + }, + "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": { + "type": "boolean", + "example": true + }, + "labels": { + "type": "array", + "items": { + "xml": { + "name": "label" + }, + "$ref": "#/components/schemas/Label" + } + } + }, + "xml": { + "name": "GetLabelsResponse" + } + }, + "GetChatLabelsResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "example": true + }, + "chatLabels": { + "type": "array", + "items": { + "xml": { + "name": "label" + }, + "$ref": "#/components/schemas/Label" + } + } + }, + "xml": { + "name": "GetChatLabelsResponse" + } } }, "securitySchemes": {