fix(core): leave allOf-wrapped ref discriminator properties untouched - #3998
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthrough
ChangesDiscriminator preservation
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Discriminator properties that wrap a shared enum reference in a single allOf now remain direct references, preventing invalid generated Zod enum calls while preserving shared schema reuse. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
@orval/angular
@orval/axios
@orval/core
@orval/effect
@orval/fetch
@orval/hono
@orval/mcp
@orval/mock
orval
@orval/query
@orval/solid-start
@orval/swr
@orval/zod
commit: |
Fixes #3991
Summary
When a
oneOfdiscriminatormappingtargets a member whose discriminator property is anallOfwrapping a single$refto a shared enum component (the shape drf-spectacular emits when a member accepts multiple discriminator values),resolveDiscriminatorsmerged the mapping keys into theallOfwrapper itself. The zod generator then rendered the chimera asEventTypeEnum.enum(['Pause', 'Session'])—.enumon aZodEnumis its values object, not callable, so the generated code failed with TS2349.resolveDiscriminatorsnow skips the merge entirely forallOf-wrapped single-$refproperties: the referenced shared schema already carries the full set of valid values, so the property stays exactly as declared.Output after the fix (from the issue's repro)
Verified end-to-end by running orval on the issue's spec with
client: 'zod'andgenerateReusableSchemas: true.Notes
A bare
$refdiscriminator property already took a different (safe) path via theisReferenceshort-circuit; this fix gives theallOf-wrapped variant the same leave-it-alone treatment.Summary by CodeRabbit
Bug Fixes
enumortypevalues.Tests