Skip to content

The open alternative to Salesforce, designed for AI.

Fix open api specs for MULTI_SELECT (#8494)

martmull090f612c4b2a
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 bde4e50992f..c14dee14f43 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 07ad4770c78..3abd55ca4c7 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),