π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix: corrections in schema
Pranav C67ed08ae7e44
diff --git a/packages/nocodb/src/services/api-docs/swaggerV3/getSwaggerColumnMetasV3.ts b/packages/nocodb/src/services/api-docs/swaggerV3/getSwaggerColumnMetasV3.tsindex 23f48eee02..022a312400 100644--- a/packages/nocodb/src/services/api-docs/swaggerV3/getSwaggerColumnMetasV3.ts+++ b/packages/nocodb/src/services/api-docs/swaggerV3/getSwaggerColumnMetasV3.ts@@ -7,6 +7,7 @@ import type { DriverClient } from '~/utils/nc-config';import SwaggerTypes from '~/db/sql-mgr/code/routers/xc-ts/SwaggerTypes';import Noco from '~/Noco';+// TODO: refactor and avoid duplication// Helper function to process a single column and return its swagger field definitionasync function processColumnToSwaggerField(context: NcContext,diff --git a/packages/nocodb/src/services/api-docs/swaggerV3/templates/params.ts b/packages/nocodb/src/services/api-docs/swaggerV3/templates/params.tsindex ba584d98cb..0dd00767f6 100644--- a/packages/nocodb/src/services/api-docs/swaggerV3/templates/params.ts+++ b/packages/nocodb/src/services/api-docs/swaggerV3/templates/params.ts@@ -29,6 +29,7 @@ export const fieldsParam = {},in: 'query',name: 'fields',+ example: null,description:'Allows you to specify the fields that you wish to include from the linked records in your API response. By default, only Primary Key and associated display value field is included.\n\nExample: `fields=["field1","field2"]` or `fields=field1,field2` will include only \'field1\' and \'field2\' in the API response.',};@@ -68,6 +69,7 @@ export const sortParam = {},in: 'query',name: 'sort',+ example: null,description:'Allows you to specify the fields by which you want to sort the records in your API response. Accepts either an array of sort objects or a single sort object.\n\nEach sort object must have a \'field\' property specifying the field name and a \'direction\' property with value \'asc\' or \'desc\'.\n\nExample: `sort=[{"direction":"asc","field":"field_name"},{"direction":"desc","field":"another_field"}]` or `sort={"direction":"asc","field":"field_name"}`\n\nIf `viewId` query parameter is also included, the sort included here will take precedence over any sorting configuration defined in the view.',};@@ -77,6 +79,7 @@ export const whereParam = {},in: 'query',name: 'where',+ example: null,description:"Enables you to define specific conditions for filtering records in your API response. Multiple conditions can be combined using logical operators such as 'and' and 'or'. Each condition consists of three parts: a field name, a comparison operator, and a value.\n\nExample: `where=(field1,eq,value1)~and(field2,eq,value2)` will filter records where 'field1' is equal to 'value1' AND 'field2' is equal to 'value2'. \n\nYou can also use other comparison operators like 'neq' (not equal), 'gt' (greater than), 'lt' (less than), and more, to create complex filtering rules.\n\nIf `viewId` query parameter is also included, then the filters included here will be applied over the filtering configuration defined in the view. \n\nPlease remember to maintain the specified format, and do not include spaces between the different condition components",};diff --git a/packages/nocodb/src/services/api-docs/swaggerV3/templates/paths.ts b/packages/nocodb/src/services/api-docs/swaggerV3/templates/paths.tsindex 6887022730..b4a9c95697 100644--- a/packages/nocodb/src/services/api-docs/swaggerV3/templates/paths.ts+++ b/packages/nocodb/src/services/api-docs/swaggerV3/templates/paths.ts@@ -1,4 +1,4 @@-import { ModelTypes } from 'nocodb-sdk';+import { ModelTypes, UITypes } from 'nocodb-sdk';import {attachmentFieldIdParam,fieldsParam,@@ -66,7 +66,16 @@ export const getModelPaths = async (content: {'application/json': {schema: {- $ref: `#/components/schemas/${ctx.tableName}Response`,+ type: 'object',+ properties: {+ records: {+ type: 'array',+ items: {+ $ref: `#/components/schemas/${ctx.tableName}Response`,+ },+ },+ },+ required: ['records'],},},},@@ -106,7 +115,18 @@ export const getModelPaths = async (description: 'OK',content: {'application/json': {- schema: {},+ schema: {+ type: 'object',+ properties: {+ records: {+ type: 'array',+ items: {+ $ref: `#/components/schemas/${ctx.tableName}Response`,+ },+ },+ },+ required: ['records'],+ },},},},@@ -121,12 +141,12 @@ export const getModelPaths = async (schema: {oneOf: [{- $ref: `#/components/schemas/${ctx.tableName}Request`,+ $ref: `#/components/schemas/${ctx.tableName}UpdateRequest`,},{type: 'array',items: {- $ref: `#/components/schemas/${ctx.tableName}Request`,+ $ref: `#/components/schemas/${ctx.tableName}UpdateRequest`,},},],@@ -190,7 +210,7 @@ export const getModelPaths = async (},},},- [`/api/v3/data/${ctx.baseId}/${ctx.tableId}/records/count`]: {+ [`/api/v3/data/${ctx.baseId}/${ctx.tableId}/count`]: {parameters: [viewIdParam(ctx.views)],get: {summary: `${ctx.tableName} count`,@@ -210,7 +230,6 @@ export const getModelPaths = async (type: 'number',},},- required: ['count'],},examples: {'Example 1': {@@ -271,7 +290,10 @@ export const getModelPaths = async (description: 'OK',content: {'application/json': {- schema: {},+ schema: {+ type: 'boolean',+ description: 'Success status of the link operation',+ },examples: {'Example 1': {value: true,@@ -333,7 +355,10 @@ export const getModelPaths = async (description: 'OK',content: {'application/json': {- schema: {},+ schema: {+ type: 'boolean',+ description: 'Success status of the unlink operation',+ },examples: {'Example 1': {value: true,@@ -498,17 +523,13 @@ function getPaginatedResponseTypeV3(type: string) {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',+ nestedNext: {+ type: ['string', 'null'],+ description: 'Nested pagination token for next page',},- totalRows: {- type: 'integer',- description: 'Total number of records',+ nestedPrev: {+ type: ['string', 'null'],+ description: 'Nested pagination token for previous page',},},required: ['records'],diff --git a/packages/nocodb/src/services/api-docs/swaggerV3/templates/schemas.ts b/packages/nocodb/src/services/api-docs/swaggerV3/templates/schemas.tsindex f9b71f14ed..b57fc4f1d2 100644--- a/packages/nocodb/src/services/api-docs/swaggerV3/templates/schemas.ts+++ b/packages/nocodb/src/services/api-docs/swaggerV3/templates/schemas.ts@@ -43,18 +43,62 @@ export const getModelSchemas = (ctx: {description: '','x-internal': false,properties: {- ...(ctx.columns?.reduce(- (colsObj, { title, virtual, column, ...fieldProps }) => ({- ...colsObj,- ...(virtual || isSystemColumn(column) || column.ai || column.meta?.ag- ? {}- : {- [title]: fieldProps,- }),- }),- {},- ) || {}),+ fields: {+ type: 'object',+ description: 'Record fields data to be created/updated',+ properties: {+ ...(ctx.columns?.reduce(+ (colsObj, { title, virtual, column, ...fieldProps }) => ({+ ...colsObj,+ ...(virtual ||+ isSystemColumn(column) ||+ column.ai ||+ column.meta?.ag+ ? {}+ : {+ [title]: fieldProps,+ }),+ }),+ {},+ ) || {}),+ },+ },+ },+ required: ['fields'],+ },+ [`${ctx.tableName}UpdateRequest`]: {+ title: `${ctx.tableName} Update Request`,+ type: 'object',+ description: '',+ 'x-internal': false,+ properties: {+ id: {+ oneOf: [{ type: 'string' }, { type: 'number' }],+ description:+ 'Record identifier (primary key value) for the record to be updated',+ },+ fields: {+ type: 'object',+ description: 'Record fields data to be updated',+ properties: {+ ...(ctx.columns?.reduce(+ (colsObj, { title, virtual, column, ...fieldProps }) => ({+ ...colsObj,+ ...(virtual ||+ isSystemColumn(column) ||+ column.ai ||+ column.meta?.ag+ ? {}+ : {+ [title]: fieldProps,+ }),+ }),+ {},+ ) || {}),+ },+ },},+ required: ['id', 'fields'],},[`${ctx.tableName}IdRequest`]: {title: `${ctx.tableName} Id Request`,@@ -62,18 +106,13 @@ export const getModelSchemas = (ctx: {description: '','x-internal': false,properties: {- ...(ctx.columns?.reduce(- (colsObj, { title, virtual, column, ...fieldProps }) => ({- ...colsObj,- ...(column.pk- ? {- [title]: fieldProps,- }- : {}),- }),- {},- ) || {}),+ id: {+ oneOf: [{ type: 'string' }, { type: 'number' }],+ description:+ 'Record identifier (primary key value) for the record to be deleted',+ },},+ required: ['id'],},});@@ -90,14 +129,29 @@ export const getViewSchemas = (ctx: {description: '','x-internal': false,properties: {- ...(ctx.columns?.reduce(- (colsObj, { title, virtual, column, ...fieldProps }) => ({- ...colsObj,- [title]: fieldProps,- }),- {},- ) || {}),+ id: {+ oneOf: [{ type: 'string' }, { type: 'number' }],+ description: 'Record identifier (primary key value)',+ },+ fields: {+ type: 'object',+ description: 'Record fields data from view',+ properties: {+ ...(ctx.columns?.reduce(+ (colsObj, { title, virtual, column, ...fieldProps }) => ({+ ...colsObj,+ ...(column.system || column.pk+ ? {}+ : {+ [title]: fieldProps,+ }),+ }),+ {},+ ) || {}),+ },+ },},+ required: ['id'],},[`${ctx.tableName}${ctx.viewName}GridRequest`]: {title: `${ctx.tableName} : ${ctx.viewName} Request`,@@ -105,17 +159,24 @@ export const getViewSchemas = (ctx: {description: '','x-internal': false,properties: {- ...(ctx.columns?.reduce(- (colsObj, { title, virtual, column, ...fieldProps }) => ({- ...colsObj,- ...(virtual- ? {}- : {- [title]: fieldProps,- }),- }),- {},- ) || {}),+ fields: {+ type: 'object',+ description: 'Record fields data for view-based operations',+ properties: {+ ...(ctx.columns?.reduce(+ (colsObj, { title, virtual, column, ...fieldProps }) => ({+ ...colsObj,+ ...(virtual+ ? {}+ : {+ [title]: fieldProps,+ }),+ }),+ {},+ ) || {}),+ },+ },},+ required: ['fields'],},});