1
0
Fork 0
mirror of synced 2024-06-02 18:44:54 +12:00
budibase/packages/server/src/api/routes/public/tables.js

148 lines
4 KiB
JavaScript
Raw Normal View History

2022-02-18 07:58:09 +13:00
const Router = require("@koa/router")
const controller = require("../../controllers/public/tables")
2022-02-18 07:58:09 +13:00
const router = Router()
/**
* @openapi
* /tables/search:
* post:
* summary: Search internal and external tables based on their name.
* tags:
* - tables
2022-02-19 07:06:58 +13:00
* parameters:
* - $ref: '#/components/parameters/appId'
* requestBody:
2022-02-23 03:28:57 +13:00
* required: true
2022-02-19 07:06:58 +13:00
* content:
* application/json:
* schema:
2022-02-23 03:28:57 +13:00
* $ref: '#/components/schemas/nameSearch'
* responses:
* 200:
* description: Returns the found tables, based on the search parameters.
* content:
* application/json:
* schema:
* type: object
* properties:
* applications:
* type: array
* items:
* $ref: '#/components/schemas/table'
* examples:
* tables:
* $ref: '#/components/examples/tables'
*/
router.post("/tables/search", controller.search)
/**
* @openapi
* /tables:
* post:
* summary: Create a new table.
* tags:
* - tables
2022-02-19 07:06:58 +13:00
* 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
* internal or external data sources.
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/tableOutput'
* examples:
* table:
* $ref: '#/components/examples/table'
*/
router.post("/tables", controller.create)
/**
* @openapi
2022-02-23 03:28:57 +13:00
* /tables/{tableId}:
* put:
2022-02-23 03:28:57 +13:00
* summary: Update the specified table.
* tags:
* - tables
* parameters:
* - $ref: '#/components/parameters/tableId'
* - $ref: '#/components/parameters/appId'
2022-02-19 07:06:58 +13:00
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/table'
* examples:
* table:
* $ref: '#/components/examples/table'
* responses:
* 200:
* description: Returns the updated table.
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/tableOutput'
* examples:
* table:
* $ref: '#/components/examples/table'
*/
router.put("/tables/:tableId", controller.update)
/**
* @openapi
* /tables/{tableId}:
* delete:
* summary: Delete a single table and all of its data.
* tags:
* - tables
* parameters:
* - $ref: '#/components/parameters/tableId'
* - $ref: '#/components/parameters/appId'
* responses:
* 200:
* description: Returns the deleted table.
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/tableOutput'
* examples:
* table:
* $ref: '#/components/examples/table'
*/
router.delete("/tables/:tableId", controller.delete)
2022-02-18 07:58:09 +13:00
/**
* @openapi
* /tables/{tableId}:
* get:
* summary: Gets a single table by its ID.
* tags:
* - tables
* parameters:
* - $ref: '#/components/parameters/tableId'
* - $ref: '#/components/parameters/appId'
* responses:
* 200:
* description: Returns the retrieved table.
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/tableOutput'
* examples:
* table:
* $ref: '#/components/examples/table'
*/
router.get("/tables/:tableId", controller.read)
2022-02-18 07:58:09 +13:00
module.exports = router