Skip to content

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

validate swagger

Fendy Heryanto53985a6785af
diff --git a/packages/nocodb/src/schema/swagger-v3-validation-patch.json b/packages/nocodb/src/schema/swagger-v3-validation-patch.json
index 343934c836..32c3f31c0c 100644
--- a/packages/nocodb/src/schema/swagger-v3-validation-patch.json
+++ b/packages/nocodb/src/schema/swagger-v3-validation-patch.json
@@ -14,6 +14,50 @@
"$ref": "#/components/schemas/FieldBase"
}
]
+ },
+ "ViewCreate": {
+ "type": "object",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ViewBase"
+ },
+ {
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": [
+ "GRID",
+ "GALLERY",
+ "KANBAN",
+ "CALENDAR",
+ "FORM"
+ ],
+ "description": "Type of the view."
+ }
+ },
+ "required": [
+ "type",
+ "name"
+ ]
+ }
+ ]
+ },
+ "ViewUpdate": {
+ "type": "object",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ViewBase"
+ },
+ {
+ "properties": {
+ "id": {
+ "type": "string",
+ "format": "uuid",
+ "description": "Unique identifier for the view."
+ }
+ }
+ }
+ ]
}
}
}
diff --git a/packages/nocodb/src/schema/swagger-v3.json b/packages/nocodb/src/schema/swagger-v3.json
index 455f3e1fe3..791ec81b40 100644
--- a/packages/nocodb/src/schema/swagger-v3.json
+++ b/packages/nocodb/src/schema/swagger-v3.json
@@ -5128,7 +5128,6 @@
"properties": {
"id": {
"type": "string",
- "format": "uuid",
"description": "Unique identifier for the sort.",
"readOnly": true
},
@@ -5222,29 +5221,13 @@
}
}
},
- "View": {
+ "ViewBase": {
"type": "object",
"properties": {
- "id": {
- "type": "string",
- "format": "uuid",
- "description": "Unique identifier for the view."
- },
- "view_name": {
+ "name": {
"type": "string",
"description": "Name of the view."
},
- "view_type": {
- "type": "string",
- "enum": [
- "GRID",
- "GALLERY",
- "KANBAN",
- "CALENDAR",
- "FORM"
- ],
- "description": "Type of the view."
- },
"lock_type": {
"type": "string",
"enum": [
@@ -5258,10 +5241,6 @@
"type": "string",
"description": "Description of the view."
},
- "is_default": {
- "type": "boolean",
- "description": "Indicates if this is the default view."
- },
"meta": {
"type": "object",
"properties": {
@@ -5276,326 +5255,341 @@
}
}
},
- "created_by": {
- "type": "string",
- "format": "uuid",
- "description": "User ID of the creator."
- },
- "owned_by": {
- "type": "string",
- "format": "uuid",
- "description": "User ID of the owner."
- },
- "created_at": {
- "type": "string",
- "format": "date-time",
- "description": "Timestamp of creation."
- },
- "updated_at": {
- "type": "string",
- "format": "date-time",
- "description": "Timestamp of last update."
- },
- "filters": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Filter"
- },
- "description": "Filters applied to the view."
- },
"sorts": {
"type": "array",
"items": {
- "$ref": "#/components/schemas/Sort"
+ "$ref": "#/components/schemas/SortCreate"
},
"description": "Sort options for the view."
}
- },
- "discriminator": {
- "propertyName": "view_type"
- },
+ }
+ },
+ "ViewBaseOptions": {
"oneOf": [
{
"type": "object",
"properties": {
- "fields": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "field_id": {
- "type": "string",
- "format": "uuid",
- "description": "Field ID for GRID view."
- },
- "is_hidden": {
- "type": "boolean",
- "description": "Indicates if the field is hidden in GRID view."
- }
- }
- }
+ "type": {
+ "type": "string",
+ "enum": [
+ "GRID"
+ ]
},
- "group": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "field_id": {
- "type": "string",
- "format": "uuid",
- "description": "Field ID for grouping in GRID view."
- },
- "sort": {
- "type": "string",
- "enum": [
- "asc",
- "desc"
- ],
- "description": "Sorting order for the group."
- }
- }
- }
+ "options": {
+ "$ref": "#/components/schemas/ViewOptionsGrid"
}
- },
- "required": [
- "view_type",
- "fields"
- ],
- "description": "GRID View"
+ }
},
{
"type": "object",
"properties": {
- "fields": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "field_id": {
- "type": "string",
- "format": "uuid",
- "description": "Field ID displayed in GALLERY view."
- },
- "cover_image": {
- "type": "boolean",
- "description": "Indicates if the field is the cover image."
- }
- }
- }
- },
- "cover_image_field_id": {
+ "type": {
"type": "string",
- "format": "uuid",
- "description": "Field ID for the cover image."
+ "enum": [
+ "KANBAN"
+ ]
+ },
+ "options": {
+ "$ref": "#/components/schemas/ViewOptionsKanban"
}
- },
- "required": [
- "view_type",
- "fields"
- ],
- "description": "GALLERY View"
+ }
},
{
"type": "object",
"properties": {
- "fields": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "field_id": {
- "type": "string",
- "format": "uuid",
- "description": "Field ID used in KANBAN view."
- },
- "is_stack_by": {
- "type": "boolean",
- "description": "Indicates if the field is used for stacking in KANBAN."
- }
- }
- }
- },
- "cover_image_field_id": {
+ "type": {
"type": "string",
- "format": "uuid",
- "description": "Field ID for the cover image."
+ "enum": [
+ "CALENDAR"
+ ]
},
- "kanban_stack_by_field_id": {
- "type": "string",
- "format": "uuid",
- "description": "Field ID used for stacking in KANBAN view."
+ "options": {
+ "$ref": "#/components/schemas/ViewOptionsCalendar"
}
- },
- "required": [
- "view_type",
- "fields"
- ],
- "description": "KANBAN View"
+ }
},
{
"type": "object",
"properties": {
- "fields": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "field_id": {
- "type": "string",
- "format": "uuid",
- "description": "Field ID displayed in CALENDAR view."
- },
- "is_date_field": {
- "type": "boolean",
- "description": "Indicates if the field is used for date ranges."
- }
- }
- }
+ "type": {
+ "type": "string",
+ "enum": [
+ "GALLERY"
+ ]
},
- "calendar_range": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "start_field_id": {
- "type": "string",
- "format": "uuid",
- "description": "Field ID for the start date."
- },
- "end_field_id": {
- "type": "string",
- "format": "uuid",
- "description": "Field ID for the end date."
- }
- }
- }
+ "options": {
+ "$ref": "#/components/schemas/ViewOptionsGallery"
}
- },
- "required": [
- "view_type",
- "fields"
- ],
- "description": "CALENDAR View"
+ }
},
{
"type": "object",
"properties": {
- "fields": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "field_id": {
- "type": "string",
- "format": "uuid",
- "description": "Field ID used in FORM view."
- },
- "is_required": {
- "type": "boolean",
- "description": "Indicates if the field is required in the form."
- }
- }
- }
- },
- "form_heading": {
+ "type": {
"type": "string",
- "description": "Heading for the form."
+ "enum": [
+ "FORM"
+ ]
},
- "form_sub_heading": {
+ "options": {
+ "$ref": "#/components/schemas/ViewOptionsForm"
+ }
+ }
+ }
+ ],
+ "discriminator": {
+ "propertyName": "type"
+ }
+ },
+ "ViewCreate": {
+ "type": "object",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ViewBase"
+ },
+ {
+ "properties": {
+ "type": {
"type": "string",
- "description": "Subheading for the form."
- },
- "form_success_message": {
+ "enum": [
+ "GRID",
+ "GALLERY",
+ "KANBAN",
+ "CALENDAR",
+ "FORM"
+ ],
+ "description": "Type of the view."
+ }
+ },
+ "required": [
+ "type",
+ "name"
+ ]
+ },
+ {
+ "$ref": "#/components/schemas/ViewBaseOptions"
+ }
+ ]
+ },
+ "ViewUpdate": {
+ "type": "object",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ViewBase"
+ },
+ {
+ "properties": {
+ "id": {
"type": "string",
- "description": "Success message shown after form submission."
- },
- "form_redirect_url": {
+ "format": "uuid",
+ "description": "Unique identifier for the view."
+ }
+ }
+ },
+ {
+ "$ref": "#/components/schemas/ViewBaseOptions"
+ }
+ ]
+ },
+ "View": {
+ "type": "object",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ViewBase"
+ },
+ {
+ "properties": {
+ "id": {
"type": "string",
- "format": "uri",
- "description": "URL to redirect to after form submission."
- },
- "form_redirect_after_secs": {
- "type": "integer",
- "description": "Seconds to wait before redirecting."
- },
- "form_send_response_email": {
- "type": "boolean",
- "description": "Whether to send a response email."
+ "format": "uuid",
+ "description": "Unique identifier for the view."
},
- "form_show_another": {
- "type": "boolean",
- "description": "Whether to show another form after submission."
+ "type": {
+ "type": "string",
+ "enum": [
+ "GRID",
+ "GALLERY",
+ "KANBAN",
+ "CALENDAR",
+ "FORM"
+ ],
+ "description": "Type of the view."
},
- "form_show_blank": {
+ "is_default": {
"type": "boolean",
- "description": "Whether to show a blank form after submission."
+ "description": "Indicates if this is the default view."
},
- "form_hide_banner": {
- "type": "boolean",
- "description": "Whether to hide the banner on the form."
+ "meta": {
+ "type": "object",
+ "properties": {
+ "locked_view_description": {
+ "type": "string",
+ "description": "Description for locked views."
+ },
+ "locked_by_user_id": {
+ "type": "string",
+ "format": "uuid",
+ "description": "User ID of the person who locked the view."
+ }
+ }
},
- "form_hide_branding": {
- "type": "boolean",
- "description": "Whether to hide branding on the form."
+ "created_by": {
+ "type": "string",
+ "format": "uuid",
+ "description": "User ID of the creator."
},
- "form_banner_image_url": {
+ "owned_by": {
"type": "string",
- "format": "uri",
- "description": "URL of the banner image for the form."
+ "format": "uuid",
+ "description": "User ID of the owner."
},
- "form_logo_url": {
+ "created_at": {
"type": "string",
- "format": "uri",
- "description": "URL of the logo for the form."
+ "format": "date-time",
+ "description": "Timestamp of creation."
},
- "form_background_color": {
+ "updated_at": {
"type": "string",
- "description": "Background color for the form.",
- "pattern": "^#[0-9A-Fa-f]{6}$"
+ "format": "date-time",
+ "description": "Timestamp of last update."
}
- },
- "required": [
- "view_type",
- "fields"
- ],
- "description": "FORM View"
+ }
+ },
+ {
+ "$ref": "#/components/schemas/ViewBaseOptions"
}
]
},
- "ViewCreate": {
+ "ViewOptionsGrid": {
+ "type": "object",
+ "properties": {
+ "groups": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "field": "string",
+ "direction": {
+ "type": "string",
+ "enum": [
+ "asc",
+ "desc"
+ ]
+ }
+ },
+ "required": [
+ "field"
+ ]
+ }
+ }
+ }
+ },
+ "ViewOptionsKanban": {
+ "type": "object",
+ "properties": {
+ "stackBy": {
+ "type": "object",
+ "properties": {
+ "fieldId": "string"
+ }
+ },
+ "coverFieldId": "string"
+ },
+ "required": [
+ "stackBy"
+ ]
+ },
+ "ViewOptionsCalendar": {
+ "type": "object",
+ "properties": {
+ "dateRanges": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "startDateFieldId": "string",
+ "endDateFieldId": "string"
+ },
+ "required": [
+ "startDateFieldId"
+ ]
+ }
+ }
+ },
+ "required": [
+ "dateRanges"
+ ]
+ },
+ "ViewOptionsGallery": {
+ "type": "object",
+ "properties": {
+ "coverFieldId": "string"
+ }
+ },
+ "ViewOptionsForm": {
"type": "object",
"properties": {
- "view_name": {
+ "formTitle": {
"type": "string",
- "description": "Name of the view."
+ "description": "Heading for the form."
},
- "view_type": {
+ "formDescription": {
"type": "string",
- "enum": [
- "GRID",
- "GALLERY",
- "KANBAN",
- "CALENDAR",
- "FORM"
- ],
- "description": "Type of the view."
+ "description": "Subheading for the form."
},
- "lock_type": {
+ "thankYouMessage": {
"type": "string",
- "enum": [
- "COLLABARATIVE",
- "LOCKED",
- "PERSONAL"
- ],
- "description": "Lock type of the view."
+ "description": "Success message shown after form submission."
},
- "description": {
+ "form_redirect_after_secs": {
+ "type": "integer",
+ "description": "Seconds to wait before redirecting."
+ },
+ "form_send_response_email": {
+ "type": "boolean",
+ "description": "Whether to send a response email."
+ },
+ "submitAnotherForm": {
+ "type": "boolean",
+ "description": "Whether to show another form after submission."
+ },
+ "showBlankForm": {
+ "type": "boolean",
+ "description": "Whether to show a blank form after submission."
+ },
+ "form_hide_banner": {
+ "type": "boolean",
+ "description": "Whether to hide the banner on the form."
+ },
+ "form_hide_branding": {
+ "type": "boolean",
+ "description": "Whether to hide branding on the form."
+ },
+ "form_banner_image_url": {
"type": "string",
- "description": "Description of the view."
+ "format": "uri",
+ "description": "URL of the banner image for the form."
+ },
+ "form_logo_url": {
+ "type": "string",
+ "format": "uri",
+ "description": "URL of the logo for the form."
+ },
+ "form_background_color": {
+ "type": "string",
+ "description": "Background color for the form.",
+ "pattern": "^#[0-9A-Fa-f]{6}$"
+ },
+ "redirectOnSubmit": {
+ "type": "object",
+ "properties": {
+ "url": {
+ "type": "string",
+ "format": "uri",
+ "description": "URL to redirect to after form submission."
+ }
+ }
}
- },
- "discriminator": {
- "propertyName": "view_type"
}
},
"FieldBase": {
@@ -7561,4 +7555,4 @@
}
}
}
-}
+}
\ No newline at end of file
diff --git a/packages/nocodb/src/services/v3/sorts-v3.service.ts b/packages/nocodb/src/services/v3/sorts-v3.service.ts
index 4321c10c45..df631b7349 100644
--- a/packages/nocodb/src/services/v3/sorts-v3.service.ts
+++ b/packages/nocodb/src/services/v3/sorts-v3.service.ts
@@ -1,5 +1,4 @@
import { Injectable } from '@nestjs/common';
-import { MetaTable } from 'src/cli';
import type {
SortCreateV3Type,
SortReqType,
diff --git a/packages/nocodb/src/services/v3/views-v3.service.ts b/packages/nocodb/src/services/v3/views-v3.service.ts
index e8c8e93620..bca0776a8f 100644
--- a/packages/nocodb/src/services/v3/views-v3.service.ts
+++ b/packages/nocodb/src/services/v3/views-v3.service.ts
@@ -558,12 +558,11 @@ export class ViewsV3Service {
const { req, viewId } = param;
const { body } = req;
- // TODO: enable validate payload
- // validatePayload(
- // 'swagger-v3.json#/components/schemas/ViewCreate',
- // body,
- // true,
- // );
+ validatePayload(
+ 'swagger-v3.json#/components/schemas/ViewUpdate',
+ body,
+ true,
+ );
const existingView = await View.get(context, viewId, ncMeta);
if (!existingView) {