From 0d5cc558c9288f3e3ed969a72ab258307d001c9f Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Mon, 17 Jun 2024 13:55:10 -0700 Subject: [PATCH] linting patch UI exception with invalid return value from failed parse resolves #1692 --- .../ChatHistory/Chartable/index.jsx | 2 +- server/endpoints/api/admin/index.js | 13 ++--- server/swagger/openapi.json | 51 +++++++++++-------- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Chartable/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Chartable/index.jsx index 2ce0fa5d..7d2266e7 100644 --- a/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Chartable/index.jsx +++ b/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Chartable/index.jsx @@ -66,7 +66,7 @@ export function Chartable({ props, workspace }) { const chartType = content?.type?.toLowerCase(); const data = typeof content.dataset === "string" - ? safeJsonParse(content.dataset, null) + ? safeJsonParse(content.dataset, []) : content.dataset; const value = data.length > 0 ? Object.keys(data[0])[1] : "value"; const title = content?.title; diff --git a/server/endpoints/api/admin/index.js b/server/endpoints/api/admin/index.js index 47c5e0d8..600d3636 100644 --- a/server/endpoints/api/admin/index.js +++ b/server/endpoints/api/admin/index.js @@ -427,10 +427,10 @@ function apiAdminEndpoints(app) { } ); app.get( - "/v1/admin/workspaces/:workspaceId/users", - [validApiKey], + "/v1/admin/workspaces/:workspaceId/users", + [validApiKey], async (request, response) => { - /* + /* #swagger.tags = ['Admin'] #swagger.path = '/v1/admin/workspaces/{workspaceId}/users' #swagger.parameters['workspaceId'] = { @@ -464,7 +464,7 @@ function apiAdminEndpoints(app) { description: "Instance is not in Multi-User mode. Method denied", } */ - + try { if (!multiUserMode(response)) { response.sendStatus(401).end(); @@ -473,13 +473,14 @@ function apiAdminEndpoints(app) { const workspaceId = request.params.workspaceId; const users = await Workspace.workspaceUsers(workspaceId); - + response.status(200).json({ users }); } catch (e) { console.error(e); response.sendStatus(500).end(); } - }); + } + ); app.post( "/v1/admin/workspaces/:workspaceId/update-users", [validApiKey], diff --git a/server/swagger/openapi.json b/server/swagger/openapi.json index e4321f86..2154c561 100644 --- a/server/swagger/openapi.json +++ b/server/swagger/openapi.json @@ -502,10 +502,12 @@ } } }, - "/v1/admin/workspaces/:workspaceId/users": { + "/v1/admin/workspaces/{workspaceId}/users": { "get": { - "tags": ["Admin"], - "description": "Retrieve a list of users for the given workspace.", + "tags": [ + "Admin" + ], + "description": "Retrieve a list of users with permissions to access the specified workspace.", "parameters": [ { "name": "workspaceId", @@ -514,43 +516,52 @@ "schema": { "type": "string" }, - "description": "The ID of the workspace whose users are to be retrieved." + "description": "id of the workspace." } ], "responses": { "200": { - "description": "OK, successful operation. Returns a list of user IDs for the given workspace.", + "description": "OK", "content": { "application/json": { "schema": { - "type": "array", - "items": {"type": "string"} + "type": "object", + "example": { + "users": [ + { + "userId": 1, + "role": "admin" + }, + { + "userId": 2, + "role": "member" + } + ] + } } } } }, "401": { - "description": "Unauthorized, not authorized to access resources in multi-user mode.", + "description": "Instance is not in Multi-User mode. Method denied" + }, + "403": { + "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/InvalidAPIKey" } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/InvalidAPIKey" + } } } }, "500": { - "description": "Internal Server Error", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": {"type": "string"} - } - } - } - } + "description": "Internal Server Error" } } } @@ -2389,4 +2400,4 @@ "BearerAuth": [] } ] -} +} \ No newline at end of file