Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Description

Fixes the OpenAPI IR parser to properly handle array-typed query parameters. Previously, the parser would log debug warnings like Expected a primitive example but got array for query parameter tipMode for GET /payments when encountering array-typed query parameters with array examples.

Link to Devin run: https://app.devin.ai/sessions/3a4e6565484443fcb082bfd5a8ba00d1
Requested by: Deep Singhvi ([email protected]) / @dsinghvi

Changes Made

  • Enhanced getResolvedSchema() to properly unwrap optional/nullable/reference wrappers to determine the underlying schema type
  • Updated query parameter example validation to accept array examples when the resolved schema type is array
  • Fixed a bug in isExamplePrimitive() where the unknown case was recursing on the same value instead of inspecting example.value

Key Implementation Details

The fix aligns with the existing IR-to-Fern conversion in buildQueryParameter.ts, which already handles array query parameters via the allowMultiple flag. When a query parameter has an array schema, the IR-to-Fern layer unwraps it to the item type and sets allowMultiple: true, allowing multiple values to be passed (e.g., ?status=pending&status=active).

Testing

  • Manual testing: Verified lint checks pass
  • Unit tests added/updated (⚠️ Reviewer note: No test coverage added for this fix)

Review Checklist

Important areas to review:

  1. Schema resolution logic (lines 700-724): Verify the while loop correctly handles all combinations of optional/nullable/reference wrappers and prevents infinite loops for circular references
  2. Array validation logic (lines 506-519): Confirm that allowing array examples for array-typed query parameters is correct and doesn't break existing behavior
  3. Downstream compatibility: Verify that buildQueryParameter.ts actually handles array query parameters correctly via allowMultiple (assumption made but not explicitly tested)
  4. Test coverage: Consider whether regression tests should be added for this fix

devin-ai-integration bot and others added 2 commits November 20, 2025 16:44
This commit fixes the OpenAPI IR parser to properly handle array-typed query parameters. Previously, the parser would log debug warnings like 'Expected a primitive example but got array for query parameter X' when encountering array-typed query parameters.

The fix includes:
1. Enhanced getResolvedSchema() to properly unwrap optional/nullable/reference wrappers to determine the underlying schema type
2. Updated query parameter example validation to accept array examples when the resolved schema type is array
3. Fixed a bug in isExamplePrimitive() where the unknown case was recursing on the same value instead of inspecting example.value

This aligns with the existing IR-to-Fern conversion in buildQueryParameter.ts which already handles array query parameters via the allowMultiple flag.

Co-Authored-By: Deep Singhvi <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 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 November 20, 2025 16:53
The previous implementation was using the unwrapped schema in isSchemaRequired, which caused optional/nullable parameters to be treated as required. This led to examples being dropped when optional parameters were missing.

Now isSchemaRequired uses the original schema (without unwrapping) to correctly determine requiredness, while getResolvedSchema is only used for detecting array types in query parameter validation.

Co-Authored-By: Deep Singhvi <[email protected]>
The fix now properly generates examples for endpoints with array-typed query parameters. Updated snapshots reflect the addition of examples that were previously missing for these cases.

Co-Authored-By: Deep Singhvi <[email protected]>
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.

1 participant