Browse Source

fix(nocodb): ProjectUpdateReqType

pull/5307/head
Wing-Kam Wong 2 years ago
parent
commit
04a577a4b9
  1. 9
      packages/nocodb/src/lib/services/project.svc.ts
  2. 60
      packages/nocodb/src/schema/swagger.json

9
packages/nocodb/src/lib/services/project.svc.ts

@ -11,7 +11,7 @@ import Project from '../models/Project';
import syncMigration from '../meta/helpers/syncMigration'; import syncMigration from '../meta/helpers/syncMigration';
import { populateMeta, validatePayload } from '../meta/api/helpers'; import { populateMeta, validatePayload } from '../meta/api/helpers';
import { extractPropsAndSanitize } from '../meta/helpers/extractProps'; import { extractPropsAndSanitize } from '../meta/helpers/extractProps';
import type { ProjectReqType } from 'nocodb-sdk'; import type { ProjectReqType, ProjectUpdateReqType } from 'nocodb-sdk';
export async function projectCreate(param: { export async function projectCreate(param: {
project: ProjectReqType; project: ProjectReqType;
@ -136,8 +136,13 @@ export function sanitizeProject(project: any) {
export async function projectUpdate(param: { export async function projectUpdate(param: {
projectId: string; projectId: string;
project: ProjectReqType; project: ProjectUpdateReqType;
}) { }) {
validatePayload(
'swagger.json#/components/schemas/ProjectUpdateReq',
param.project
);
const project = await Project.getWithInfo(param.projectId); const project = await Project.getWithInfo(param.projectId);
const data: Partial<Project> = extractPropsAndSanitize( const data: Partial<Project> = extractPropsAndSanitize(

60
packages/nocodb/src/schema/swagger.json

@ -2149,7 +2149,20 @@
"operationId": "project-update", "operationId": "project-update",
"responses": { "responses": {
"200": { "200": {
"description": "OK" "description": "OK",
"content": {
"application/json": {
"schema": {
"type": "number",
"example": 1
},
"examples": {
"Example 1": {
"value": 1
}
}
}
}
}, },
"400": { "400": {
"$ref": "#/components/responses/BadRequest" "$ref": "#/components/responses/BadRequest"
@ -2160,11 +2173,15 @@
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"type": "number" "$ref": "#/components/schemas/ProjectUpdateReq"
}, },
"examples": { "examples": {
"Example 1": { "Example 1": {
"value": 1 "value": {
"color": "#24716E",
"meta": null,
"title": "My Project"
}
} }
} }
} }
@ -17484,6 +17501,43 @@
"title": "Project Request Model", "title": "Project Request Model",
"type": "object" "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": { "ProjectUserReq": {
"description": "Model for Project User Request", "description": "Model for Project User Request",
"examples": [ "examples": [

Loading…
Cancel
Save