diff --git a/packages/server/specs/openapi.json b/packages/server/specs/openapi.json index 163dbbf0ac..a52c524aec 100644 --- a/packages/server/specs/openapi.json +++ b/packages/server/specs/openapi.json @@ -174,6 +174,42 @@ } ] } + }, + "table": { + "description": "The table to be created/updated.", + "type": "object", + "properties": { + "name": { + "description": "The name of the table", + "type": "string" + }, + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "string", + "longform", + "options", + "number", + "boolean", + "array", + "datetime", + "attachment", + "link", + "formula", + "auto", + "json", + "internal" + ] + } + } + } + } + } } } }, @@ -521,15 +557,29 @@ "/tables/search": { "post": { "summary": "Search internal and external tables based on their name.", + "tags": [ + "tables" + ], "parameters": [ { "$ref": "#/components/parameters/appId" } ], - "tags": [ - "tables" - ], - "requestBody": null, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The name of the table, this should be an exact match (ignoring case)." + } + } + } + } + } + }, "responses": { "200": { "description": "Returns the found tables, based on the search parameters.", @@ -555,14 +605,28 @@ "/tables": { "post": { "summary": "Create a new table.", + "tags": [ + "tables" + ], "parameters": [ { "$ref": "#/components/parameters/appId" } ], - "tags": [ - "tables" - ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/table" + }, + "examples": { + "table": { + "$ref": "#/components/examples/table" + } + } + } + } + }, "responses": { "200": { "description": "Returns the created table, including the ID which has been generated for it. This can be internal or external data sources.", @@ -627,6 +691,20 @@ "$ref": "#/components/parameters/appId" } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/table" + }, + "examples": { + "table": { + "$ref": "#/components/examples/table" + } + } + } + } + }, "responses": { "200": { "description": "Returns the updated table.", diff --git a/packages/server/specs/openapi.yaml b/packages/server/specs/openapi.yaml index efa75f53b2..d2cf091643 100644 --- a/packages/server/specs/openapi.yaml +++ b/packages/server/specs/openapi.yaml @@ -116,6 +116,34 @@ components: - type: integer - type: array - type: boolean + table: + description: The table to be created/updated. + type: object + properties: + name: + description: The name of the table + type: string + schema: + type: object + additionalProperties: + type: object + properties: + type: + type: string + enum: + - string + - longform + - options + - number + - boolean + - array + - datetime + - attachment + - link + - formula + - auto + - json + - internal security: - ApiKeyAuth: [] paths: @@ -340,11 +368,20 @@ paths: /tables/search: post: summary: Search internal and external tables based on their name. - parameters: - - $ref: "#/components/parameters/appId" tags: - tables - requestBody: null + parameters: + - $ref: "#/components/parameters/appId" + requestBody: + content: + application/json: + schema: + type: object + properties: + name: + type: string + description: The name of the table, this should be an exact match (ignoring + case). responses: "200": description: Returns the found tables, based on the search parameters. @@ -360,10 +397,18 @@ paths: /tables: post: summary: Create a new table. - parameters: - - $ref: "#/components/parameters/appId" tags: - tables + parameters: + - $ref: "#/components/parameters/appId" + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/table" + examples: + table: + $ref: "#/components/examples/table" responses: "200": description: Returns the created table, including the ID which has been @@ -400,6 +445,14 @@ paths: parameters: - $ref: "#/components/parameters/tableId" - $ref: "#/components/parameters/appId" + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/table" + examples: + table: + $ref: "#/components/examples/table" responses: "200": description: Returns the updated table. diff --git a/packages/server/specs/schemas.js b/packages/server/specs/schemas.js index 29a6b5b84f..1ed31bf0b1 100644 --- a/packages/server/specs/schemas.js +++ b/packages/server/specs/schemas.js @@ -1,3 +1,5 @@ +const { FieldTypes } = require("../src/constants") + exports.row = { description: "The row to be created/updated, based on the table schema.", type: "object", @@ -11,3 +13,26 @@ exports.row = { ], }, } + +exports.table = { + description: "The table to be created/updated.", + type: "object", + properties: { + name: { + description: "The name of the table", + type: "string", + }, + schema: { + type: "object", + additionalProperties: { + type: "object", + properties: { + type: { + type: "string", + enum: Object.values(FieldTypes), + }, + }, + }, + }, + }, +} diff --git a/packages/server/src/api/routes/public/tables.js b/packages/server/src/api/routes/public/tables.js index 91690389de..f245870d33 100644 --- a/packages/server/src/api/routes/public/tables.js +++ b/packages/server/src/api/routes/public/tables.js @@ -8,12 +8,19 @@ const router = Router() * /tables/search: * post: * summary: Search internal and external tables based on their name. - * parameters: - * - $ref: '#/components/parameters/appId' * tags: * - tables + * parameters: + * - $ref: '#/components/parameters/appId' * requestBody: - * + * content: + * application/json: + * schema: + * type: object + * properties: + * name: + * type: string + * description: The name of the table, this should be an exact match (ignoring case). * responses: * 200: * description: Returns the found tables, based on the search parameters. @@ -34,10 +41,18 @@ router.post("/tables/search", controller.search) * /tables: * post: * summary: Create a new table. - * parameters: - * - $ref: '#/components/parameters/appId' * tags: * - tables + * parameters: + * - $ref: '#/components/parameters/appId' + * requestBody: + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/table' + * examples: + * table: + * $ref: '#/components/examples/table' * responses: * 200: * description: Returns the created table, including the ID which has been generated for it. This can be @@ -62,6 +77,14 @@ router.post("/tables", controller.create) * parameters: * - $ref: '#/components/parameters/tableId' * - $ref: '#/components/parameters/appId' + * requestBody: + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/table' + * examples: + * table: + * $ref: '#/components/examples/table' * responses: * 200: * description: Returns the updated table.