Adding in row schema for create/update, making sure all existing endpoints have appId specified.
This commit is contained in:
parent
9b28414bbb
commit
890a17679c
|
@ -1,9 +1,18 @@
|
||||||
const row = {
|
const baseRow = {
|
||||||
_id: "ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4",
|
_id: "ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4",
|
||||||
type: "row",
|
type: "row",
|
||||||
tableId: "ta_5b1649e42a5b41dea4ef7742a36a7a70",
|
tableId: "ta_5b1649e42a5b41dea4ef7742a36a7a70",
|
||||||
name: "Mike",
|
name: "Mike",
|
||||||
age: 30,
|
age: 30,
|
||||||
|
}
|
||||||
|
|
||||||
|
const inputRow = {
|
||||||
|
...baseRow,
|
||||||
|
relationship: ["ro_ta_..."],
|
||||||
|
}
|
||||||
|
|
||||||
|
const row = {
|
||||||
|
...baseRow,
|
||||||
relationship: [
|
relationship: [
|
||||||
{
|
{
|
||||||
primaryDisplay: "Joe",
|
primaryDisplay: "Joe",
|
||||||
|
@ -12,30 +21,40 @@ const row = {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.table = {
|
const table = {
|
||||||
value: {
|
_id: "ta_5b1649e42a5b41dea4ef7742a36a7a70",
|
||||||
_id: "ta_5b1649e42a5b41dea4ef7742a36a7a70",
|
name: "People",
|
||||||
name: "People",
|
schema: {
|
||||||
schema: {
|
name: {
|
||||||
name: {
|
type: "string",
|
||||||
type: "string",
|
name: "name",
|
||||||
name: "name",
|
},
|
||||||
},
|
age: {
|
||||||
age: {
|
type: "number",
|
||||||
type: "number",
|
name: "age",
|
||||||
name: "age",
|
},
|
||||||
},
|
relationship: {
|
||||||
relationship: {
|
type: "link",
|
||||||
type: "link",
|
name: "relationship",
|
||||||
name: "relationship",
|
tableId: "ta_...",
|
||||||
tableId: "ta_...",
|
fieldName: "relatedColumn",
|
||||||
fieldName: "relatedColumn",
|
relationshipType: "many-to-many",
|
||||||
relationshipType: "many-to-many",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.table = {
|
||||||
|
value: table,
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.tables = {
|
||||||
|
value: [table],
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.inputRow = {
|
||||||
|
value: inputRow,
|
||||||
|
}
|
||||||
|
|
||||||
exports.row = {
|
exports.row = {
|
||||||
value: row,
|
value: row,
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ const { writeFileSync } = require("fs")
|
||||||
const examples = require("./examples")
|
const examples = require("./examples")
|
||||||
const parameters = require("./parameters")
|
const parameters = require("./parameters")
|
||||||
const security = require("./security")
|
const security = require("./security")
|
||||||
|
const schemas = require("./schemas")
|
||||||
|
|
||||||
const VARIABLES = {}
|
const VARIABLES = {}
|
||||||
|
|
||||||
|
@ -35,6 +36,9 @@ const options = {
|
||||||
securitySchemes: {
|
securitySchemes: {
|
||||||
...security,
|
...security,
|
||||||
},
|
},
|
||||||
|
schemas: {
|
||||||
|
...schemas,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,15 @@
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"appId": {
|
||||||
|
"in": "header",
|
||||||
|
"name": "appId",
|
||||||
|
"required": true,
|
||||||
|
"description": "The ID of the app which this request is targeting.",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"examples": {
|
"examples": {
|
||||||
|
@ -60,6 +69,43 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"tables": {
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"_id": "ta_5b1649e42a5b41dea4ef7742a36a7a70",
|
||||||
|
"name": "People",
|
||||||
|
"schema": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"name": "name"
|
||||||
|
},
|
||||||
|
"age": {
|
||||||
|
"type": "number",
|
||||||
|
"name": "age"
|
||||||
|
},
|
||||||
|
"relationship": {
|
||||||
|
"type": "link",
|
||||||
|
"name": "relationship",
|
||||||
|
"tableId": "ta_...",
|
||||||
|
"fieldName": "relatedColumn",
|
||||||
|
"relationshipType": "many-to-many"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"inputRow": {
|
||||||
|
"value": {
|
||||||
|
"_id": "ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4",
|
||||||
|
"type": "row",
|
||||||
|
"tableId": "ta_5b1649e42a5b41dea4ef7742a36a7a70",
|
||||||
|
"name": "Mike",
|
||||||
|
"age": 30,
|
||||||
|
"relationship": [
|
||||||
|
"ro_ta_..."
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"row": {
|
"row": {
|
||||||
"value": {
|
"value": {
|
||||||
"_id": "ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4",
|
"_id": "ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4",
|
||||||
|
@ -104,6 +150,31 @@
|
||||||
"name": "x-budibase-api-key",
|
"name": "x-budibase-api-key",
|
||||||
"description": "Your individual API key, this will provide access based on the configured RBAC settings of your user."
|
"description": "Your individual API key, this will provide access based on the configured RBAC settings of your user."
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"schemas": {
|
||||||
|
"row": {
|
||||||
|
"description": "The row to be created/updated, based on the table schema.",
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
|
@ -121,6 +192,9 @@
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"$ref": "#/components/parameters/tableId"
|
"$ref": "#/components/parameters/tableId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/appId"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
|
@ -151,7 +225,13 @@
|
||||||
},
|
},
|
||||||
"range": {
|
"range": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "Searches within a range, the format of this must be columnName -> [low, high]."
|
"description": "Searches within a range, the format of this must be columnName -> [low, high].",
|
||||||
|
"example": {
|
||||||
|
"columnName1": [
|
||||||
|
10,
|
||||||
|
20
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"equal": {
|
"equal": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -163,7 +243,10 @@
|
||||||
},
|
},
|
||||||
"empty": {
|
"empty": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "Searches for rows which do not contain the specified column. The object should simply contain keys of the column names, these can map to any value."
|
"description": "Searches for rows which do not contain the specified column. The object should simply contain keys of the column names, these can map to any value.",
|
||||||
|
"example": {
|
||||||
|
"columnName1": ""
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"notEmpty": {
|
"notEmpty": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -255,11 +338,11 @@
|
||||||
"description": "If pagination in use, this will determine if there is another page to fetch.",
|
"description": "If pagination in use, this will determine if there is another page to fetch.",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"examples": {
|
},
|
||||||
"search": [
|
"examples": {
|
||||||
"#/components/examples/search"
|
"search": {
|
||||||
]
|
"$ref": "#/components/examples/search"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,6 +360,9 @@
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"$ref": "#/components/parameters/tableId"
|
"$ref": "#/components/parameters/tableId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/appId"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
|
@ -284,29 +370,11 @@
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"description": "The contents of the row which is to be created, the keys of",
|
"$ref": "#/components/schemas/row"
|
||||||
"type": "object",
|
},
|
||||||
"example": {
|
"examples": {
|
||||||
"$ref": "#/components/examples/row"
|
"row": {
|
||||||
},
|
"$ref": "#/components/examples/inputRow"
|
||||||
"additionalProperties": {
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "array"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "boolean"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,8 +411,26 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/components/parameters/rowId"
|
"$ref": "#/components/parameters/rowId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/appId"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/row"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"row": {
|
||||||
|
"$ref": "#/components/examples/inputRow"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Returns the created row, including the ID which has been generated for it.",
|
"description": "Returns the created row, including the ID which has been generated for it.",
|
||||||
|
@ -374,6 +460,9 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/components/parameters/rowId"
|
"$ref": "#/components/parameters/rowId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/appId"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
@ -405,6 +494,9 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/components/parameters/rowId"
|
"$ref": "#/components/parameters/rowId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/appId"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
@ -426,22 +518,158 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/tables/search": {
|
||||||
|
"post": {
|
||||||
|
"summary": "Search internal and external tables based on their name.",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/appId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"tables"
|
||||||
|
],
|
||||||
|
"requestBody": null,
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Returns the found tables, based on the search parameters.",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"tables": {
|
||||||
|
"$ref": "#/components/examples/tables"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/tables": {
|
"/tables": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Create a new table",
|
"summary": "Create a new table.",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/appId"
|
||||||
|
}
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"tables"
|
"tables"
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Returns the created table, including the ID which has been generated for it.",
|
"description": "Returns the created table, including the ID which has been generated for it. This can be internal or external data sources.",
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
"examples": {
|
"examples": {
|
||||||
"row": {
|
"table": {
|
||||||
|
"$ref": "#/components/examples/table"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"get": {
|
||||||
|
"summary": "Get all the tables, internal and external within an app.",
|
||||||
|
"tags": [
|
||||||
|
"tables"
|
||||||
|
],
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/tableId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/appId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Returns all of the tables which were found.",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"table": {
|
||||||
|
"$ref": "#/components/examples/row"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/tables/:tableId": {
|
||||||
|
"put": {
|
||||||
|
"summary": "Update the specified table. This can be for internal or external tables.",
|
||||||
|
"tags": [
|
||||||
|
"tables"
|
||||||
|
],
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/tableId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/appId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Returns the updated table.",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"table": {
|
||||||
|
"$ref": "#/components/examples/row"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/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": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"table": {
|
||||||
"$ref": "#/components/examples/table"
|
"$ref": "#/components/examples/table"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,13 @@ components:
|
||||||
description: The ID of the row which this request is targeting.
|
description: The ID of the row which this request is targeting.
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
|
appId:
|
||||||
|
in: header
|
||||||
|
name: appId
|
||||||
|
required: true
|
||||||
|
description: The ID of the app which this request is targeting.
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
examples:
|
examples:
|
||||||
table:
|
table:
|
||||||
value:
|
value:
|
||||||
|
@ -42,6 +49,32 @@ components:
|
||||||
tableId: ta_...
|
tableId: ta_...
|
||||||
fieldName: relatedColumn
|
fieldName: relatedColumn
|
||||||
relationshipType: many-to-many
|
relationshipType: many-to-many
|
||||||
|
tables:
|
||||||
|
value:
|
||||||
|
- _id: ta_5b1649e42a5b41dea4ef7742a36a7a70
|
||||||
|
name: People
|
||||||
|
schema:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
name: name
|
||||||
|
age:
|
||||||
|
type: number
|
||||||
|
name: age
|
||||||
|
relationship:
|
||||||
|
type: link
|
||||||
|
name: relationship
|
||||||
|
tableId: ta_...
|
||||||
|
fieldName: relatedColumn
|
||||||
|
relationshipType: many-to-many
|
||||||
|
inputRow:
|
||||||
|
value:
|
||||||
|
_id: ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4
|
||||||
|
type: row
|
||||||
|
tableId: ta_5b1649e42a5b41dea4ef7742a36a7a70
|
||||||
|
name: Mike
|
||||||
|
age: 30
|
||||||
|
relationship:
|
||||||
|
- ro_ta_...
|
||||||
row:
|
row:
|
||||||
value:
|
value:
|
||||||
_id: ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4
|
_id: ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4
|
||||||
|
@ -72,6 +105,17 @@ components:
|
||||||
name: x-budibase-api-key
|
name: x-budibase-api-key
|
||||||
description: Your individual API key, this will provide access based on the
|
description: Your individual API key, this will provide access based on the
|
||||||
configured RBAC settings of your user.
|
configured RBAC settings of your user.
|
||||||
|
schemas:
|
||||||
|
row:
|
||||||
|
description: The row to be created/updated, based on the table schema.
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
oneOf:
|
||||||
|
- type: string
|
||||||
|
- type: object
|
||||||
|
- type: integer
|
||||||
|
- type: array
|
||||||
|
- type: boolean
|
||||||
security:
|
security:
|
||||||
- ApiKeyAuth: []
|
- ApiKeyAuth: []
|
||||||
paths:
|
paths:
|
||||||
|
@ -82,6 +126,7 @@ paths:
|
||||||
- rows
|
- rows
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: "#/components/parameters/tableId"
|
- $ref: "#/components/parameters/tableId"
|
||||||
|
- $ref: "#/components/parameters/appId"
|
||||||
requestBody:
|
requestBody:
|
||||||
required: true
|
required: true
|
||||||
content:
|
content:
|
||||||
|
@ -109,6 +154,10 @@ paths:
|
||||||
type: object
|
type: object
|
||||||
description: Searches within a range, the format of this must be columnName ->
|
description: Searches within a range, the format of this must be columnName ->
|
||||||
[low, high].
|
[low, high].
|
||||||
|
example:
|
||||||
|
columnName1:
|
||||||
|
- 10
|
||||||
|
- 20
|
||||||
equal:
|
equal:
|
||||||
type: object
|
type: object
|
||||||
description: Searches for rows that have a column value that is exactly the
|
description: Searches for rows that have a column value that is exactly the
|
||||||
|
@ -122,6 +171,8 @@ paths:
|
||||||
description: Searches for rows which do not contain the specified column. The
|
description: Searches for rows which do not contain the specified column. The
|
||||||
object should simply contain keys of the column names,
|
object should simply contain keys of the column names,
|
||||||
these can map to any value.
|
these can map to any value.
|
||||||
|
example:
|
||||||
|
columnName1: ""
|
||||||
notEmpty:
|
notEmpty:
|
||||||
type: object
|
type: object
|
||||||
description: Searches for rows which have the specified column.
|
description: Searches for rows which have the specified column.
|
||||||
|
@ -188,9 +239,9 @@ paths:
|
||||||
description: If pagination in use, this will determine if there is another page
|
description: If pagination in use, this will determine if there is another page
|
||||||
to fetch.
|
to fetch.
|
||||||
type: boolean
|
type: boolean
|
||||||
examples:
|
examples:
|
||||||
search:
|
search:
|
||||||
- "#/components/examples/search"
|
$ref: "#/components/examples/search"
|
||||||
"/tables/{tableId}/rows":
|
"/tables/{tableId}/rows":
|
||||||
post:
|
post:
|
||||||
summary: Creates a new row within a specified table.
|
summary: Creates a new row within a specified table.
|
||||||
|
@ -198,22 +249,16 @@ paths:
|
||||||
- rows
|
- rows
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: "#/components/parameters/tableId"
|
- $ref: "#/components/parameters/tableId"
|
||||||
|
- $ref: "#/components/parameters/appId"
|
||||||
requestBody:
|
requestBody:
|
||||||
required: true
|
required: true
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
description: The contents of the row which is to be created, the keys of
|
$ref: "#/components/schemas/row"
|
||||||
type: object
|
examples:
|
||||||
example:
|
row:
|
||||||
$ref: "#/components/examples/row"
|
$ref: "#/components/examples/inputRow"
|
||||||
additionalProperties:
|
|
||||||
oneOf:
|
|
||||||
- type: string
|
|
||||||
- type: object
|
|
||||||
- type: integer
|
|
||||||
- type: array
|
|
||||||
- type: boolean
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Returns the created row, including the ID which has been generated
|
description: Returns the created row, including the ID which has been generated
|
||||||
|
@ -234,6 +279,16 @@ paths:
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: "#/components/parameters/tableId"
|
- $ref: "#/components/parameters/tableId"
|
||||||
- $ref: "#/components/parameters/rowId"
|
- $ref: "#/components/parameters/rowId"
|
||||||
|
- $ref: "#/components/parameters/appId"
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/row"
|
||||||
|
examples:
|
||||||
|
row:
|
||||||
|
$ref: "#/components/examples/inputRow"
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Returns the created row, including the ID which has been generated
|
description: Returns the created row, including the ID which has been generated
|
||||||
|
@ -252,6 +307,7 @@ paths:
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: "#/components/parameters/tableId"
|
- $ref: "#/components/parameters/tableId"
|
||||||
- $ref: "#/components/parameters/rowId"
|
- $ref: "#/components/parameters/rowId"
|
||||||
|
- $ref: "#/components/parameters/appId"
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Returns the deleted row, including the ID which has been generated
|
description: Returns the deleted row, including the ID which has been generated
|
||||||
|
@ -270,6 +326,7 @@ paths:
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: "#/components/parameters/tableId"
|
- $ref: "#/components/parameters/tableId"
|
||||||
- $ref: "#/components/parameters/rowId"
|
- $ref: "#/components/parameters/rowId"
|
||||||
|
- $ref: "#/components/parameters/appId"
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Returns the retrieved row.
|
description: Returns the retrieved row.
|
||||||
|
@ -280,20 +337,95 @@ paths:
|
||||||
examples:
|
examples:
|
||||||
row:
|
row:
|
||||||
$ref: "#/components/examples/row"
|
$ref: "#/components/examples/row"
|
||||||
|
/tables/search:
|
||||||
|
post:
|
||||||
|
summary: Search internal and external tables based on their name.
|
||||||
|
parameters:
|
||||||
|
- $ref: "#/components/parameters/appId"
|
||||||
|
tags:
|
||||||
|
- tables
|
||||||
|
requestBody: null
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: Returns the found tables, based on the search parameters.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
examples:
|
||||||
|
tables:
|
||||||
|
$ref: "#/components/examples/tables"
|
||||||
/tables:
|
/tables:
|
||||||
post:
|
post:
|
||||||
summary: Create a new table
|
summary: Create a new table.
|
||||||
|
parameters:
|
||||||
|
- $ref: "#/components/parameters/appId"
|
||||||
tags:
|
tags:
|
||||||
- tables
|
- tables
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Returns the created table, including the ID which has been
|
description: Returns the created table, including the ID which has been
|
||||||
generated for it.
|
generated for it. This can be internal or external data sources.
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: object
|
type: object
|
||||||
examples:
|
examples:
|
||||||
row:
|
table:
|
||||||
|
$ref: "#/components/examples/table"
|
||||||
|
get:
|
||||||
|
summary: Get all the tables, internal and external within an app.
|
||||||
|
tags:
|
||||||
|
- tables
|
||||||
|
parameters:
|
||||||
|
- $ref: "#/components/parameters/tableId"
|
||||||
|
- $ref: "#/components/parameters/appId"
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: Returns all of the tables which were found.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
examples:
|
||||||
|
table:
|
||||||
|
$ref: "#/components/examples/row"
|
||||||
|
/tables/:tableId:
|
||||||
|
put:
|
||||||
|
summary: Update the specified table. This can be for internal or external tables.
|
||||||
|
tags:
|
||||||
|
- tables
|
||||||
|
parameters:
|
||||||
|
- $ref: "#/components/parameters/tableId"
|
||||||
|
- $ref: "#/components/parameters/appId"
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: Returns the updated table.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
examples:
|
||||||
|
table:
|
||||||
|
$ref: "#/components/examples/row"
|
||||||
|
"/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:
|
||||||
|
type: object
|
||||||
|
examples:
|
||||||
|
table:
|
||||||
$ref: "#/components/examples/table"
|
$ref: "#/components/examples/table"
|
||||||
tags: []
|
tags: []
|
||||||
|
|
|
@ -17,3 +17,13 @@ exports.rowId = {
|
||||||
type: "string",
|
type: "string",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.appId = {
|
||||||
|
in: "header",
|
||||||
|
name: "appId",
|
||||||
|
required: true,
|
||||||
|
description: "The ID of the app which this request is targeting.",
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
exports.row = {
|
||||||
|
description: "The row to be created/updated, based on the table schema.",
|
||||||
|
type: "object",
|
||||||
|
additionalProperties: {
|
||||||
|
oneOf: [
|
||||||
|
{ type: "string" },
|
||||||
|
{ type: "object" },
|
||||||
|
{ type: "integer" },
|
||||||
|
{ type: "array" },
|
||||||
|
{ type: "boolean" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
|
@ -1,17 +1,35 @@
|
||||||
|
// makes sure that the user doesn't need to pass in the type, tableId or _id params for
|
||||||
|
// the call to be correct
|
||||||
|
function fixRow(row, params) {
|
||||||
|
if (!params || !row) {
|
||||||
|
return row
|
||||||
|
}
|
||||||
|
if (params.rowId) {
|
||||||
|
row._id = params.rowId
|
||||||
|
}
|
||||||
|
if (params.tableId) {
|
||||||
|
row.tableId = params.tableId
|
||||||
|
}
|
||||||
|
if (!row.type) {
|
||||||
|
row.type = "row"
|
||||||
|
}
|
||||||
|
return row
|
||||||
|
}
|
||||||
|
|
||||||
exports.search = () => {
|
exports.search = () => {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.create = () => {
|
exports.create = () => {
|
||||||
|
ctx.request.body = fixRow(ctx.request.body, ctx.params)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.singleRead = () => {
|
exports.singleRead = () => {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.update = () => {
|
exports.update = async ctx => {
|
||||||
|
ctx.request.body = fixRow(ctx.request.body, ctx.params)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.delete = () => {
|
exports.delete = () => {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
|
exports.search = () => {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
exports.create = () => {
|
exports.create = () => {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getAllTables = () => {
|
exports.singleRead = () => {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.getSingleTable = () => {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ const router = Router()
|
||||||
* - rows
|
* - rows
|
||||||
* parameters:
|
* parameters:
|
||||||
* - $ref: '#/components/parameters/tableId'
|
* - $ref: '#/components/parameters/tableId'
|
||||||
|
* - $ref: '#/components/parameters/appId'
|
||||||
* requestBody:
|
* requestBody:
|
||||||
* required: true
|
* required: true
|
||||||
* content:
|
* content:
|
||||||
|
@ -40,6 +41,8 @@ const router = Router()
|
||||||
* type: object
|
* type: object
|
||||||
* description: Searches within a range, the format of this must be
|
* description: Searches within a range, the format of this must be
|
||||||
* columnName -> [low, high].
|
* columnName -> [low, high].
|
||||||
|
* example:
|
||||||
|
* columnName1: [10, 20]
|
||||||
* equal:
|
* equal:
|
||||||
* type: object
|
* type: object
|
||||||
* description: Searches for rows that have a column value that is
|
* description: Searches for rows that have a column value that is
|
||||||
|
@ -53,6 +56,8 @@ const router = Router()
|
||||||
* description: Searches for rows which do not contain the specified column.
|
* description: Searches for rows which do not contain the specified column.
|
||||||
* The object should simply contain keys of the column names, these
|
* The object should simply contain keys of the column names, these
|
||||||
* can map to any value.
|
* can map to any value.
|
||||||
|
* example:
|
||||||
|
* columnName1: ""
|
||||||
* notEmpty:
|
* notEmpty:
|
||||||
* type: object
|
* type: object
|
||||||
* description: Searches for rows which have the specified column.
|
* description: Searches for rows which have the specified column.
|
||||||
|
@ -110,9 +115,9 @@ const router = Router()
|
||||||
* hasNextPage:
|
* hasNextPage:
|
||||||
* description: If pagination in use, this will determine if there is another page to fetch.
|
* description: If pagination in use, this will determine if there is another page to fetch.
|
||||||
* type: boolean
|
* type: boolean
|
||||||
* examples:
|
* examples:
|
||||||
* search:
|
* search:
|
||||||
* - '#/components/examples/search'
|
* $ref: '#/components/examples/search'
|
||||||
*/
|
*/
|
||||||
router.post("/tables/:tableId/rows/search", controller.search)
|
router.post("/tables/:tableId/rows/search", controller.search)
|
||||||
|
|
||||||
|
@ -125,22 +130,16 @@ router.post("/tables/:tableId/rows/search", controller.search)
|
||||||
* - rows
|
* - rows
|
||||||
* parameters:
|
* parameters:
|
||||||
* - $ref: '#/components/parameters/tableId'
|
* - $ref: '#/components/parameters/tableId'
|
||||||
|
* - $ref: '#/components/parameters/appId'
|
||||||
* requestBody:
|
* requestBody:
|
||||||
* required: true
|
* required: true
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* description: The contents of the row which is to be created, the keys of
|
* $ref: '#/components/schemas/row'
|
||||||
* type: object
|
* examples:
|
||||||
* example:
|
* row:
|
||||||
* $ref: '#/components/examples/row'
|
* $ref: '#/components/examples/inputRow'
|
||||||
* additionalProperties:
|
|
||||||
* oneOf:
|
|
||||||
* - type: string
|
|
||||||
* - type: object
|
|
||||||
* - type: integer
|
|
||||||
* - type: array
|
|
||||||
* - type: boolean
|
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Returns the created row, including the ID which has been generated for it.
|
* description: Returns the created row, including the ID which has been generated for it.
|
||||||
|
@ -165,6 +164,16 @@ router.post("/tables/:tableId/rows", controller.create)
|
||||||
* parameters:
|
* parameters:
|
||||||
* - $ref: '#/components/parameters/tableId'
|
* - $ref: '#/components/parameters/tableId'
|
||||||
* - $ref: '#/components/parameters/rowId'
|
* - $ref: '#/components/parameters/rowId'
|
||||||
|
* - $ref: '#/components/parameters/appId'
|
||||||
|
* requestBody:
|
||||||
|
* required: true
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* $ref: '#/components/schemas/row'
|
||||||
|
* examples:
|
||||||
|
* row:
|
||||||
|
* $ref: '#/components/examples/inputRow'
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Returns the created row, including the ID which has been generated for it.
|
* description: Returns the created row, including the ID which has been generated for it.
|
||||||
|
@ -188,6 +197,7 @@ router.put("/tables/:tableId/rows/:rowId", controller.update)
|
||||||
* parameters:
|
* parameters:
|
||||||
* - $ref: '#/components/parameters/tableId'
|
* - $ref: '#/components/parameters/tableId'
|
||||||
* - $ref: '#/components/parameters/rowId'
|
* - $ref: '#/components/parameters/rowId'
|
||||||
|
* - $ref: '#/components/parameters/appId'
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Returns the deleted row, including the ID which has been generated for it.
|
* description: Returns the deleted row, including the ID which has been generated for it.
|
||||||
|
@ -211,6 +221,7 @@ router.delete("/tables/:tableId/rows/:rowId", controller.delete)
|
||||||
* parameters:
|
* parameters:
|
||||||
* - $ref: '#/components/parameters/tableId'
|
* - $ref: '#/components/parameters/tableId'
|
||||||
* - $ref: '#/components/parameters/rowId'
|
* - $ref: '#/components/parameters/rowId'
|
||||||
|
* - $ref: '#/components/parameters/appId'
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Returns the retrieved row.
|
* description: Returns the retrieved row.
|
||||||
|
|
|
@ -2,22 +2,52 @@ const Router = require("@koa/router")
|
||||||
const controller = require("../../controllers/public/tables")
|
const controller = require("../../controllers/public/tables")
|
||||||
|
|
||||||
const router = Router()
|
const router = Router()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @openapi
|
||||||
|
* /tables/search:
|
||||||
|
* post:
|
||||||
|
* summary: Search internal and external tables based on their name.
|
||||||
|
* parameters:
|
||||||
|
* - $ref: '#/components/parameters/appId'
|
||||||
|
* tags:
|
||||||
|
* - tables
|
||||||
|
* requestBody:
|
||||||
|
*
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: Returns the found tables, based on the search parameters.
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
|
* type: object
|
||||||
|
* examples:
|
||||||
|
* tables:
|
||||||
|
* $ref: '#/components/examples/tables'
|
||||||
|
*/
|
||||||
|
router.post("/tables/search", controller.search)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @openapi
|
* @openapi
|
||||||
* /tables:
|
* /tables:
|
||||||
* post:
|
* post:
|
||||||
* summary: Create a new table
|
* summary: Create a new table.
|
||||||
|
* parameters:
|
||||||
|
* - $ref: '#/components/parameters/appId'
|
||||||
* tags:
|
* tags:
|
||||||
* - tables
|
* - tables
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Returns the created table, including the ID which has been generated for it.
|
* description: Returns the created table, including the ID which has been generated for it. This can be
|
||||||
|
* internal or external data sources.
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* type: object
|
||||||
* examples:
|
* examples:
|
||||||
* row:
|
* table:
|
||||||
* $ref: '#/components/examples/table'
|
* $ref: '#/components/examples/table'
|
||||||
*/
|
*/
|
||||||
router.post("/tables", controller.create)
|
router.post("/tables", controller.create)
|
||||||
|
@ -26,21 +56,21 @@ router.post("/tables", controller.create)
|
||||||
* @openapi
|
* @openapi
|
||||||
* /tables/:tableId:
|
* /tables/:tableId:
|
||||||
* put:
|
* put:
|
||||||
* summary: Update a single row within a specified table.
|
* summary: Update the specified table. This can be for internal or external tables.
|
||||||
* tags:
|
* tags:
|
||||||
* - tables
|
* - tables
|
||||||
* parameters:
|
* parameters:
|
||||||
* - $ref: '#/components/parameters/tableId'
|
* - $ref: '#/components/parameters/tableId'
|
||||||
* - $ref: '#/components/parameters/rowId'
|
* - $ref: '#/components/parameters/appId'
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Returns the created row, including the ID which has been generated for it.
|
* description: Returns the updated table.
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* type: object
|
||||||
* examples:
|
* examples:
|
||||||
* row:
|
* table:
|
||||||
* $ref: '#/components/examples/row'
|
* $ref: '#/components/examples/row'
|
||||||
*/
|
*/
|
||||||
router.put("/tables/:tableId", controller.update)
|
router.put("/tables/:tableId", controller.update)
|
||||||
|
@ -49,68 +79,45 @@ router.put("/tables/:tableId", controller.update)
|
||||||
* @openapi
|
* @openapi
|
||||||
* /tables:
|
* /tables:
|
||||||
* get:
|
* get:
|
||||||
* summary: Update a single row within a specified table.
|
* summary: Get all the tables, internal and external within an app.
|
||||||
* tags:
|
* tags:
|
||||||
* - tables
|
* - tables
|
||||||
* parameters:
|
* parameters:
|
||||||
* - $ref: '#/components/parameters/tableId'
|
* - $ref: '#/components/parameters/tableId'
|
||||||
* - $ref: '#/components/parameters/rowId'
|
* - $ref: '#/components/parameters/appId'
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Returns the created row, including the ID which has been generated for it.
|
* description: Returns all of the tables which were found.
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* type: object
|
||||||
* examples:
|
* examples:
|
||||||
* row:
|
* table:
|
||||||
* $ref: '#/components/examples/row'
|
* $ref: '#/components/examples/row'
|
||||||
*/
|
*/
|
||||||
router.get("/tables", controller.getAllTables)
|
router.get("/tables", controller.singleRead)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @openapi
|
* @openapi
|
||||||
* /tables/{tableId}/rows/{rowId}:
|
* /tables/{tableId}:
|
||||||
* put:
|
* delete:
|
||||||
* summary: Update a single row within a specified table.
|
* summary: Delete a single table and all of its data.
|
||||||
* tags:
|
* tags:
|
||||||
* - rows
|
* - tables
|
||||||
* parameters:
|
* parameters:
|
||||||
* - $ref: '#/components/parameters/tableId'
|
* - $ref: '#/components/parameters/tableId'
|
||||||
* - $ref: '#/components/parameters/rowId'
|
* - $ref: '#/components/parameters/appId'
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Returns the created row, including the ID which has been generated for it.
|
* description: Returns the deleted table.
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* type: object
|
||||||
* examples:
|
* examples:
|
||||||
* row:
|
* table:
|
||||||
* $ref: '#/components/examples/row'
|
* $ref: '#/components/examples/table'
|
||||||
*/
|
|
||||||
router.get("/tables/:tableId", controller.getSingleTable)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @openapi
|
|
||||||
* /tables/{tableId}/rows/{rowId}:
|
|
||||||
* put:
|
|
||||||
* summary: Update a single row within a specified table.
|
|
||||||
* tags:
|
|
||||||
* - rows
|
|
||||||
* parameters:
|
|
||||||
* - $ref: '#/components/parameters/tableId'
|
|
||||||
* - $ref: '#/components/parameters/rowId'
|
|
||||||
* responses:
|
|
||||||
* 200:
|
|
||||||
* description: Returns the created row, including the ID which has been generated for it.
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* type: object
|
|
||||||
* examples:
|
|
||||||
* row:
|
|
||||||
* $ref: '#/components/examples/row'
|
|
||||||
*/
|
*/
|
||||||
router.delete("/tables/:tableId", controller.delete)
|
router.delete("/tables/:tableId", controller.delete)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue