Repository: orval-labs/orval (2025-08-22T16:30:45Z)

Issue:
Bug: Faker generates invalid code for nested arrays (Array.from)
The faker mock code was generating invalid code, here is a minimal schema that reproduces the issue

```yaml
openapi: 3.1.0
info:
  title: Test Schema
  version: 0.1.0
paths:
  /test:
    post:
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestSchema'
components:
  schemas:
    TestSchema:
      properties:
        coordinates:
          anyOf:
            - items:
                items:
                  type: integer
                type: array
              type: array
            - type: null
          title: Coordinates
          description: Array of coordinate pairs representing points on a grid.
      type: object
      title: TestSchema
```

<img width="622" height="200" alt="Image" src="https://github.com/user-attachments/assets/648dad9a-f853-48bd-b8f4-78b94a26c600" />


Discussion:
PR opened: https://github.com/orval-labs/orval/pull/2328
I opened a pr eagerly so i don't have to adjust our api contract as a workaround for now 🤞 



Patch:
diff --git a/packages/mock/src/faker/getters/scalar.ts b/packages/mock/src/faker/getters/scalar.ts
index bed9d9b53..1cb498993 100644
--- a/packages/mock/src/faker/getters/scalar.ts
+++ b/packages/mock/src/faker/getters/scalar.ts
@@ -220,7 +220,12 @@ export const getMockScalar = ({
 
       let mapValue = value;
 
-      if (combine && !value.startsWith('faker') && !value.startsWith('{')) {
+      if (
+        combine &&
+        !value.startsWith('faker') &&
+        !value.startsWith('{') &&
+        !value.startsWith('Array.from')
+      ) {
         mapValue = `{${value}}`;
       }
 


Test patch:
diff --git a/packages/mock/src/faker/getters/scalar.test.ts b/packages/mock/src/faker/getters/scalar.test.ts
index ff66f9970..3104e1ed1 100644
--- a/packages/mock/src/faker/getters/scalar.test.ts
+++ b/packages/mock/src/faker/getters/scalar.test.ts
@@ -148,3 +148,31 @@ describe('getMockScalar (example handling with falsy values)', () => {
     expect(result.value).toBe('faker.datatype.boolean()');
   });
 });
+
+describe('getMockScalar (nested arrays handling)', () => {
+  it('should generate valid syntax for nested arrays (array of arrays)', () => {
+    const result = getMockScalar({
+      item: {
+        type: 'array' as const,
+        name: 'coordinates',
+        items: {
+          type: 'array',
+          items: { type: 'integer' },
+        },
+      },
+      imports: [],
+      operationId: 'test',
+      tags: [],
+      existingReferencedProperties: [],
+      splitMockImplementations: [],
+      context: { output: { override: {} } } as ContextSpecs,
+      combine: { separator: 'anyOf' as const, includedProperties: [] },
+    });
+    console.dir(result.value, { depth: null });
+
+    // Should avoid putting Array.from in an object {
+    expect(result.value).toBe(
+      'Array.from({ length: faker.number.int({ min: undefined, max: undefined }) }, (_, i) => i + 1).map(() => (Array.from({ length: faker.number.int({ min: undefined, max: undefined }) }, (_, i) => i + 1).map(() => (faker.number.int({min: undefined, max: undefined})))))',
+    );
+  });
+});