-
-
Couldn't load subscription status.
- Fork 259
Fix maximum call stack size exceeded when using asClass: true
#2816
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.
💡 Enable Vercel Agent with $100 free credit for automated AI reviews |
- Remove duplicate class names from operation path to prevent self-references - Add cycle detection to prevent circular class hierarchies - Fixes issue where operationIds with path segments that transform to same PascalCase name as tags created circular references Co-authored-by: mrlubos <[email protected]>
asClass: true
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2816 +/- ##
==========================================
- Coverage 29.15% 29.13% -0.03%
==========================================
Files 391 391
Lines 38104 38131 +27
Branches 2272 2272
==========================================
Hits 11109 11109
- Misses 26965 26992 +27
Partials 30 30
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
commit: |
Problem
When using the SDK plugin with
asClass: true, the code generator would fail with "Maximum call stack size exceeded" error for certain OpenAPI specifications. This issue occurred when operationIds contained path segments that, after PascalCase transformation, created duplicate class names or circular class hierarchies.Root Cause
The issue had two related causes:
Duplicate class names in path: When an operationId like
api/v1/test/getDatawas combined with a tag likeTest, the generated class path would be:["Test", "api", "v1", "test"]["Test", "Api", "V1", "Test"]This created a self-referencing class structure where
Testappeared twice in the hierarchy.Circular class hierarchies: Multiple operations with overlapping class segments could create cycles. For example:
AccountingCompanies → Api → VVersionApiVersion → OdataOdata → ... → AccountingCompaniesThis resulted in infinite recursion during class generation.
Solution
This PR implements two fixes:
1. Deduplicate class names in operation paths (
operation.ts)After transforming path segments to PascalCase, the code now removes duplicate class names while preserving order:
2. Add cycle detection to parent-child relationships (
plugin.ts)Before adding a child class to a parent, the code now checks if it would create a cycle:
Testing
Fixes #2627
Original prompt
Fixes #2815
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.