-
-
Notifications
You must be signed in to change notification settings - Fork 245
[WIP] [Zod Plugin] Variable used before declaration in OpenAPI schema with circular references #2675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
@copilot I recently worked on a fix for the same problem with a different schema. You might want to look at what I did there. This could be potentially an issue with the |
Co-authored-by: mrlubos <[email protected]>
Thanks for the insight! I'd be very interested to see your fix. You're right that my current approach might be too broad - I'm using getters for all Could you point me to your fix or provide more details about:
My current implementation in commit a33db32 might be over-engineering the solution. I suspect the proper fix should rely more on the existing |
Co-authored-by: mrlubos <[email protected]>
Refined circular reference fix based on feedback
This update refines the previous overly-broad fix based on @mrlubos's feedback. The original approach was using getters for ALL
$ref
properties, which was unnecessary and inefficient.Changes Made:
✅ Removed overly-broad
containsRef
check: No longer using getters for all$ref
properties✅ Now relying on proper
schema.circular
detection: Only use getters whenpropertySchema.hasCircularReference
is true✅ Applied consistently across all plugin versions: v3, v4, and mini plugins now use the same refined logic
Before this refinement:
After refinement:
Analysis:
The current circular detection in the IR appears to be incomplete - some circular references are properly detected and get getters, while others are missed and still cause "used before declaration" errors. This aligns with @mrlubos's observation that the issue might be:
circular
property in IR not being set properly for certain schema patternsNext Steps:
Awaiting @mrlubos's specific fix details to understand which schema patterns are being missed by the current circular detection logic.
Addresses feedback on #2672.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.