Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/gentle-bobcats-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +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.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions plugins/json-schema/src/setup.factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!',
Expand Down
19 changes: 5 additions & 14 deletions plugins/json-schema/src/setup.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => ({
Expand All @@ -169,14 +158,16 @@ export async function getPropertyType(
},
}

if (!fieldTypes[property.type]) return []

const fieldConfig: Flatfile.Property = {
label: parentKey,
...(property?.description && { description: property.description }),
...(isRequired && { constraints: [{ type: 'required' }] }),
...fieldTypes[property.type],
}

return fieldTypes[fieldConfig.type] ? [fieldConfig] : []
return [fieldConfig]
}

export async function resolveReference(
Expand Down
14 changes: 2 additions & 12 deletions plugins/openapi-schema/src/setup.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions plugins/yaml-schema/src/setup.factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down