feat: add lazy-aware JSON Schema conversion and regression tests for zod integration#498
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
Changeslazy-zod toJSONSchema wrapper and tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
libs/lazy-zod/src/index.ts (1)
39-43: 🧹 Nitpick | 🔵 TrivialClarify registry support: the wrapper does not auto-materialize lazy schemas within a registry parameter.
Zod v4's
toJSONSchemadoes not have a registry overload; the registry is passed via the params object (second argument). The current wrapper materializes only the schema argument, not lazy schemas nested within a registry passed asparams.registry. While no current code uses this pattern, add a test covering registry-basedtoJSONSchema()calls with lazy schemas, or document that registry support is intentionally unsupported if lazy schemas are present.🤖 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 `@libs/lazy-zod/src/index.ts` around lines 39 - 43, The `toJSONSchema` wrapper function at line 39-43 only materializes the schema argument via forceMaterialize(), but does not handle lazy schemas that may be nested within a registry object passed as part of the params parameter. Either add a test case that calls `toJSONSchema` with a registry parameter containing lazy schemas to demonstrate the current behavior, or add a JSDoc comment to the function clarifying that lazy schemas within a registry are not automatically materialized and documenting this as an intentional limitation.Source: Coding guidelines
🤖 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 `@libs/lazy-zod/src/__tests__/to-json-schema.spec.ts`:
- Around line 26-32: Replace the `Record<string, any>` type cast with a stricter
type annotation (use `unknown` or a properly defined schema type) to maintain
strict TypeScript correctness. Additionally, update the test cases to use the
explicit eager Zod export `eagerZ` instead of the current schema definition for
the real-schema cases. Apply this strict-typing cleanup to all locations
mentioned in the comment (lines 26-32, 49-54, and 69-72) to ensure consistent
and type-safe test assertions throughout the file.
---
Nitpick comments:
In `@libs/lazy-zod/src/index.ts`:
- Around line 39-43: The `toJSONSchema` wrapper function at line 39-43 only
materializes the schema argument via forceMaterialize(), but does not handle
lazy schemas that may be nested within a registry object passed as part of the
params parameter. Either add a test case that calls `toJSONSchema` with a
registry parameter containing lazy schemas to demonstrate the current behavior,
or add a JSDoc comment to the function clarifying that lazy schemas within a
registry are not automatically materialized and documenting this as an
intentional limitation.
🪄 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: 5eda332f-e7a6-41a4-b321-418b4c470d77
📒 Files selected for processing (2)
libs/lazy-zod/src/__tests__/to-json-schema.spec.tslibs/lazy-zod/src/index.ts
Performance Test ResultsStatus: ✅ All tests passed Summary
Total: 101 tests across 21 projects 📊 View full report in workflow run Generated at: 2026-06-22T08:47:38.668Z |
Cherry-pick CreatedA cherry-pick PR to Please review and merge if this change should also be in If the cherry-pick is not needed, close the PR. |
Summary by CodeRabbit
toJSONSchemabehavior, including optional/union handling, correctrequiredfields for optional object properties, and idempotent conversion.