From 9fc6f20c842c9a32e6fbc7dba255381f559fa7c7 Mon Sep 17 00:00:00 2001 From: JuanBerrocal Date: Sat, 14 Feb 2026 12:06:36 +0100 Subject: [PATCH 1/6] Array of objects json export reviwed --- .../export-button/export-button.business.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/pods/toolbar/components/export-button/export-button.business.ts b/src/pods/toolbar/components/export-button/export-button.business.ts index 765b62f7..951e2d8b 100644 --- a/src/pods/toolbar/components/export-button/export-button.business.ts +++ b/src/pods/toolbar/components/export-button/export-button.business.ts @@ -146,15 +146,21 @@ export const expandAllFieldsInTables = (table: TableVm[]) => // Export Schema functions export const getPropertyJsonSchema = (field: FieldVm): string => { if (field.isArray) { - return `"${field.name}": { bsonType: "array", items: { bsonType: "${field.type}" } }`; + return `"${field.name}": { bsonType: "array", items: ${getItemType(field)} }`; } + return `"${field.name}": ${getItemType(field)}`; +}; +export const getItemType = (field: FieldVm, useTab = true): string => { if (field.children && field.children.length > 0) { - const properties = getPropertiesJsonSchema(field.children, false); - return `"${field.name}": { bsonType: "object", title: "${field.name}", properties: { ${properties}, }, }`; - } - return `"${field.name}": { bsonType: "${field.type}" }`; -}; + const separator = useTab ? ',\n ' : ', '; + const tabSeparator = useTab ? '\n ' : ' '; + const properties = getPropertiesJsonSchema(field.children); + + return `{ ${tabSeparator} bsonType: "object" ${separator} title: "${field.name}" ${separator} required: [${getRequiredFields(field.children)}] ${separator} properties: {${properties}} } `; + } + return `{ bsonType: "${field.type}" }`; +} export const getPropertiesJsonSchema = ( fields: FieldVm[], From ede9ab531537c96c3b60d61ebe2128959ff8c624 Mon Sep 17 00:00:00 2001 From: JuanBerrocal Date: Sat, 14 Feb 2026 12:33:40 +0100 Subject: [PATCH 2/6] Array of objects json export reviwed again --- .../components/export-button/export-button.business.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pods/toolbar/components/export-button/export-button.business.ts b/src/pods/toolbar/components/export-button/export-button.business.ts index 951e2d8b..70898e94 100644 --- a/src/pods/toolbar/components/export-button/export-button.business.ts +++ b/src/pods/toolbar/components/export-button/export-button.business.ts @@ -151,13 +151,11 @@ export const getPropertyJsonSchema = (field: FieldVm): string => { return `"${field.name}": ${getItemType(field)}`; }; -export const getItemType = (field: FieldVm, useTab = true): string => { +export const getItemType = (field: FieldVm): string => { if (field.children && field.children.length > 0) { - const separator = useTab ? ',\n ' : ', '; - const tabSeparator = useTab ? '\n ' : ' '; const properties = getPropertiesJsonSchema(field.children); - return `{ ${tabSeparator} bsonType: "object" ${separator} title: "${field.name}" ${separator} required: [${getRequiredFields(field.children)}] ${separator} properties: {${properties}} } `; + return `{ bsonType: "object", title: "${field.name}", required: [${getRequiredFields(field.children)}], properties: {${properties}} } `; } return `{ bsonType: "${field.type}" }`; } From 8d1598f8a26e4b06b19b82f6e5975ad1ea4f2f65 Mon Sep 17 00:00:00 2001 From: JuanBerrocal Date: Sat, 14 Feb 2026 12:42:40 +0100 Subject: [PATCH 3/6] Chnges made to pass the should-generate-JSON-schema-for-a-subdocument-property test --- .../components/export-button/export-button.business.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pods/toolbar/components/export-button/export-button.business.ts b/src/pods/toolbar/components/export-button/export-button.business.ts index 70898e94..fdde3ccd 100644 --- a/src/pods/toolbar/components/export-button/export-button.business.ts +++ b/src/pods/toolbar/components/export-button/export-button.business.ts @@ -154,8 +154,11 @@ export const getPropertyJsonSchema = (field: FieldVm): string => { export const getItemType = (field: FieldVm): string => { if (field.children && field.children.length > 0) { const properties = getPropertiesJsonSchema(field.children); - - return `{ bsonType: "object", title: "${field.name}", required: [${getRequiredFields(field.children)}], properties: {${properties}} } `; + + return `{ bsonType: "object", title: "${field.name}", properties: {${properties}} } `; + + // Perhaps to be changed for this later. + //return `{ bsonType: "object", title: "${field.name}", required: [${getRequiredFields(field.children)}], properties: {${properties}} } `; } return `{ bsonType: "${field.type}" }`; } From d82a28e277b590a40e57e3676e82c69a7488be67 Mon Sep 17 00:00:00 2001 From: JuanBerrocal Date: Sat, 14 Feb 2026 12:45:50 +0100 Subject: [PATCH 4/6] Changes made to pass the should-generate-JSON-schema-for-a-subdocument-property test again --- .../toolbar/components/export-button/export-button.business.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pods/toolbar/components/export-button/export-button.business.ts b/src/pods/toolbar/components/export-button/export-button.business.ts index fdde3ccd..25a1ff50 100644 --- a/src/pods/toolbar/components/export-button/export-button.business.ts +++ b/src/pods/toolbar/components/export-button/export-button.business.ts @@ -153,7 +153,7 @@ export const getPropertyJsonSchema = (field: FieldVm): string => { export const getItemType = (field: FieldVm): string => { if (field.children && field.children.length > 0) { - const properties = getPropertiesJsonSchema(field.children); + const properties = getPropertiesJsonSchema(field.children, false); return `{ bsonType: "object", title: "${field.name}", properties: {${properties}} } `; From 83e9c9f1cca7bda4197dc56f09201d4e17082290 Mon Sep 17 00:00:00 2001 From: JuanBerrocal Date: Sat, 14 Feb 2026 18:28:41 +0100 Subject: [PATCH 5/6] Changed again to pass should-generate-JSON-schema-for-a-subdocument-property test --- .../toolbar/components/export-button/export-button.business.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pods/toolbar/components/export-button/export-button.business.ts b/src/pods/toolbar/components/export-button/export-button.business.ts index 25a1ff50..09594e87 100644 --- a/src/pods/toolbar/components/export-button/export-button.business.ts +++ b/src/pods/toolbar/components/export-button/export-button.business.ts @@ -155,7 +155,7 @@ export const getItemType = (field: FieldVm): string => { if (field.children && field.children.length > 0) { const properties = getPropertiesJsonSchema(field.children, false); - return `{ bsonType: "object", title: "${field.name}", properties: {${properties}} } `; + return `{ bsonType: "object", title: "${field.name}", properties: { ${properties}, }, } `; // Perhaps to be changed for this later. //return `{ bsonType: "object", title: "${field.name}", required: [${getRequiredFields(field.children)}], properties: {${properties}} } `; From 19e0b7d5dd1f13a8be5ee5451e7b16e09e9889fa Mon Sep 17 00:00:00 2001 From: JuanBerrocal Date: Sat, 14 Feb 2026 19:41:22 +0100 Subject: [PATCH 6/6] Changed one more time to pass should-generate-JSON-schema-for-a-subdocument-property test --- .../toolbar/components/export-button/export-button.business.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pods/toolbar/components/export-button/export-button.business.ts b/src/pods/toolbar/components/export-button/export-button.business.ts index 09594e87..dd409365 100644 --- a/src/pods/toolbar/components/export-button/export-button.business.ts +++ b/src/pods/toolbar/components/export-button/export-button.business.ts @@ -155,7 +155,7 @@ export const getItemType = (field: FieldVm): string => { if (field.children && field.children.length > 0) { const properties = getPropertiesJsonSchema(field.children, false); - return `{ bsonType: "object", title: "${field.name}", properties: { ${properties}, }, } `; + return `{ bsonType: "object", title: "${field.name}", properties: { ${properties}, }, }`; // Perhaps to be changed for this later. //return `{ bsonType: "object", title: "${field.name}", required: [${getRequiredFields(field.children)}], properties: {${properties}} } `;