From 6bbdcb4bcfe6673e6bc7bb8d65e22ff33898cea3 Mon Sep 17 00:00:00 2001 From: Carl Brugger Date: Fri, 1 Nov 2024 09:16:16 -0500 Subject: [PATCH 1/3] JSON array -> Flatfile string-list --- .changeset/gentle-bobcats-laugh.md | 5 +++++ package-lock.json | 8 ++++---- plugins/json-schema/src/setup.factory.ts | 19 +++++-------------- 3 files changed, 14 insertions(+), 18 deletions(-) create mode 100644 .changeset/gentle-bobcats-laugh.md diff --git a/.changeset/gentle-bobcats-laugh.md b/.changeset/gentle-bobcats-laugh.md new file mode 100644 index 000000000..59e35b089 --- /dev/null +++ b/.changeset/gentle-bobcats-laugh.md @@ -0,0 +1,5 @@ +--- +'@flatfile/plugin-convert-json-schema': minor +--- + +This release provides better support for the JSON schema array field type by mapping it to a Flatfile string-list. diff --git a/package-lock.json b/package-lock.json index e71cbc887..b2bec777a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -247,7 +247,7 @@ }, "extract/html-table": { "name": "@flatfile/plugin-extract-html-table", - "version": "1.2.0", + "version": "1.2.1", "license": "ISC", "dependencies": { "@flatfile/util-extractor": "^2.2.1", @@ -262,7 +262,7 @@ }, "extract/markdown": { "name": "@flatfile/plugin-extract-markdown", - "version": "0.2.0", + "version": "0.2.1", "license": "ISC", "dependencies": { "@flatfile/util-extractor": "^2.2.1" @@ -17306,7 +17306,7 @@ }, "plugins/json-extractor": { "name": "@flatfile/plugin-json-extractor", - "version": "0.9.0", + "version": "0.9.1", "license": "ISC", "dependencies": { "@flatfile/util-extractor": "^2.2.1" @@ -17621,7 +17621,7 @@ }, "plugins/xml-extractor": { "name": "@flatfile/plugin-xml-extractor", - "version": "0.8.0", + "version": "0.8.1", "license": "ISC", "dependencies": { "@flatfile/util-extractor": "^2.2.1", diff --git a/plugins/json-schema/src/setup.factory.ts b/plugins/json-schema/src/setup.factory.ts index 2a045f934..b98a2356b 100644 --- a/plugins/json-schema/src/setup.factory.ts +++ b/plugins/json-schema/src/setup.factory.ts @@ -140,22 +140,11 @@ export async function getPropertyType( boolean: { key: parentKey, type: 'boolean' }, array: { key: parentKey, - type: 'enum', - description: 'An enum of Selected Values', - config: property.enum - ? { - options: property.enum.map((value: any) => ({ - value, - label: String(value), - })), - } - : { - options: [], - }, + type: 'string-list', }, enum: { key: parentKey, - type: 'enum', + type: 'enum-list', config: property?.enum ? { options: property.enum.map((value: any) => ({ @@ -169,6 +158,8 @@ export async function getPropertyType( }, } + if (!fieldTypes[property.type]) return [] + const fieldConfig: Flatfile.Property = { label: parentKey, ...(property?.description && { description: property.description }), @@ -176,7 +167,7 @@ export async function getPropertyType( ...fieldTypes[property.type], } - return fieldTypes[fieldConfig.type] ? [fieldConfig] : [] + return [fieldConfig] } export async function resolveReference( From 20d524adc2ce860c147c4e0e59f76157c579bdc7 Mon Sep 17 00:00:00 2001 From: Carl Brugger Date: Fri, 1 Nov 2024 14:07:23 -0500 Subject: [PATCH 2/3] update tests --- plugins/json-schema/src/setup.factory.spec.ts | 5 ++--- plugins/openapi-schema/src/setup.factory.ts | 14 ++------------ plugins/yaml-schema/src/setup.factory.spec.ts | 5 ++--- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/plugins/json-schema/src/setup.factory.spec.ts b/plugins/json-schema/src/setup.factory.spec.ts index 80421bc5f..b5e86588e 100644 --- a/plugins/json-schema/src/setup.factory.spec.ts +++ b/plugins/json-schema/src/setup.factory.spec.ts @@ -63,11 +63,10 @@ describe('generateSetup()', () => { type: 'number', }, { - config: { options: [] }, - description: 'An enum of Selected Values', + description: 'A column for string arrays!', key: 'arrayColumn', label: 'arrayColumn', - type: 'enum', + type: 'string-list', }, { description: 'A column for unique numbers!', diff --git a/plugins/openapi-schema/src/setup.factory.ts b/plugins/openapi-schema/src/setup.factory.ts index 4e8bd1a3a..81eaee2e7 100644 --- a/plugins/openapi-schema/src/setup.factory.ts +++ b/plugins/openapi-schema/src/setup.factory.ts @@ -192,18 +192,8 @@ export async function getPropertyType( boolean: { key: parentKey, type: 'boolean' }, array: { key: parentKey, - type: 'enum', - description: 'An enum of Selected Values', - config: property.enum - ? { - options: property.enum.map((value: any) => ({ - value, - label: String(value), - })), - } - : { - options: [], - }, + type: 'string-list', + description: 'A column for string arrays!', }, enum: { key: parentKey, diff --git a/plugins/yaml-schema/src/setup.factory.spec.ts b/plugins/yaml-schema/src/setup.factory.spec.ts index f0d836962..4512487d3 100644 --- a/plugins/yaml-schema/src/setup.factory.spec.ts +++ b/plugins/yaml-schema/src/setup.factory.spec.ts @@ -31,10 +31,9 @@ describe('configureSpaceWithYamlSchema() e2e', () => { }, { label: 'arrayColumn', - description: 'An enum of Selected Values', + description: 'A column for string arrays!', key: 'arrayColumn', - type: 'enum', - config: { options: [] }, + type: 'string-list', }, { label: 'objectColumn_nestedUniqueNumberColumn', From 97f542b2cbf80bd4bc2a5df9f6b8ce5854020ab0 Mon Sep 17 00:00:00 2001 From: Carl Brugger Date: Mon, 4 Nov 2024 09:02:51 -0600 Subject: [PATCH 3/3] Update gentle-bobcats-laugh.md --- .changeset/gentle-bobcats-laugh.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/gentle-bobcats-laugh.md b/.changeset/gentle-bobcats-laugh.md index 59e35b089..948d1463b 100644 --- a/.changeset/gentle-bobcats-laugh.md +++ b/.changeset/gentle-bobcats-laugh.md @@ -1,5 +1,6 @@ --- '@flatfile/plugin-convert-json-schema': minor +'@flatfile/plugin-convert-openapi-schema': minor --- This release provides better support for the JSON schema array field type by mapping it to a Flatfile string-list.