π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix swagger
Fendy Heryanto696db9ece255
diff --git a/packages/nocodb/src/schema/swagger-v3.json b/packages/nocodb/src/schema/swagger-v3.jsonindex 38ee1cdd87..3bab522f42 100644--- a/packages/nocodb/src/schema/swagger-v3.json+++ b/packages/nocodb/src/schema/swagger-v3.json@@ -5265,44 +5265,47 @@}},"ViewColumnOption": {- "fieldsById": {- "type": "object",- "additionalProperties": {+ "type": "object",+ "properties": {+ "fieldsById": {"type": "object",- "properties": {- "alias": {- "type": "string"- },- "description": {- "type": "string"- },- "required": {- "type": "boolean"- },- "allowScannerInput": {- "type": "boolean"- },- "isList": {- "type": "boolean"- },- "isLimitOption": {- "type": "boolean"- },- "validators": {- "type": "array",- "items": {- "type": "object",- "properties": {- "type": {- "type": "string"- },- "value": {},- "message": {- "type": "string"- },- "regex": {- "type": "string",- "nullable": true+ "additionalProperties": {+ "type": "object",+ "properties": {+ "alias": {+ "type": "string"+ },+ "description": {+ "type": "string"+ },+ "required": {+ "type": "boolean"+ },+ "allowScannerInput": {+ "type": "boolean"+ },+ "isList": {+ "type": "boolean"+ },+ "isLimitOption": {+ "type": "boolean"+ },+ "validators": {+ "type": "array",+ "items": {+ "type": "object",+ "properties": {+ "type": {+ "type": "string"+ },+ "value": {},+ "message": {+ "type": "string"+ },+ "regex": {+ "type": "string",+ "nullable": true+ }}}}diff --git a/packages/nocodb/src/services/v3/views-v3.service.ts b/packages/nocodb/src/services/v3/views-v3.service.tsindex cfe38c63f8..58efe0e725 100644--- a/packages/nocodb/src/services/v3/views-v3.service.ts+++ b/packages/nocodb/src/services/v3/views-v3.service.ts@@ -6,12 +6,13 @@ import { KanbansService } from '../kanbans.service';import { GalleriesService } from '../galleries.service';import { FormsService } from '../forms.service';import { GridColumnsService } from '../grid-columns.service';+import type { ViewColumnOptionV3Type } from 'nocodb-sdk';import type { MetaService } from '~/meta/meta.service';import type { ApiV3DataTransformationBuilder } from 'src/utils/data-transformation.builder';import type { NcContext, NcRequest } from '~/interface/config';import type { GridViewColumn } from '~/models';import Noco from '~/Noco';-import { Sort, View } from '~/models';+import { Model, Sort, View } from '~/models';import {builderGenerator,viewColumnBuilder,@@ -440,6 +441,15 @@ export class ViewsV3Service {true,context,);+ await this.validateFieldsById(+ context,+ {+ tableId: param.tableId,+ req: param.req,+ fieldsById: body.options.fieldsById,+ },+ ncMeta,+ );}}@@ -603,6 +613,29 @@ export class ViewsV3Service {}}+ async validateFieldsById(+ context: NcContext,+ param: {+ req: NcRequest;+ tableId: string;+ fieldsById: ViewColumnOptionV3Type['fieldsById'];+ },+ ncMeta?: MetaService,+ ) {+ const columnKeys = Object.keys(param.fieldsById ?? {});+ if (columnKeys.length === 0) {+ return;+ }+ const model = await Model.get(context, param.tableId, ncMeta);+ const columns = await model.getColumns(context, ncMeta);+ const existingColumnKeys = columns.map((k) => k.id);+ if (columnKeys.find((col) => !existingColumnKeys.includes(col))) {+ NcError.fieldNotFound(+ columnKeys.find((col) => !existingColumnKeys.includes(col)),+ );+ }+ }+async update(context: NcContext,param: { req: NcRequest; viewId: string },