From ba8c50bb0f95e74a8b34378b20a4b2473b3832f9 Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Thu, 12 Sep 2024 15:01:22 +0800 Subject: [PATCH] allow unknow query paramters for ui settings route (#8152) Signed-off-by: Hailong Cui --- src/core/server/ui_settings/routes/delete.ts | 13 ++++++++----- src/core/server/ui_settings/routes/get.ts | 13 ++++++++----- src/core/server/ui_settings/routes/set.ts | 13 ++++++++----- src/core/server/ui_settings/routes/set_many.ts | 13 ++++++++----- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/core/server/ui_settings/routes/delete.ts b/src/core/server/ui_settings/routes/delete.ts index eb3d167edfd5..52888fa6f398 100644 --- a/src/core/server/ui_settings/routes/delete.ts +++ b/src/core/server/ui_settings/routes/delete.ts @@ -39,11 +39,14 @@ const validate = { params: schema.object({ key: schema.string(), }), - query: schema.object({ - scope: schema.maybe( - schema.oneOf([schema.literal(UiSettingScope.GLOBAL), schema.literal(UiSettingScope.USER)]) - ), - }), + query: schema.object( + { + scope: schema.maybe( + schema.oneOf([schema.literal(UiSettingScope.GLOBAL), schema.literal(UiSettingScope.USER)]) + ), + }, + { unknowns: 'allow' } + ), }; export function registerDeleteRoute(router: IRouter) { diff --git a/src/core/server/ui_settings/routes/get.ts b/src/core/server/ui_settings/routes/get.ts index 5d4571f93a1a..21c995d11b91 100644 --- a/src/core/server/ui_settings/routes/get.ts +++ b/src/core/server/ui_settings/routes/get.ts @@ -35,11 +35,14 @@ import { SavedObjectsErrorHelpers } from '../../saved_objects'; import { UiSettingScope } from '../types'; const validate = { - query: schema.object({ - scope: schema.maybe( - schema.oneOf([schema.literal(UiSettingScope.GLOBAL), schema.literal(UiSettingScope.USER)]) - ), - }), + query: schema.object( + { + scope: schema.maybe( + schema.oneOf([schema.literal(UiSettingScope.GLOBAL), schema.literal(UiSettingScope.USER)]) + ), + }, + { unknowns: 'allow' } + ), }; export function registerGetRoute(router: IRouter) { diff --git a/src/core/server/ui_settings/routes/set.ts b/src/core/server/ui_settings/routes/set.ts index abf49f4218e3..4da4d244e329 100644 --- a/src/core/server/ui_settings/routes/set.ts +++ b/src/core/server/ui_settings/routes/set.ts @@ -42,11 +42,14 @@ const validate = { body: schema.object({ value: schema.any(), }), - query: schema.object({ - scope: schema.maybe( - schema.oneOf([schema.literal(UiSettingScope.GLOBAL), schema.literal(UiSettingScope.USER)]) - ), - }), + query: schema.object( + { + scope: schema.maybe( + schema.oneOf([schema.literal(UiSettingScope.GLOBAL), schema.literal(UiSettingScope.USER)]) + ), + }, + { unknowns: 'allow' } + ), }; export function registerSetRoute(router: IRouter) { diff --git a/src/core/server/ui_settings/routes/set_many.ts b/src/core/server/ui_settings/routes/set_many.ts index b83d2bbef20e..661d88bec4f5 100644 --- a/src/core/server/ui_settings/routes/set_many.ts +++ b/src/core/server/ui_settings/routes/set_many.ts @@ -39,11 +39,14 @@ const validate = { body: schema.object({ changes: schema.object({}, { unknowns: 'allow' }), }), - query: schema.object({ - scope: schema.maybe( - schema.oneOf([schema.literal(UiSettingScope.GLOBAL), schema.literal(UiSettingScope.USER)]) - ), - }), + query: schema.object( + { + scope: schema.maybe( + schema.oneOf([schema.literal(UiSettingScope.GLOBAL), schema.literal(UiSettingScope.USER)]) + ), + }, + { unknowns: 'allow' } + ), }; export function registerSetManyRoute(router: IRouter) {