Skip to content

Bug: Schema export does not include nested properties for array-object items #562

Description

@Jakob-42

Description:

When exporting a schema that contains an array of objects with nested properties, only items: { bsonType: "object" } is exported. All nested property definitions inside the array items are missing from the export.

Steps to Reproduce:

  1. Load the "theaters" example schema (or any schema with arrays containing objects with nested properties)
  2. Verify the schema includes an array field with object items that have defined nested properties
  3. Export the schema
  4. Compare the exported code to the expected output

Current Output:

"location": { bsonType: "array", items: { bsonType: "object" } }

Expected Output:

"location": { 
  bsonType: "array", 
  items: { 
    bsonType: "object",
    properties: {
      "address": { 
        bsonType: "object",
        properties: {
          "street1": { bsonType: "string" },
          "city": { bsonType: "string" }
        }
      }
    }
  }
}

Note:

Export works correctly for non-array objects. Nested properties are included when the field is a direct object type.

Activity

  1. brauliodiez commented on Nov 16, 2025

    @brauliodiez
    Member

    I manage to reproduce it using the default mongo modeler example (movies), exactly just updating in the theather collection, the file location to an array, then I got this:

    db.createCollection("theaters", {
      validator: {
        $jsonSchema: {
          bsonType: "object",
          title: "theaters",
          required: ["_id"],
          properties: {
            "_id": { bsonType: "objectId" },
            "teatherId": { bsonType: "int" },
            "location": { bsonType: "array", items: { bsonType: "object" } },
          },
        },
      },
    });

    Could you confirm that the expected response should be something like?

    db.createCollection("theaters", {
      validator: {
        $jsonSchema: {
          bsonType: "object",
          title: "theaters",
          required: ["_id"],
          properties: {
            "_id": { bsonType: "objectId" },
            "teatherId": { bsonType: "int" },
            "location": { 
              bsonType: "array",
              items: { 
                bsonType: "object",
                required: ["address"],
                properties: {
                  address: {
                    bsonType: "object",
                    required: ["street1", "city"],
                    properties: {
                      street1: { bsonType: "string" },
                      city: { bsonType: "string" }
                    }
                  }
                }
              }
            }
          }
        }
      }
    })

    Thanks

  2. Jakob-42 commented on Nov 16, 2025

    @Jakob-42
    Author

    Yes, exactly like that.

    Appreciate you looking into this!

  3. JuanBerrocal commented on Feb 13, 2026

    @JuanBerrocal
    Collaborator

    Working on this issue.

  4. JuanBerrocal commented on Feb 14, 2026

    @JuanBerrocal
    Collaborator

    I looked into this issue. The problem was that the array of objects are never processed.
    In the file: src\pods\toolbar\components\export-button\export-button.business.ts
    This function: getPropertyJsonSchema suposses that every array is made up of base type items.
    When an array is found, always made this:
    return "${field.name}": { bsonType: "array", items: ${field.type} };
    So if an object is the item of an array, always returns:
    return "${field.name}": { bsonType: "array", items: "object" };
    But doesnt return any property from the object.
    To resolve this I've used a new function, getItemType.
    This function process every item from the array and make a recursive call on getPropertiesJsonSchema if necessary.
    So nested objects are also treated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions