Skip to content

fix(mock): handle nullable object schemas and per-import strict kinds#3617

Merged
melloware merged 6 commits into
orval-labs:masterfrom
Hypenate:fix/strict-mock-nullable-object-and-schema-kinds
Jun 18, 2026
Merged

fix(mock): handle nullable object schemas and per-import strict kinds#3617
melloware merged 6 commits into
orval-labs:masterfrom
Hypenate:fix/strict-mock-nullable-object-and-schema-kinds

Conversation

@Hypenate

@Hypenate Hypenate commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix strict faker mocks for schemas that are nullable objects (type: object + nullable: true, or type: ['object', 'null']): when nonNullable is enabled, factories no longer emit top-level null branches that conflict with {Schema}Mock return types.
  • Classify strict mock schema kinds per import by resolving $ref targets and matching oneOf/anyOf branches, instead of applying the response wrapper schema to every imported type.
  • Resolve $ref targets in classifyStrictMockSchemaType so enum refs emit alias mocks instead of object mapped types.

Test plan

  • packages/mock/src/mock-types.test.ts
  • packages/mock/src/faker/getters/object.test.ts
  • packages/mock/src/faker/index.test.ts
  • bun run lint

EOF

Summary by CodeRabbit

  • New Features

    • Enhanced strict mock type generation to detect nullable-at-root object schemas and emit nullable type declarations, including context-aware handling for referenced and composed schemas.
  • Bug Fixes

    • Improved OpenAPI 3.1 nullable object mocking: root null wrapping is applied consistently (including additional properties and empty object cases), nonNullable overrides are respected, and nullWrapped behavior is propagated correctly.
  • Tests

    • Added and expanded Vitest coverage for nullable-at-root behavior, context-aware $ref resolution, and oneOf response classification, plus strict-mock expectations for type: ['object', 'null'].

Strip schema-level null from nullable object mocks when nonNullable is set.

Resolve refs and oneOf branches when classifying strict mock schema kinds.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • tests/__snapshots__/default/null-type-v3-0/endpoints.ts is excluded by !**/__snapshots__/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4b2ab362-495c-45aa-a74f-cd0008819f77

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds nullable-at-root detection (isSchemaNullableAtRoot) and ContextSpec-aware $ref resolution to strict mock type classification. getMockObject gains nullability handling via a wrapRootNullableObjectValue helper that applies faker.helpers.arrayElement([value, null]) wrapping to object schemas, while filtering null from type arrays when nonNullable is set. All strict mock schema kind inference functions receive an optional context parameter, threaded from generateDefinition.

Changes

Nullable Object Schema Support

Layer / File(s) Summary
Nullable detection and $ref-aware schema classification
packages/mock/src/mock-types.ts, packages/mock/src/mock-types.test.ts
Introduces isSchemaNullableAtRoot() to detect root-level nullable schemas (schema.nullable === true or schema.type containing null). Extends classifyStrictMockSchemaType() with optional context parameter; when a schema is a $ref and context is provided, resolves the reference via resolveRef and classifies the resolved schema, otherwise defaults to 'object'.
Strict mock type declarations with nullable union and resolver
packages/mock/src/mock-types.ts, packages/mock/src/mock-types.test.ts
Updates getStrictMockTypeDeclaration() to conditionally union the generated object type with null when schemaNullableAtRoot is set. Extends getStrictMockTypeDeclarations() with nullableAtRoot mapping and an internal resolver helper to match schemas to type names via composed-schema branches and $ref references. Updates getStrictMockSchemaKindsFromResponses() to resolve imported schemas and array items through context-aware classification.
Faker mock generation with nullable wrapping and type filtering
packages/mock/src/faker/getters/object.ts, packages/mock/src/faker/getters/object.test.ts, packages/mock/src/faker/index.test.ts
Adds wrapRootNullableObjectValue helper to conditionally wrap object-literal strings with faker.helpers.arrayElement([value, null]) for nullable schemas when nonNullable is not set. Filters null from type arrays when nonNullable is requested, handles single-non-null-type recursion, uses filtered nonNullTypes for anyOf composition, and applies wrapping consistently across properties and additionalProperties paths.
Context threading into the mock generation pipeline
packages/mock/src/msw/index.ts
generateDefinition now passes context into getStrictMockSchemaKindsFromResponses so that strict mock schema kind derivation can resolve $refs and composed schemas.

Sequence Diagram(s)

sequenceDiagram
  participant ClassifySchema as classifyStrictMockSchemaType
  participant RefResolver as resolveRef
  participant GetDecl as getStrictMockTypeDeclaration
  participant MakeMock as getMockObject

  Note over ClassifySchema,MakeMock: Strict Mock Type Flow with Context

  rect rgba(100, 200, 200, 0.5)
    ClassifySchema->>RefResolver: resolve $ref if context provided
    RefResolver-->>ClassifySchema: resolved schema
    ClassifySchema->>ClassifySchema: recursively classify resolved schema
    ClassifySchema-->>GetDecl: schema kind
  end

  rect rgba(150, 150, 200, 0.5)
    GetDecl->>GetDecl: check schemaNullableAtRoot
    GetDecl-->>GetDecl: emit type with optional | null union
  end

  rect rgba(200, 150, 150, 0.5)
    MakeMock->>MakeMock: filter null types if nonNullable
    MakeMock->>MakeMock: generate properties/additionalProperties
    MakeMock->>MakeMock: wrap with faker.helpers.arrayElement if nullable
    MakeMock-->>MakeMock: return {value, nullWrapped}
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • orval-labs/orval#3230: Modifies the same getMockObject logic in object.ts for OpenAPI 3.1 nullable type: ['object','null'] handling, working in adjacent code paths.
  • orval-labs/orval#3476: Introduces override.mock.nonNullable behavior and the getNullable/isNullableSchema helpers that this PR now integrates into getMockObject for consistent nullable schema wrapping.

Suggested labels

mock

Suggested reviewers

  • melloware
  • wadakatu

🐰 A rabbit resolved every ref with care,
"Is this schema null? Let's declare!"
With context now flowing and types all aligned,
Nullable objects leave none behind—
Each faker mock wraps with a flair! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: handling nullable object schemas and implementing per-import strict mock type classification, which are the primary objectives of this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/mock/src/faker/getters/object.ts (2)

174-289: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Wrap only complete object expressions and preserve nullWrapped.

For allOf, this branch returns a property fragment without braces, so getNullable(value, ...) can wrap foo: bar as if it were a full expression. Also mark the result as nullWrapped when this branch adds the null choice, so parent property assembly does not add another null wrapper.

🐛 Proposed fix
+    const returnsObjectExpression =
+      !combine || combine.separator === 'oneOf' || combine.separator === 'anyOf';
     let value =
-      !combine || combine.separator === 'oneOf' || combine.separator === 'anyOf'
-        ? '{'
-        : '';
+      returnsObjectExpression ? '{' : '';
@@
     value += propertyScalars.join(', ');
-    value +=
-      !combine || combine.separator === 'oneOf' || combine.separator === 'anyOf'
-        ? '}'
-        : '';
+    value += returnsObjectExpression ? '}' : '';
+
+    const nullWrapped =
+      returnsObjectExpression &&
+      isNullableSchema(schemaItem) &&
+      !mockOptions?.nonNullable;
 
     return {
-      value: getNullable(
-        value,
-        isNullableSchema(schemaItem),
-        mockOptions?.nonNullable,
-      ),
+      value: getNullable(value, nullWrapped),
       imports,
       name: schemaItem.name,
       includedProperties,
+      nullWrapped,
     };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/mock/src/faker/getters/object.ts` around lines 174 - 289, The return
statement at the end of this object building block incorrectly calls getNullable
on value in all cases, but this should only happen when value is a complete
object expression with braces. Move the getNullable call inside a conditional
block that only executes when !combine or combine.separator is oneOf or anyOf
(the cases where braces are added). Additionally, the function needs to return
nullWrapped set to true when getNullable is applied to indicate that null
wrapping has already been handled at this level, preventing parent property
assembly from adding another null wrapper. For the allOf case where combine
exists without these specific separators, return the value directly without
getNullable and set nullWrapped to false.

296-337: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Apply root nullability to dictionary and empty-object returns.

nullable: true object schemas without properties reach the additionalProperties or fallback branches, so they still always emit an object when nonNullable is false. Reuse the same root nullable wrapper for these complete object values.

🐛 Proposed fix
   if (itemAdditionalProperties) {
+    const nullWrapped =
+      isNullableSchema(schemaItem) && !mockOptions?.nonNullable;
+
     if (itemAdditionalProperties === true) {
-      return { value: `{}`, imports: [], name: schemaItem.name };
+      return {
+        value: getNullable(`{}`, nullWrapped),
+        imports: [],
+        name: schemaItem.name,
+        nullWrapped,
+      };
     }
@@
-    return {
+    const value = `{
+        [${DEFAULT_OBJECT_KEY_MOCK}]: ${resolvedValue.value}
+      }`;
+
+    return {
       ...resolvedValue,
-      value: `{
-        [${DEFAULT_OBJECT_KEY_MOCK}]: ${resolvedValue.value}
-      }`,
+      value: getNullable(value, nullWrapped),
+      nullWrapped,
     };
   }
 
-  return { value: '{}', imports: [], name: schemaItem.name };
+  const nullWrapped = isNullableSchema(schemaItem) && !mockOptions?.nonNullable;
+  return {
+    value: getNullable('{}', nullWrapped),
+    imports: [],
+    name: schemaItem.name,
+    nullWrapped,
+  };
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/mock/src/faker/getters/object.ts` around lines 296 - 337, The
complete object values returned in the `itemAdditionalProperties` handling block
(both when it is true and when it contains resolved properties) and in the
fallback return statement do not apply root nullability wrapping. When a schema
is nullable and nonNullable is false, these complete object values should be
wrapped with the same root nullable wrapper used elsewhere in the code. Apply
the nullable wrapper to the final computed `value` in all three return
statements: the early return when itemAdditionalProperties is true, the return
after resolving additionalProperties, and the fallback empty object return.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/mock/src/mock-types.ts`:
- Around line 160-210: The function `resolveStrictMockSchemaForTypeName`
compares the received typeName (which may be an alias) against the resolved
import name, but resolveRef returns imports with only bare names and no alias
field. When the outer import uses an alias, the comparison at lines 187 and 201
fails because branchName and refName only contain the bare import name. Update
both comparison points to check if typeName matches either the resolved import's
bare name OR the resolved import's alias (if available), ensuring the function
correctly matches aliased type names by checking both forms of the reference
name.
- Around line 133-138: In the mappedType constant construction, the issue is
that Required<${typeName}> will drop all object keys when typeName is a union
type like Type | null. Fix this by wrapping typeName with NonNullable before
applying Required, changing the mapped type definition from `{\n  [K in keyof
Required<${typeName}>]: NonNullable<Required<${typeName}>[K]>;\n}` to use
NonNullable<${typeName}> inside the Required call, so that the Required utility
extracts keys from the actual object structure rather than from the union that
includes null. Additionally, update the test expectation at mock-types.test.ts
line 166 to reflect the corrected output format.

---

Outside diff comments:
In `@packages/mock/src/faker/getters/object.ts`:
- Around line 174-289: The return statement at the end of this object building
block incorrectly calls getNullable on value in all cases, but this should only
happen when value is a complete object expression with braces. Move the
getNullable call inside a conditional block that only executes when !combine or
combine.separator is oneOf or anyOf (the cases where braces are added).
Additionally, the function needs to return nullWrapped set to true when
getNullable is applied to indicate that null wrapping has already been handled
at this level, preventing parent property assembly from adding another null
wrapper. For the allOf case where combine exists without these specific
separators, return the value directly without getNullable and set nullWrapped to
false.
- Around line 296-337: The complete object values returned in the
`itemAdditionalProperties` handling block (both when it is true and when it
contains resolved properties) and in the fallback return statement do not apply
root nullability wrapping. When a schema is nullable and nonNullable is false,
these complete object values should be wrapped with the same root nullable
wrapper used elsewhere in the code. Apply the nullable wrapper to the final
computed `value` in all three return statements: the early return when
itemAdditionalProperties is true, the return after resolving
additionalProperties, and the fallback empty object return.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: feb7d7ea-58aa-4280-8a5e-4ab4c1190a3b

📥 Commits

Reviewing files that changed from the base of the PR and between 66af3e2 and 3db8137.

📒 Files selected for processing (6)
  • packages/mock/src/faker/getters/object.test.ts
  • packages/mock/src/faker/getters/object.ts
  • packages/mock/src/faker/index.test.ts
  • packages/mock/src/mock-types.test.ts
  • packages/mock/src/mock-types.ts
  • packages/mock/src/msw/index.ts

Comment thread packages/mock/src/mock-types.ts Outdated
Comment thread packages/mock/src/mock-types.ts
Hypenate and others added 3 commits June 17, 2026 14:29
Skip root-level null randomization when building object fragments for
combineSchemasMock so oneOf merges stay valid TypeScript. Update the
circular mock snapshot for nullable required child refs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Match aliased oneOf imports against resolved bare schema names, use
NonNullable inside strict mapped types, and set nullWrapped on root
nullable object mocks including additionalProperties fallbacks.

Co-authored-by: Cursor <cursoragent@cursor.com>
These snapshots were generated locally with v8.16.0 and have no matching
test config; they fail the snapshot version check against master v8.17.0.

Co-authored-by: Cursor <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/mock/src/faker/getters/object.ts (1)

134-186: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Keep the {} branch for propertyless ['object', 'null'] schemas.

This branch handles OpenAPI 3.1 nullable objects before the fallback wrapper at Lines 389-396. The current test suite still locks the no-property type: ['object', 'null'] case to faker.helpers.arrayElement([null,]), while the new nullable: true equivalent returns faker.helpers.arrayElement([{}, null]). That leaves the two nullable-object syntaxes generating different top-level mocks and drops the valid non-null {} branch for the OpenAPI 3.1 form.

🐛 Possible localized fix for the no-property object/null union
   if (Array.isArray(itemType)) {
     const nonNullTypes = mockOptions?.nonNullable
       ? itemType.filter((type) => type !== 'null')
       : itemType;
 
+    if (
+      !mockOptions?.nonNullable &&
+      itemType.length === 2 &&
+      itemType.includes('object') &&
+      itemType.includes('null') &&
+      !itemProperties &&
+      !itemAdditionalProperties
+    ) {
+      const { value: finalValue, nullWrapped } = wrapRootNullableObjectValue(
+        '{}',
+        { ...schemaItem, type: 'object', nullable: true } as MockSchemaObject &
+          Record<string, unknown>,
+        mockOptions,
+        combine,
+      );
+
+      return {
+        value: finalValue,
+        nullWrapped,
+        imports: [],
+        name: schemaItem.name,
+      };
+    }
+
     if (nonNullTypes.length === 0) {
       return { value: 'null', imports: [], name: schemaItem.name };
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/mock/src/faker/getters/object.ts` around lines 134 - 186, The
combineSchemasMock call for union types like ['object', 'null'] with no
properties is not preserving the empty object branch. When nonNullTypes contains
'object' but the schemaItem has no properties or required fields, ensure that
the mapped anyOf array includes a valid empty object entry instead of collapsing
it. Check the logic where nonNullTypes.map creates the anyOf entries and add
special handling to preserve the {} option for propertyless object types, so
that ['object', 'null'] generates faker.helpers.arrayElement([{}, null]) instead
of just [null].
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/mock/src/faker/getters/object.ts`:
- Around line 382-386: The nullWrapped property in the returned object is
incorrectly propagating the nested property's nullWrapped state by using
`nullWrapped || resolvedValue.nullWrapped`. Since resolvedValue.nullWrapped
describes the additional-property value and not the dictionary object being
returned, remove the `|| resolvedValue.nullWrapped` portion from the nullWrapped
assignment in the return statement so that only the nullWrapped parameter is
used for the containing object's nullWrapped property.

---

Outside diff comments:
In `@packages/mock/src/faker/getters/object.ts`:
- Around line 134-186: The combineSchemasMock call for union types like
['object', 'null'] with no properties is not preserving the empty object branch.
When nonNullTypes contains 'object' but the schemaItem has no properties or
required fields, ensure that the mapped anyOf array includes a valid empty
object entry instead of collapsing it. Check the logic where nonNullTypes.map
creates the anyOf entries and add special handling to preserve the {} option for
propertyless object types, so that ['object', 'null'] generates
faker.helpers.arrayElement([{}, null]) instead of just [null].
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d5d297ba-cca3-4b31-920c-c62e90bbac20

📥 Commits

Reviewing files that changed from the base of the PR and between 3f4d7de and 7e17bc7.

⛔ Files ignored due to path filters (34)
  • tests/__snapshots__/mock/issue-3525-multi/endpoints.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3525-multi/model/index.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3525-oas31/endpoints.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3525-oas31/model/index.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3525-widget-mock-strict/endpoints.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3525/endpoints.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3525/model/index.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split-fetch/pets/index.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split-fetch/pets/index.msw.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split-fetch/pets/pets/pets.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split-fetch/pets/pets/pets.msw.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split-fetch/pets/pets/pets.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split-fetch/schemas/index.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split-fetch/schemas/index.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split-fetch/schemas/pet.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split/pets/index.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split/pets/index.msw.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split/pets/pets/pets.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split/pets/pets/pets.msw.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split/pets/pets/pets.service.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split/schemas/index.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3572-strict-mock-tags-split/schemas/pet.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3574-strict-mock-tags-split-fetch/pets/pets/pets.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3574-strict-mock-tags-split-fetch/pets/pets/pets.msw.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3574-strict-mock-tags-split-fetch/schemas/index.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3574-strict-mock-tags-split-multi-fetch/schemas/index.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3574-strict-mock-tags-split-multi-fetch/store/store/store.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3574-strict-mock-tags-split-multi-fetch/store/store/store.msw.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3574-strict-mock-tags-split/pets/pets/pets.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3574-strict-mock-tags-split/pets/pets/pets.msw.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3590-tags-split-schema-imports/pets/pets/pets.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3590-tags-split-schema-imports/schemas/index.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3590-wide-schema-imports/model/index.faker.ts is excluded by !**/__snapshots__/**
  • tests/__snapshots__/mock/issue-3590/model/index.faker.ts is excluded by !**/__snapshots__/**
📒 Files selected for processing (4)
  • packages/mock/src/faker/getters/object.test.ts
  • packages/mock/src/faker/getters/object.ts
  • packages/mock/src/mock-types.test.ts
  • packages/mock/src/mock-types.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/mock/src/mock-types.test.ts
  • packages/mock/src/mock-types.ts

Comment thread packages/mock/src/faker/getters/object.ts
Hypenate and others added 2 commits June 17, 2026 15:07
Stop propagating nested nullWrapped from additionalProperties values and
emit {} for propertyless type: ['object', 'null'] unions.

Co-authored-by: Cursor <cursoragent@cursor.com>
…l union

NullableAnyObject now emits faker.helpers.arrayElement([{}, null])
instead of [null] only.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Hypenate

Copy link
Copy Markdown
Contributor Author

@wadakatu this follow up PR for #3607 with issue #3590 fixes your remarks.

@melloware melloware added the mock Related to mock generation label Jun 17, 2026
@melloware melloware added this to the 8.18.0 milestone Jun 17, 2026
@melloware melloware merged commit 0afe352 into orval-labs:master Jun 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mock Related to mock generation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants