Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

feat: remove baseId from params and update response structure

Pranav Cc2d17dacf6c8
diff --git a/packages/nocodb/src/services/api-docs/swaggerV3/swagger-base-v3.json b/packages/nocodb/src/services/api-docs/swaggerV3/swagger-base-v3.json
index 251349a598..8845f50367 100644
--- a/packages/nocodb/src/services/api-docs/swaggerV3/swagger-base-v3.json
+++ b/packages/nocodb/src/services/api-docs/swaggerV3/swagger-base-v3.json
@@ -33,8 +33,10 @@
"type": "number"
},
"next": {
- "type": "string",
- "nullable": true,
+ "type": [
+ "string",
+ "null"
+ ],
"description": "URL to retrieve the next page of records"
}
}
@@ -73,6 +75,69 @@
"description": "the value of the given column"
}
}
+ },
+ "DataRecordV3": {
+ "type": "object",
+ "description": "V3 Data Record format with id and fields separation",
+ "properties": {
+ "id": {
+ "oneOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "number"
+ }
+ ],
+ "description": "Record identifier (primary key value)"
+ },
+ "fields": {
+ "type": "object",
+ "description": "Record fields data (excluding primary key). Undefined when empty.",
+ "additionalProperties": true
+ }
+ },
+ "required": ["id"]
+ },
+ "DataListResponseV3": {
+ "type": "object",
+ "description": "V3 Data List Response format",
+ "properties": {
+ "records": {
+ "type": "array",
+ "description": "Array of records for has-many and many-to-many relationships",
+ "items": {
+ "$ref": "#/components/schemas/DataRecordV3"
+ }
+ },
+ "next": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "Pagination token for next page"
+ },
+ "prev": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "Pagination token for previous page"
+ },
+ "page": {
+ "type": "integer",
+ "description": "Current page number"
+ },
+ "pageSize": {
+ "type": "integer",
+ "description": "Number of records per page"
+ },
+ "totalRows": {
+ "type": "integer",
+ "description": "Total number of records"
+ }
+ },
+ "required": ["records"]
}
},
"securitySchemes": {
diff --git a/packages/nocodb/src/services/api-docs/swaggerV3/templates/paths.ts b/packages/nocodb/src/services/api-docs/swaggerV3/templates/paths.ts
index c4a4a54ecf..82cd791df4 100644
--- a/packages/nocodb/src/services/api-docs/swaggerV3/templates/paths.ts
+++ b/packages/nocodb/src/services/api-docs/swaggerV3/templates/paths.ts
@@ -27,17 +27,6 @@ export const getModelPaths = async (
},
): Promise<{ [path: string]: any }> => ({
[`/api/v3/data/{baseId}/${ctx.tableId}/records`]: {
- parameters: [
- {
- name: 'baseId',
- in: 'path',
- required: true,
- schema: {
- type: 'string'
- },
- description: 'Base Identifier'
- }
- ],
get: {
summary: `${ctx.tableName} list`,
operationId: `${ctx.tableName.toLowerCase()}-db-table-row-list`,
@@ -58,7 +47,9 @@ export const getModelPaths = async (
description: 'OK',
content: {
'application/json': {
- schema: getPaginatedResponseType(`${ctx.tableName}Response`),
+ schema: {
+ $ref: '#/components/schemas/DataListResponseV3'
+ },
},
},
},
@@ -182,15 +173,6 @@ export const getModelPaths = async (
},
[`/api/v3/data/{baseId}/${ctx.tableId}/records/{recordId}`]: {
parameters: [
- {
- name: 'baseId',
- in: 'path',
- required: true,
- schema: {
- type: 'string'
- },
- description: 'Base Identifier'
- },
recordIdParam,
fieldsParam
],
@@ -200,12 +182,12 @@ export const getModelPaths = async (
operationId: `${ctx.tableName.toLowerCase()}-read`,
tags: [ctx.tableName],
responses: {
- '201': {
- description: 'Created',
+ '200': {
+ description: 'OK',
content: {
'application/json': {
schema: {
- $ref: `#/components/schemas/${ctx.tableName}Response`,
+ $ref: '#/components/schemas/DataRecordV3'
},
},
},
@@ -215,15 +197,6 @@ export const getModelPaths = async (
},
[`/api/v3/data/{baseId}/${ctx.tableId}/records/count`]: {
parameters: [
- {
- name: 'baseId',
- in: 'path',
- required: true,
- schema: {
- type: 'string'
- },
- description: 'Base Identifier'
- },
viewIdParams(ctx.views)
],
get: {
@@ -268,15 +241,6 @@ export const getModelPaths = async (
[`/api/v3/data/{baseId}/${ctx.tableId}/links/{linkFieldId}/records/{recordId}`]:
{
parameters: [
- {
- name: 'baseId',
- in: 'path',
- required: true,
- schema: {
- type: 'string'
- },
- description: 'Base Identifier'
- },
linkFieldNameParam(ctx.columns),
recordIdParam
],
@@ -299,21 +263,7 @@ export const getModelPaths = async (
content: {
'application/json': {
schema: {
- type: 'object',
- properties: {
- list: {
- type: 'array',
- description: 'List of data objects',
- items: {
- type: 'object',
- },
- },
- pageInfo: {
- $ref: '#/components/schemas/Paginated',
- description: 'Paginated Info',
- },
- },
- required: ['list', 'pageInfo'],
+ $ref: '#/components/schemas/DataListResponseV3'
},
},
},
@@ -444,19 +394,3 @@ export const getModelPaths = async (
: {}),
});
-function getPaginatedResponseType(type: string) {
- return {
- type: 'object',
- properties: {
- list: {
- type: 'array',
- items: {
- $ref: `#/components/schemas/${type}`,
- },
- },
- pageInfo: {
- $ref: `#/components/schemas/Paginated`,
- },
- },
- };
-}
diff --git a/packages/nocodb/src/services/api-docs/swaggerV3/templates/schemas.ts b/packages/nocodb/src/services/api-docs/swaggerV3/templates/schemas.ts
index 1a91ac9a59..cbfdf1af0d 100644
--- a/packages/nocodb/src/services/api-docs/swaggerV3/templates/schemas.ts
+++ b/packages/nocodb/src/services/api-docs/swaggerV3/templates/schemas.ts
@@ -7,16 +7,16 @@ export const getModelSchemas = (ctx: {
baseName: string;
columns: Array<SwaggerColumn>;
}) => ({
- [`${ctx.tableName}Response`]: {
- title: `${ctx.tableName} Response`,
+ [`${ctx.tableName}Fields`]: {
+ title: `${ctx.tableName} Fields`,
type: 'object',
- description: '',
+ description: 'Fields data for the record (excluding primary key)',
'x-internal': false,
properties: {
...(ctx.columns?.reduce(
(colsObj, { title, virtual, column, ...fieldProps }) => ({
...colsObj,
- ...(column.system
+ ...(column.system || column.pk
? {}
: {
[title]: fieldProps,