From 1f8da07767e897fc9ebfceceb73b66d55f8e9961 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 22 Feb 2022 14:28:57 +0000 Subject: [PATCH] Adding in request bodies. --- packages/server/specs/openapi.json | 77 ++++++++++++++++--- packages/server/specs/openapi.yaml | 51 +++++++++--- packages/server/specs/schemas.js | 67 ++++++++-------- .../src/api/routes/public/applications.js | 18 +++++ .../server/src/api/routes/public/queries.js | 6 ++ .../server/src/api/routes/public/tables.js | 12 +-- .../server/src/api/routes/public/users.js | 6 ++ 7 files changed, 172 insertions(+), 65 deletions(-) diff --git a/packages/server/specs/openapi.json b/packages/server/specs/openapi.json index d23423914e..e6ba7ce8ef 100644 --- a/packages/server/specs/openapi.json +++ b/packages/server/specs/openapi.json @@ -848,6 +848,7 @@ } }, "rowOutput": { + "type": "object", "properties": { "row": { "description": "The row to be created/updated, based on the table schema.", @@ -873,6 +874,15 @@ } } } + }, + "nameSearch": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The name to be used when searching - this will be used in a case insensitive starts with match." + } + } } } }, @@ -893,6 +903,16 @@ "$ref": "#/components/parameters/appId" } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/nameSearch" + } + } + } + }, "responses": { "200": { "description": "Returns the applications that were found based on the search parameters.", @@ -931,6 +951,16 @@ "$ref": "#/components/parameters/appId" } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/application" + } + } + } + }, "responses": { "200": { "description": "Returns the created application.", @@ -961,6 +991,16 @@ "$ref": "#/components/parameters/appIdUrl" } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/application" + } + } + } + }, "responses": { "200": { "description": "Returns the updated application.", @@ -1047,6 +1087,16 @@ "$ref": "#/components/parameters/appId" } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/nameSearch" + } + } + } + }, "responses": { "200": { "description": "Returns the queries found based on the search parameters.", @@ -1457,16 +1507,11 @@ } ], "requestBody": { + "required": true, "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "The name of the table, this is a case insensitive search using the provided name as a starts with search." - } - } + "$ref": "#/components/schemas/nameSearch" } } } @@ -1542,9 +1587,9 @@ } } }, - "/tables/:tableId": { + "/tables/{tableId}": { "put": { - "summary": "Update the specified table. This can be for internal or external tables.", + "summary": "Update the specified table.", "tags": [ "tables" ], @@ -1587,9 +1632,7 @@ } } } - } - }, - "/tables/{tableId}": { + }, "delete": { "summary": "Delete a single table and all of its data.", "tags": [ @@ -1664,6 +1707,16 @@ "$ref": "#/components/parameters/appId" } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/nameSearch" + } + } + } + }, "responses": { "200": { "description": "Returns the found users based on search parameters.", diff --git a/packages/server/specs/openapi.yaml b/packages/server/specs/openapi.yaml index 37b5dcd1b8..fd12dd2b22 100644 --- a/packages/server/specs/openapi.yaml +++ b/packages/server/specs/openapi.yaml @@ -633,6 +633,7 @@ components: type: object properties: {} rowOutput: + type: object properties: row: description: The row to be created/updated, based on the table schema. @@ -644,6 +645,13 @@ components: - type: integer - type: array - type: boolean + nameSearch: + type: object + properties: + name: + type: string + description: The name to be used when searching - this will be used in a case + insensitive starts with match. security: - ApiKeyAuth: [] paths: @@ -654,6 +662,12 @@ paths: - applications parameters: - $ref: "#/components/parameters/appId" + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/nameSearch" responses: "200": description: Returns the applications that were found based on the search @@ -677,6 +691,12 @@ paths: - applications parameters: - $ref: "#/components/parameters/appId" + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/application" responses: "200": description: Returns the created application. @@ -694,6 +714,12 @@ paths: - applications parameters: - $ref: "#/components/parameters/appIdUrl" + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/application" responses: "200": description: Returns the updated application. @@ -743,6 +769,12 @@ paths: - queries parameters: - $ref: "#/components/parameters/appId" + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/nameSearch" responses: "200": description: Returns the queries found based on the search parameters. @@ -1004,15 +1036,11 @@ paths: parameters: - $ref: "#/components/parameters/appId" requestBody: + required: true content: application/json: schema: - type: object - properties: - name: - type: string - description: The name of the table, this is a case insensitive search using the - provided name as a starts with search. + $ref: "#/components/schemas/nameSearch" responses: "200": description: Returns the found tables, based on the search parameters. @@ -1054,9 +1082,9 @@ paths: examples: table: $ref: "#/components/examples/table" - /tables/:tableId: + "/tables/{tableId}": put: - summary: Update the specified table. This can be for internal or external tables. + summary: Update the specified table. tags: - tables parameters: @@ -1080,7 +1108,6 @@ paths: examples: table: $ref: "#/components/examples/table" - "/tables/{tableId}": delete: summary: Delete a single table and all of its data. tags: @@ -1122,6 +1149,12 @@ paths: - users parameters: - $ref: "#/components/parameters/appId" + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/nameSearch" responses: "200": description: Returns the found users based on search parameters. diff --git a/packages/server/specs/schemas.js b/packages/server/specs/schemas.js index c1ef908cba..59e0c676f0 100644 --- a/packages/server/specs/schemas.js +++ b/packages/server/specs/schemas.js @@ -144,44 +144,39 @@ exports.table = { }, } -exports.query = { - type: "object", - properties: {}, +function object(props) { + return { + type: "object", + properties: props, + } } -exports.user = { - type: "object", - properties: {}, -} +exports.query = object({}) -exports.application = { - type: "object", - properties: {}, -} +exports.user = object({}) -exports.applicationOutput = { - type: "object", - properties: { - application: exports.application, +exports.application = object({}) + +exports.applicationOutput = object({ + application: exports.application, +}) + +exports.tableOutput = object({ + table: exports.table, +}) + +exports.userOutput = object({ + user: exports.user, +}) + +exports.rowOutput = object({ + row: exports.row, +}) + +exports.nameSearch = object({ + name: { + type: "string", + description: + "The name to be used when searching - this will be used in a case insensitive starts with match.", }, -} - -exports.tableOutput = { - type: "object", - properties: { - table: exports.table, - }, -} - -exports.userOutput = { - type: "object", - properties: { - user: exports.user, - }, -} - -exports.rowOutput = { - properties: { - row: exports.row, - }, -} +}) diff --git a/packages/server/src/api/routes/public/applications.js b/packages/server/src/api/routes/public/applications.js index 0bde81fe07..41b2f52798 100644 --- a/packages/server/src/api/routes/public/applications.js +++ b/packages/server/src/api/routes/public/applications.js @@ -12,6 +12,12 @@ const router = Router() * - applications * parameters: * - $ref: '#/components/parameters/appId' + * requestBody: + * required: true + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/nameSearch' * responses: * 200: * description: Returns the applications that were found based on the search parameters. @@ -39,6 +45,12 @@ router.post("/applications/search", controller.search) * - applications * parameters: * - $ref: '#/components/parameters/appId' + * requestBody: + * required: true + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/application' * responses: * 200: * description: Returns the created application. @@ -61,6 +73,12 @@ router.post("/applications", controller.create) * - applications * parameters: * - $ref: '#/components/parameters/appIdUrl' + * requestBody: + * required: true + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/application' * responses: * 200: * description: Returns the updated application. diff --git a/packages/server/src/api/routes/public/queries.js b/packages/server/src/api/routes/public/queries.js index 017404c263..220346f58a 100644 --- a/packages/server/src/api/routes/public/queries.js +++ b/packages/server/src/api/routes/public/queries.js @@ -12,6 +12,12 @@ const router = Router() * - queries * parameters: * - $ref: '#/components/parameters/appId' + * requestBody: + * required: true + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/nameSearch' * responses: * 200: * description: Returns the queries found based on the search parameters. diff --git a/packages/server/src/api/routes/public/tables.js b/packages/server/src/api/routes/public/tables.js index 159e4c1e74..0c2684b80c 100644 --- a/packages/server/src/api/routes/public/tables.js +++ b/packages/server/src/api/routes/public/tables.js @@ -13,15 +13,11 @@ const router = Router() * parameters: * - $ref: '#/components/parameters/appId' * requestBody: + * required: true * content: * application/json: * schema: - * type: object - * properties: - * name: - * type: string - * description: The name of the table, this is a case insensitive search using the provided - * name as a starts with search. + * $ref: '#/components/schemas/nameSearch' * responses: * 200: * description: Returns the found tables, based on the search parameters. @@ -73,9 +69,9 @@ router.post("/tables", controller.create) /** * @openapi - * /tables/:tableId: + * /tables/{tableId}: * put: - * summary: Update the specified table. This can be for internal or external tables. + * summary: Update the specified table. * tags: * - tables * parameters: diff --git a/packages/server/src/api/routes/public/users.js b/packages/server/src/api/routes/public/users.js index 79a71d7799..a8478e4b6a 100644 --- a/packages/server/src/api/routes/public/users.js +++ b/packages/server/src/api/routes/public/users.js @@ -12,6 +12,12 @@ const router = Router() * - users * parameters: * - $ref: '#/components/parameters/appId' + * requestBody: + * required: true + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/nameSearch' * responses: * 200: * description: Returns the found users based on search parameters.