Generating from typescript files.

This commit is contained in:
mike12345567 2022-02-24 18:15:13 +00:00
parent dce23a9eb8
commit 26c2fc8702
5 changed files with 1668 additions and 20 deletions

View File

@ -46,7 +46,7 @@ const options = {
],
},
format: ".json",
apis: [join(__dirname, "..", "src", "api", "routes", "public", "*.js")],
apis: [join(__dirname, "..", "src", "api", "routes", "public", "*.ts")],
}
function writeFile(output, { isJson } = {}) {

File diff suppressed because it is too large Load Diff

View File

@ -321,9 +321,11 @@ components:
properties:
name:
type: string
required: true
url:
type: string
required:
- name
- url
applicationOutput:
type: object
properties:
@ -332,9 +334,11 @@ components:
properties:
name:
type: string
required: true
url:
type: string
required:
- name
- url
row:
description: The row to be created/updated, based on the table schema.
type: object
@ -686,5 +690,619 @@ components:
insensitive starts with match.
security:
- ApiKeyAuth: []
paths: {}
paths:
/applications/search:
post:
summary: Search for an application based on its app name.
tags:
- 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.
content:
application/json:
schema:
type: object
properties:
applications:
type: array
items:
$ref: "#/components/schemas/application"
examples:
applications:
$ref: "#/components/examples/applications"
/applications:
post:
summary: Create a new application.
tags:
- applications
parameters:
- $ref: "#/components/parameters/appId"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/application"
responses:
"200":
description: Returns the created application.
content:
application/json:
schema:
$ref: "#/components/schemas/applicationOutput"
examples:
application:
$ref: "#/components/examples/application"
"/applications/{appId}":
put:
summary: Update an existing application by its ID.
tags:
- applications
parameters:
- $ref: "#/components/parameters/appIdUrl"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/application"
responses:
"200":
description: Returns the updated application.
content:
application/json:
schema:
$ref: "#/components/schemas/applicationOutput"
examples:
application:
$ref: "#/components/examples/application"
delete:
summary: Delete an existing application by its ID.
tags:
- applications
parameters:
- $ref: "#/components/parameters/appIdUrl"
responses:
"200":
description: Returns the deleted application.
content:
application/json:
schema:
$ref: "#/components/schemas/applicationOutput"
examples:
application:
$ref: "#/components/examples/application"
get:
summary: Retrieve a single application by its ID.
tags:
- applications
parameters:
- $ref: "#/components/parameters/appIdUrl"
responses:
"200":
description: Returns the retrieved application.
content:
application/json:
schema:
$ref: "#/components/schemas/applicationOutput"
examples:
application:
$ref: "#/components/examples/application"
/queries/search:
post:
summary: Search for a query based on its name.
tags:
- 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.
content:
application/json:
schema:
type: object
properties:
queries:
type: array
items:
$ref: "#/components/schemas/query"
examples:
queries:
$ref: "#/components/examples/queries"
"/queries/{queryId}":
post:
summary: Execute a query and retrieve its response.
tags:
- queries
parameters:
- $ref: "#/components/parameters/queryId"
- $ref: "#/components/parameters/appId"
responses:
"200":
description: Returns the result of the query execution.
content:
application/json:
schema:
type: object
properties:
data:
type: array
description: The data retrieved from the query.
items:
type: object
description: The structure of the returned data will be an object, if it is just
a string then this will be an object containing "value".
pagination:
type: object
description: For supported query types this returns pagination information.
properties:
cursor:
type: string
description: The pagination cursor location.
raw:
type: string
description: The raw query response.
headers:
type: object
description: For REST queries the headers in the response will be returned here.
examples:
REST:
$ref: "#/components/examples/restResponse"
SQL:
$ref: "#/components/examples/sqlResponse"
"/tables/{tableId}/rows/search":
post:
summary: Used to search for rows within a table.
tags:
- rows
parameters:
- $ref: "#/components/parameters/tableId"
- $ref: "#/components/parameters/appId"
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
query:
type: object
properties:
string:
type: object
example:
columnName1: value
columnName2: value
description: A map of field name to the string to search for, this will look for
rows that have a value starting with the string value.
additionalProperties:
type: string
description: The value to search for in the column.
fuzzy:
type: object
description: A fuzzy search, only supported by internal tables.
range:
type: object
description: Searches within a range, the format of this must be columnName ->
[low, high].
example:
columnName1:
- 10
- 20
equal:
type: object
description: Searches for rows that have a column value that is exactly the
value set.
notEqual:
type: object
description: Searches for any row which does not contain the specified column
value.
empty:
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.
example:
columnName1: ""
notEmpty:
type: object
description: Searches for rows which have the specified column.
oneOf:
type: object
description: Searches for rows which have a column value that is any of the
specified values. The format of this must be columnName
-> [value1, value2].
paginate:
type: boolean
description: Enables pagination, by default this is disabled.
bookmark:
oneOf:
- type: string
- type: integer
description: If retrieving another page, the bookmark from the previous request
must be supplied.
limit:
type: integer
description: The maximum number of rows to return, useful when paginating, for
internal tables this will be limited to 1000, for SQL tables
it will be 5000.
sort:
type: object
description: A set of parameters describing the sort behaviour of the search.
properties:
order:
type: string
enum:
- ascending
- descending
description: The order of the sort, by default this is ascending.
column:
type: string
description: The name of the column by which the rows will be sorted.
type:
type: string
enum:
- string
- number
description: Defines whether the column should be treated as a string or as
numbers when sorting.
responses:
"200":
description: The response will contain an array of rows that match the search
parameters.
content:
application/json:
schema:
type: object
properties:
rows:
description: An array of rows, these will each contain an _id field which can be
used to update or delete them.
type: array
items:
type: object
bookmark:
oneOf:
- type: string
- type: integer
description: If pagination in use, this should be provided.
hasNextPage:
description: If pagination in use, this will determine if there is another page
to fetch.
type: boolean
examples:
search:
$ref: "#/components/examples/rows"
"/tables/{tableId}/rows":
post:
summary: Creates a new row within a specified table.
tags:
- rows
parameters:
- $ref: "#/components/parameters/tableId"
- $ref: "#/components/parameters/appId"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/row"
examples:
row:
$ref: "#/components/examples/inputRow"
responses:
"200":
description: Returns the created row, including the ID which has been generated
for it. This can be found in the Budibase portal, viewed under the
developer information.
content:
application/json:
schema:
$ref: "#/components/schemas/rowOutput"
examples:
row:
$ref: "#/components/examples/row"
"/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"
- $ref: "#/components/parameters/appId"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/row"
examples:
row:
$ref: "#/components/examples/inputRow"
responses:
"200":
description: Returns the created row, including the ID which has been generated
for it.
content:
application/json:
schema:
$ref: "#/components/schemas/rowOutput"
examples:
row:
$ref: "#/components/examples/row"
delete:
summary: Delete a single row from the specified table.
tags:
- rows
parameters:
- $ref: "#/components/parameters/tableId"
- $ref: "#/components/parameters/rowId"
- $ref: "#/components/parameters/appId"
responses:
"200":
description: Returns the deleted row, including the ID which has been generated
for it.
content:
application/json:
schema:
$ref: "#/components/schemas/rowOutput"
examples:
row:
$ref: "#/components/examples/row"
get:
summary: Get a single row from the specified table.
tags:
- rows
parameters:
- $ref: "#/components/parameters/tableId"
- $ref: "#/components/parameters/rowId"
- $ref: "#/components/parameters/appId"
responses:
"200":
description: Returns the retrieved row.
content:
application/json:
schema:
$ref: "#/components/schemas/rowOutput"
examples:
row:
$ref: "#/components/examples/row"
/tables/search:
post:
summary: Search internal and external tables based on their name.
tags:
- tables
parameters:
- $ref: "#/components/parameters/appId"
requestBody:
required: true
content:
application/json:
schema:
$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"
/tables:
post:
summary: Create a new table.
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 internal or external data sources.
content:
application/json:
schema:
$ref: "#/components/schemas/tableOutput"
examples:
table:
$ref: "#/components/examples/table"
"/tables/{tableId}":
put:
summary: Update the specified table.
tags:
- tables
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.
content:
application/json:
schema:
$ref: "#/components/schemas/tableOutput"
examples:
table:
$ref: "#/components/examples/table"
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"
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"
/users/search:
post:
summary: Search for a user based on their email/username.
tags:
- 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.
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/user"
examples:
users:
$ref: "#/components/examples/users"
/users:
post:
summary: Create a new user in the Budibase portal.
tags:
- users
parameters:
- $ref: "#/components/parameters/appId"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/user"
responses:
"200":
description: Returns the created user.
content:
application/json:
schema:
$ref: "#/components/schemas/userOutput"
examples:
user:
$ref: "#/components/examples/user"
"/users/{userId}":
put:
summary: Update an existing user by their ID.
tags:
- users
parameters:
- $ref: "#/components/parameters/userId"
- $ref: "#/components/parameters/appId"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/user"
responses:
"200":
description: Returns the updated user.
content:
application/json:
schema:
$ref: "#/components/schemas/userOutput"
examples:
user:
$ref: "#/components/examples/user"
delete:
summary: Delete an existing user by their ID.
tags:
- users
parameters:
- $ref: "#/components/parameters/userId"
- $ref: "#/components/parameters/appId"
responses:
"200":
description: Returns the deleted user.
content:
application/json:
schema:
$ref: "#/components/schemas/userOutput"
examples:
user:
$ref: "#/components/examples/user"
get:
summary: Retrieve a single user by their ID.
tags:
- users
parameters:
- $ref: "#/components/parameters/userId"
- $ref: "#/components/parameters/appId"
responses:
"200":
description: Returns the retrieved user.
content:
application/json:
schema:
$ref: "#/components/schemas/userOutput"
examples:
user:
$ref: "#/components/examples/user"
tags: []

View File

@ -15,15 +15,17 @@ const application = {
lockedBy: userResource.getExamples().user.value.user,
}
const applicationSchema = object({
const applicationSchema = object(
{
name: {
type: "string",
required: true,
},
url: {
type: "string",
},
})
},
{ required: ["name", "url"] }
)
module.exports = new Resource()
.setExamples({

View File

@ -1,6 +1,7 @@
exports.object = props => {
exports.object = (props, opts) => {
return {
type: "object",
properties: props,
...opts,
}
}