Skip to content

Conversation

@sbawabe
Copy link
Contributor

@sbawabe sbawabe commented Dec 10, 2025

Description

Refs: Request from Sarah Bawabe

Fixes a bug where explicit null values in OpenAPI response examples were being incorrectly replaced with schema example values. For example, balance_max: null in a tiered rate structure (representing an unbounded upper tier) was being replaced with "100000000" from the schema's example field.

Link to Devin run: https://app.devin.ai/sessions/dcba61f67aa34cc5aaac1eb92ee496a5
Requested by: Sarah Bawabe (@sbawabe)

Root Cause

The nullish coalescing operator (??) was treating explicit null values as nullish and falling back to schema examples. Changed to use explicit undefined checks to preserve null values in examples.

Changes Made

  • ExampleConverter.ts: Changed property example resolution from propExampleFromParent ?? this.maybeResolveSchemaExample(property) to an explicit undefined check, so explicit null values are preserved
  • ExampleTypeFactory.ts: Added early return for example === null in nullable schema handling, and changed property example resolution to use inExample check to respect explicit presence in the example object
  • Added test fixture balance-max-null with an OpenAPI spec containing:
    • A RateTier schema where balance_max is nullable
    • An explicit response example with 3 tiers where the third tier has balance_max: null
  • Added test case with assertions verifying tiers[2].balance_max is null (not replaced with "100000000")
  • Updated valtown snapshots to reflect correct behavior (null values now preserved instead of replaced with schema examples)

Testing

  • Unit tests added/updated
  • All existing tests pass
  • Lint checks pass
  • All CI checks pass

Human Review Checklist

  • Verify the valtown snapshot changes are expected behavior:
    • profileImageUrl: null instead of "profileImageUrl" (schema example)
    • lastInsertRowid omitted when not present in the example
  • Verify the nullish coalescing → undefined check change doesn't break other example generation scenarios
  • Confirm the example === null early return in ExampleTypeFactory is correct for nullable schemas
  • Check that the fix correctly distinguishes between "property absent from example" vs "property explicitly set to null"

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration bot and others added 2 commits December 10, 2025 22:08
…tions

- Add explicit response example with 3 tiers where the third tier has balance_max: null
- Add assertions to verify null value is preserved in the output
- Mark test as expected-failing (it.fails) since the bug currently replaces null with schema example value
- Once the bug is fixed, this test should be changed back to a normal it(...) test

Co-Authored-By: Sarah Bawabe <[email protected]>
The nullish coalescing operator (??) was treating explicit null values
as nullish and falling back to schema examples. Changed to use explicit
undefined check to preserve null values in examples.

This fixes the bug where balance_max: null in tiered rate structures
was being replaced with the schema example value (e.g., '100000000').

Co-Authored-By: Sarah Bawabe <[email protected]>
@devin-ai-integration devin-ai-integration bot changed the title chore(internal): add test for nullable balance_max in tiered rates fix: preserve explicit null values in OpenAPI examples Dec 10, 2025
The fix for preserving explicit null values in OpenAPI examples now
correctly shows profileImageUrl: null instead of the schema example,
and omits lastInsertRowid when not present in the example.

Co-Authored-By: Sarah Bawabe <[email protected]>
@devin-ai-integration devin-ai-integration bot changed the title fix: preserve explicit null values in OpenAPI examples fix(openapi): preserve explicit null values in OpenAPI examples Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants