From 04a577a4b97ae03efbea1dca343fc3618a18d1a3 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 16 Mar 2023 12:23:52 +0800 Subject: [PATCH] fix(nocodb): ProjectUpdateReqType --- .../nocodb/src/lib/services/project.svc.ts | 9 ++- packages/nocodb/src/schema/swagger.json | 60 ++++++++++++++++++- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/packages/nocodb/src/lib/services/project.svc.ts b/packages/nocodb/src/lib/services/project.svc.ts index bfb2d7cba8..023a1ebe30 100644 --- a/packages/nocodb/src/lib/services/project.svc.ts +++ b/packages/nocodb/src/lib/services/project.svc.ts @@ -11,7 +11,7 @@ import Project from '../models/Project'; import syncMigration from '../meta/helpers/syncMigration'; import { populateMeta, validatePayload } from '../meta/api/helpers'; import { extractPropsAndSanitize } from '../meta/helpers/extractProps'; -import type { ProjectReqType } from 'nocodb-sdk'; +import type { ProjectReqType, ProjectUpdateReqType } from 'nocodb-sdk'; export async function projectCreate(param: { project: ProjectReqType; @@ -136,8 +136,13 @@ export function sanitizeProject(project: any) { export async function projectUpdate(param: { projectId: string; - project: ProjectReqType; + project: ProjectUpdateReqType; }) { + validatePayload( + 'swagger.json#/components/schemas/ProjectUpdateReq', + param.project + ); + const project = await Project.getWithInfo(param.projectId); const data: Partial = extractPropsAndSanitize( diff --git a/packages/nocodb/src/schema/swagger.json b/packages/nocodb/src/schema/swagger.json index baca6ccd60..5ed9414b6d 100644 --- a/packages/nocodb/src/schema/swagger.json +++ b/packages/nocodb/src/schema/swagger.json @@ -2149,7 +2149,20 @@ "operationId": "project-update", "responses": { "200": { - "description": "OK" + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "number", + "example": 1 + }, + "examples": { + "Example 1": { + "value": 1 + } + } + } + } }, "400": { "$ref": "#/components/responses/BadRequest" @@ -2160,11 +2173,15 @@ "content": { "application/json": { "schema": { - "type": "number" + "$ref": "#/components/schemas/ProjectUpdateReq" }, "examples": { "Example 1": { - "value": 1 + "value": { + "color": "#24716E", + "meta": null, + "title": "My Project" + } } } } @@ -17484,6 +17501,43 @@ "title": "Project Request Model", "type": "object" }, + "ProjectUpdateReq": { + "description": "Model for Project Update Request", + "x-stoplight": { + "id": "4zgrec70wyz4c" + }, + "examples": [ + { + "color": "#24716E", + "meta": null, + "title": "My Project" + } + ], + "title": "Project Update Request Model", + "type": "object", + "properties": { + "color": { + "description": "Primary Theme Color", + "example": "#24716E", + "maxLength": 50, + "type": "string" + }, + "meta": { + "$ref": "#/components/schemas/Meta", + "description": "Project Meta", + "x-stoplight": { + "id": "m05w9sbwqgul3" + } + }, + "title": { + "description": "Project Title", + "example": "My Project", + "maxLength": 128, + "minLength": 1, + "type": "string" + } + } + }, "ProjectUserReq": { "description": "Model for Project User Request", "examples": [