From 11eb22f5bbadbd4e19067cb1e639d7ef34c8c671 Mon Sep 17 00:00:00 2001
From: Anton Voylenko <anton.voylenko@gmail.com>
Date: Fri, 16 Feb 2024 12:00:33 +0200
Subject: [PATCH] fix swagger servers and error logging

---
 src/utils.js |  2 +-
 swagger.js   | 10 ++++++++++
 swagger.json | 10 +++++++++-
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/utils.js b/src/utils.js
index 819841dd..8943a42d 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -4,7 +4,7 @@ const { globalApiKey, disabledCallbacks } = require('./config')
 // Trigger webhook endpoint
 const triggerWebhook = (webhookURL, sessionId, dataType, data) => {
   axios.post(webhookURL, { dataType, data, sessionId }, { headers: { 'x-api-key': globalApiKey } })
-    .catch(error => console.error('Failed to send new message webhook:', sessionId, dataType, error.message, data))
+    .catch(error => console.error('Failed to send new message webhook:', sessionId, dataType, error.message, data || ''))
 }
 
 // Function to send a response with error status and message
diff --git a/swagger.js b/swagger.js
index 611f8c42..2e7eeded 100644
--- a/swagger.js
+++ b/swagger.js
@@ -8,6 +8,16 @@ const doc = {
     title: 'WhatsApp API',
     description: 'API Wrapper for WhatsAppWebJS'
   },
+  servers: [
+    {
+      url: '',
+      description: ''
+    },
+    {
+      url: 'http://localhost:3000',
+      description: 'localhost'
+    }
+  ],
   securityDefinitions: {
     apiKeyAuth: {
       type: 'apiKey',
diff --git a/swagger.json b/swagger.json
index 37b68b9c..0c89a436 100644
--- a/swagger.json
+++ b/swagger.json
@@ -7,7 +7,12 @@
   },
   "servers": [
     {
-      "url": "http://localhost:3000/"
+      "url": "",
+      "description": ""
+    },
+    {
+      "url": "http://localhost:3000",
+      "description": "localhost"
     }
   ],
   "tags": [
@@ -31,6 +36,7 @@
           "Various"
         ],
         "description": "",
+        "parameters": [],
         "responses": {
           "200": {
             "description": "OK"
@@ -411,6 +417,7 @@
         ],
         "summary": "Terminate inactive sessions",
         "description": "Terminates all inactive sessions.",
+        "parameters": [],
         "responses": {
           "200": {
             "description": "Sessions terminated.",
@@ -457,6 +464,7 @@
         ],
         "summary": "Terminate all sessions",
         "description": "Terminates all sessions.",
+        "parameters": [],
         "responses": {
           "200": {
             "description": "Sessions terminated.",