From 7594841dacf6b97ee8ed00b8af5c13299fa0d641 Mon Sep 17 00:00:00 2001 From: Mr Simon C Date: Wed, 4 Sep 2024 23:40:24 +0100 Subject: [PATCH] Bug/make swagger json output openapi 3 compliant (#2219) update source to ensure swagger.json is openapi 3.0.0 compliant --- server/endpoints/api/admin/index.js | 6 ---- server/endpoints/api/document/index.js | 10 ++---- server/endpoints/api/openai/index.js | 2 -- server/endpoints/api/system/index.js | 1 - server/endpoints/api/workspace/index.js | 9 ++--- server/endpoints/api/workspaceThread/index.js | 7 ++-- server/swagger/openapi.json | 35 +++++-------------- 7 files changed, 18 insertions(+), 52 deletions(-) diff --git a/server/endpoints/api/admin/index.js b/server/endpoints/api/admin/index.js index e1eb05450..11c9d1c11 100644 --- a/server/endpoints/api/admin/index.js +++ b/server/endpoints/api/admin/index.js @@ -88,7 +88,6 @@ function apiAdminEndpoints(app) { #swagger.requestBody = { description: 'Key pair object that will define the new user to add to the system.', required: true, - type: 'object', content: { "application/json": { example: { @@ -153,7 +152,6 @@ function apiAdminEndpoints(app) { #swagger.requestBody = { description: 'Key pair object that will update the found user. All fields are optional and will not update unless specified.', required: true, - type: 'object', content: { "application/json": { example: { @@ -321,7 +319,6 @@ function apiAdminEndpoints(app) { #swagger.requestBody = { description: 'Request body for creation parameters of the invitation', required: false, - type: 'object', content: { "application/json": { example: { @@ -493,7 +490,6 @@ function apiAdminEndpoints(app) { #swagger.requestBody = { description: 'Entire array of user ids who can access the workspace. All fields are optional and will not update unless specified.', required: true, - type: 'object', content: { "application/json": { example: { @@ -553,7 +549,6 @@ function apiAdminEndpoints(app) { #swagger.requestBody = { description: 'Page offset to show of workspace chats. All fields are optional and will not update unless specified.', required: false, - type: 'integer', content: { "application/json": { example: { @@ -660,7 +655,6 @@ function apiAdminEndpoints(app) { #swagger.requestBody = { description: 'Object with setting key and new value to set. All keys are optional and will not update unless specified.', required: true, - type: 'object', content: { "application/json": { example: { diff --git a/server/endpoints/api/document/index.js b/server/endpoints/api/document/index.js index b4461175a..a646fb584 100644 --- a/server/endpoints/api/document/index.js +++ b/server/endpoints/api/document/index.js @@ -31,11 +31,11 @@ function apiDocumentEndpoints(app) { #swagger.requestBody = { description: 'File to be uploaded.', required: true, - type: 'file', content: { "multipart/form-data": { schema: { - type: 'object', + type: 'string', + format: 'binary', properties: { file: { type: 'string', @@ -131,7 +131,6 @@ function apiDocumentEndpoints(app) { #swagger.requestBody = { description: 'Link of web address to be scraped.', required: true, - type: 'object', content: { "application/json": { schema: { @@ -229,7 +228,6 @@ function apiDocumentEndpoints(app) { #swagger.requestBody = { description: 'Text content and metadata of the file to be saved to the system. Use metadata-schema endpoint to get the possible metadata keys', required: true, - type: 'object', content: { "application/json": { schema: { @@ -571,11 +569,10 @@ function apiDocumentEndpoints(app) { #swagger.requestBody = { description: 'Name of the folder to create.', required: true, - type: 'object', content: { "application/json": { schema: { - type: 'object', + type: 'string', example: { "name": "new-folder" } @@ -638,7 +635,6 @@ function apiDocumentEndpoints(app) { #swagger.requestBody = { description: 'Array of objects containing source and destination paths of files to move.', required: true, - type: 'object', content: { "application/json": { schema: { diff --git a/server/endpoints/api/openai/index.js b/server/endpoints/api/openai/index.js index cd732f424..1f805359f 100644 --- a/server/endpoints/api/openai/index.js +++ b/server/endpoints/api/openai/index.js @@ -90,7 +90,6 @@ function apiOpenAICompatibleEndpoints(app) { #swagger.requestBody = { description: 'Send a prompt to the workspace with full use of documents as if sending a chat in AnythingLLM. Only supports some values of OpenAI API. See example below.', required: true, - type: 'object', content: { "application/json": { example: { @@ -205,7 +204,6 @@ function apiOpenAICompatibleEndpoints(app) { #swagger.requestBody = { description: 'The input string(s) to be embedded. If the text is too long for the embedder model context, it will fail to embed. The vector and associated chunk metadata will be returned in the array order provided', required: true, - type: 'object', content: { "application/json": { example: { diff --git a/server/endpoints/api/system/index.js b/server/endpoints/api/system/index.js index fa92a7c3b..f6b9f511d 100644 --- a/server/endpoints/api/system/index.js +++ b/server/endpoints/api/system/index.js @@ -113,7 +113,6 @@ function apiSystemEndpoints(app) { #swagger.requestBody = { description: 'Key pair object that matches a valid setting and value. Get keys from GET /v1/system or refer to codebase.', required: true, - type: 'object', content: { "application/json": { example: { diff --git a/server/endpoints/api/workspace/index.js b/server/endpoints/api/workspace/index.js index 694baea98..d2040be1e 100644 --- a/server/endpoints/api/workspace/index.js +++ b/server/endpoints/api/workspace/index.js @@ -25,7 +25,6 @@ function apiWorkspaceEndpoints(app) { #swagger.requestBody = { description: 'JSON object containing new display name of workspace.', required: true, - type: 'object', content: { "application/json": { example: { @@ -265,7 +264,6 @@ function apiWorkspaceEndpoints(app) { #swagger.requestBody = { description: 'JSON object containing new settings to update a workspace. All keys are optional and will not update unless provided', required: true, - type: 'object', content: { "application/json": { example: { @@ -404,7 +402,6 @@ function apiWorkspaceEndpoints(app) { #swagger.requestBody = { description: 'JSON object of additions and removals of documents to add to update a workspace. The value should be the folder + filename with the exclusions of the top-level documents path.', required: true, - type: 'object', content: { "application/json": { example: { @@ -482,7 +479,6 @@ function apiWorkspaceEndpoints(app) { #swagger.requestBody = { description: 'JSON object with the document path and pin status to update.', required: true, - type: 'object', content: { "application/json": { example: { @@ -545,7 +541,6 @@ function apiWorkspaceEndpoints(app) { #swagger.requestBody = { description: 'Send a prompt to the workspace and the type of conversation (query or chat).
Query: Will not use LLM unless there are relevant sources from vectorDB & does not recall chat history.
Chat: Uses LLM general knowledge w/custom embeddings to produce output, uses rolling chat history.', required: true, - type: 'object', content: { "application/json": { example: { @@ -655,7 +650,6 @@ function apiWorkspaceEndpoints(app) { #swagger.requestBody = { description: 'Send a prompt to the workspace and the type of conversation (query or chat).
Query: Will not use LLM unless there are relevant sources from vectorDB & does not recall chat history.
Chat: Uses LLM general knowledge w/custom embeddings to produce output, uses rolling chat history.', required: true, - type: 'object', content: { "application/json": { example: { @@ -671,6 +665,9 @@ function apiWorkspaceEndpoints(app) { "text/event-stream": { schema: { type: 'array', + items: { + type: 'string', + }, example: [ { id: 'uuid-123', diff --git a/server/endpoints/api/workspaceThread/index.js b/server/endpoints/api/workspaceThread/index.js index f8552d73c..66c3a6844 100644 --- a/server/endpoints/api/workspaceThread/index.js +++ b/server/endpoints/api/workspaceThread/index.js @@ -36,7 +36,6 @@ function apiWorkspaceThreadEndpoints(app) { #swagger.requestBody = { description: 'Optional userId associated with the thread', required: false, - type: 'object', content: { "application/json": { example: { @@ -125,7 +124,6 @@ function apiWorkspaceThreadEndpoints(app) { #swagger.requestBody = { description: 'JSON object containing new name to update the thread.', required: true, - type: 'object', content: { "application/json": { example: { @@ -336,7 +334,6 @@ function apiWorkspaceThreadEndpoints(app) { #swagger.requestBody = { description: 'Send a prompt to the workspace thread and the type of conversation (query or chat).', required: true, - type: 'object', content: { "application/json": { example: { @@ -462,7 +459,6 @@ function apiWorkspaceThreadEndpoints(app) { #swagger.requestBody = { description: 'Send a prompt to the workspace thread and the type of conversation (query or chat).', required: true, - type: 'object', content: { "application/json": { example: { @@ -478,6 +474,9 @@ function apiWorkspaceThreadEndpoints(app) { "text/event-stream": { schema: { type: 'array', + items: { + type: 'string', + }, example: [ { id: 'uuid-123', diff --git a/server/swagger/openapi.json b/server/swagger/openapi.json index 078e38a88..f412f0a4f 100644 --- a/server/swagger/openapi.json +++ b/server/swagger/openapi.json @@ -193,7 +193,6 @@ "requestBody": { "description": "Key pair object that will define the new user to add to the system.", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -263,7 +262,6 @@ "requestBody": { "description": "Key pair object that will update the found user. All fields are optional and will not update unless specified.", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -434,7 +432,6 @@ "requestBody": { "description": "Request body for creation parameters of the invitation", "required": false, - "type": "object", "content": { "application/json": { "example": { @@ -626,7 +623,6 @@ "requestBody": { "description": "Entire array of user ids who can access the workspace. All fields are optional and will not update unless specified.", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -686,7 +682,6 @@ "requestBody": { "description": "Page offset to show of workspace chats. All fields are optional and will not update unless specified.", "required": false, - "type": "integer", "content": { "application/json": { "example": { @@ -790,7 +785,6 @@ "requestBody": { "description": "Object with setting key and new value to set. All keys are optional and will not update unless specified.", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -861,11 +855,11 @@ "requestBody": { "description": "File to be uploaded.", "required": true, - "type": "file", "content": { "multipart/form-data": { "schema": { - "type": "object", + "type": "string", + "format": "binary", "properties": { "file": { "type": "string", @@ -938,7 +932,6 @@ "requestBody": { "description": "Link of web address to be scraped.", "required": true, - "type": "object", "content": { "application/json": { "schema": { @@ -1015,7 +1008,6 @@ "requestBody": { "description": "Text content and metadata of the file to be saved to the system. Use metadata-schema endpoint to get the possible metadata keys", "required": true, - "type": "object", "content": { "application/json": { "schema": { @@ -1311,11 +1303,10 @@ "requestBody": { "description": "Name of the folder to create.", "required": true, - "type": "object", "content": { "application/json": { "schema": { - "type": "object", + "type": "string", "example": { "name": "new-folder" } @@ -1369,7 +1360,6 @@ "requestBody": { "description": "Array of objects containing source and destination paths of files to move.", "required": true, - "type": "object", "content": { "application/json": { "schema": { @@ -1441,7 +1431,6 @@ "requestBody": { "description": "JSON object containing new display name of workspace.", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -1679,7 +1668,6 @@ "requestBody": { "description": "JSON object containing new settings to update a workspace. All keys are optional and will not update unless provided", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -1830,7 +1818,6 @@ "requestBody": { "description": "JSON object of additions and removals of documents to add to update a workspace. The value should be the folder + filename with the exclusions of the top-level documents path.", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -1890,7 +1877,6 @@ "requestBody": { "description": "JSON object with the document path and pin status to update.", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -1967,7 +1953,6 @@ "requestBody": { "description": "Send a prompt to the workspace and the type of conversation (query or chat).
Query: Will not use LLM unless there are relevant sources from vectorDB & does not recall chat history.
Chat: Uses LLM general knowledge w/custom embeddings to produce output, uses rolling chat history.", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -2002,6 +1987,9 @@ "text/event-stream": { "schema": { "type": "array", + "items": { + "type": "string" + }, "example": [ { "id": "uuid-123", @@ -2060,7 +2048,6 @@ "requestBody": { "description": "Send a prompt to the workspace and the type of conversation (query or chat).
Query: Will not use LLM unless there are relevant sources from vectorDB & does not recall chat history.
Chat: Uses LLM general knowledge w/custom embeddings to produce output, uses rolling chat history.", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -2241,7 +2228,6 @@ "requestBody": { "description": "Key pair object that matches a valid setting and value. Get keys from GET /v1/system or refer to codebase.", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -2440,7 +2426,6 @@ "requestBody": { "description": "Optional userId associated with the thread", "required": false, - "type": "object", "content": { "application/json": { "example": { @@ -2523,7 +2508,6 @@ "requestBody": { "description": "JSON object containing new name to update the thread.", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -2742,7 +2726,6 @@ "requestBody": { "description": "Send a prompt to the workspace thread and the type of conversation (query or chat).", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -2787,6 +2770,9 @@ "text/event-stream": { "schema": { "type": "array", + "items": { + "type": "string" + }, "example": [ { "id": "uuid-123", @@ -2845,7 +2831,6 @@ "requestBody": { "description": "Send a prompt to the workspace thread and the type of conversation (query or chat).", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -3012,7 +2997,6 @@ "requestBody": { "description": "Send a prompt to the workspace with full use of documents as if sending a chat in AnythingLLM. Only supports some values of OpenAI API. See example below.", "required": true, - "type": "object", "content": { "application/json": { "example": { @@ -3076,7 +3060,6 @@ "requestBody": { "description": "The input string(s) to be embedded. If the text is too long for the embedder model context, it will fail to embed. The vector and associated chunk metadata will be returned in the array order provided", "required": true, - "type": "object", "content": { "application/json": { "example": {