From ed0a3a2511fbe9efa3b1869fe67a103acc6ab4d6 Mon Sep 17 00:00:00 2001 From: martmull Date: Thu, 14 Nov 2024 12:07:31 +0100 Subject: [PATCH] Fix open api specs for MULTI_SELECT (#8494) ## Before ![image](https://github.com/user-attachments/assets/b7384fb3-0f32-498b-99bb-27b8c15db00c) ## After ![image](https://github.com/user-attachments/assets/a8429849-559d-4494-8636-e5a6ddda7b47) --- .../utils/__tests__/components.utils.spec.ts | 12 ++++++------ .../core-modules/open-api/utils/components.utils.ts | 12 +++++++++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/twenty-server/src/engine/core-modules/open-api/utils/__tests__/components.utils.spec.ts b/packages/twenty-server/src/engine/core-modules/open-api/utils/__tests__/components.utils.spec.ts index bde4e50992fa..c14dee14f43f 100644 --- a/packages/twenty-server/src/engine/core-modules/open-api/utils/__tests__/components.utils.spec.ts +++ b/packages/twenty-server/src/engine/core-modules/open-api/utils/__tests__/components.utils.spec.ts @@ -125,8 +125,8 @@ describe('computeSchemaComponents', () => { enum: ['OPTION_1', 'OPTION_2'], }, fieldMultiSelect: { - type: 'string', - enum: ['OPTION_1', 'OPTION_2'], + type: 'array', + items: { type: 'string', enum: ['OPTION_1', 'OPTION_2'] }, }, fieldPosition: { type: 'number', @@ -302,8 +302,8 @@ describe('computeSchemaComponents', () => { enum: ['OPTION_1', 'OPTION_2'], }, fieldMultiSelect: { - type: 'string', - enum: ['OPTION_1', 'OPTION_2'], + type: 'array', + items: { type: 'string', enum: ['OPTION_1', 'OPTION_2'] }, }, fieldPosition: { type: 'number', @@ -478,8 +478,8 @@ describe('computeSchemaComponents', () => { enum: ['OPTION_1', 'OPTION_2'], }, fieldMultiSelect: { - type: 'string', - enum: ['OPTION_1', 'OPTION_2'], + type: 'array', + items: { type: 'string', enum: ['OPTION_1', 'OPTION_2'] }, }, fieldPosition: { type: 'number', diff --git a/packages/twenty-server/src/engine/core-modules/open-api/utils/components.utils.ts b/packages/twenty-server/src/engine/core-modules/open-api/utils/components.utils.ts index 07ad4770c782..3abd55ca4c7c 100644 --- a/packages/twenty-server/src/engine/core-modules/open-api/utils/components.utils.ts +++ b/packages/twenty-server/src/engine/core-modules/open-api/utils/components.utils.ts @@ -115,8 +115,18 @@ const getSchemaComponentsProperties = ({ let itemProperty = {} as Property; switch (field.type) { - case FieldMetadataType.SELECT: case FieldMetadataType.MULTI_SELECT: + itemProperty = { + type: 'array', + items: { + type: 'string', + enum: field.options.map( + (option: { value: string }) => option.value, + ), + }, + }; + break; + case FieldMetadataType.SELECT: itemProperty = { type: 'string', enum: field.options.map((option: { value: string }) => option.value),