Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/controllers/clientController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions swagger.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -81,6 +83,9 @@ const doc = {
success: true,
result: ['session1', 'session2']
},
SuccessResponse: {
success: true,
},
ChatId: {
server: 'c.us | g.us',
user: '1234567890',
Expand All @@ -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' } ],
}
}
}
Expand Down
144 changes: 137 additions & 7 deletions swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -1757,7 +1764,14 @@
],
"responses": {
"200": {
"description": "OK"
"description": "Retrieved all chats.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetChatsResponse"
}
}
}
},
"403": {
"description": "Forbidden.",
Expand Down Expand Up @@ -2128,7 +2142,14 @@
],
"responses": {
"200": {
"description": "OK"
"description": "Labels changed successfully.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SuccessResponse"
}
}
}
},
"403": {
"description": "Forbidden.",
Expand Down Expand Up @@ -2228,7 +2249,14 @@
],
"responses": {
"200": {
"description": "OK"
"description": "Retrieved the label.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetLabelResponse"
}
}
}
},
"403": {
"description": "Forbidden.",
Expand Down Expand Up @@ -2313,7 +2341,7 @@
"Client"
],
"summary": "Get all current labels",
"description": "",
"description": "Retrieve all labels for the given session ID.",
"parameters": [
{
"name": "sessionId",
Expand All @@ -2328,7 +2356,14 @@
],
"responses": {
"200": {
"description": "OK"
"description": "Retrieved all labels.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetLabelsResponse"
}
}
}
},
"403": {
"description": "Forbidden.",
Expand Down Expand Up @@ -2399,7 +2434,14 @@
],
"responses": {
"200": {
"description": "OK"
"description": "Labels changed successfully.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SuccessResponse"
}
}
}
},
"403": {
"description": "Forbidden.",
Expand Down Expand Up @@ -15196,6 +15238,18 @@
"name": "GetSessionsResponse"
}
},
"SuccessResponse": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
}
},
"xml": {
"name": "SuccessResponse"
}
},
"ChatId": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -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": {
Expand Down