这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@flow96
Copy link
Contributor

@flow96 flow96 commented Aug 11, 2025

Fixes #2377

This bug only occures when asClass was set to true and when the schema contains the same nested tags and operationIds. For example:

...
operationId: providers.domains.get
tags:
- Providers
- Domains
...

Based on that schema the implementation tries to build a paths like this: providers.providers.domains.get and domains.providers.domains.get (the tags are used for the root class and then the path is built up from the operationId).

The problem that occurs, is that the generator tries add the same class multiple times and then link these two or more instances with each other, which ends up in an endless recursion loop.

I fixed it by removing the root class from the path if the same class name appears later in that path already. So for our example the new path would be:
providers.domains.get

I added two tests to verify the class generation works with nested classes - with and without instance creation.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@changeset-bot
Copy link

changeset-bot bot commented Aug 11, 2025

🦋 Changeset detected

Latest commit: 7308d9b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hey-api/openapi-ts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Aug 11, 2025

@flow96 is attempting to deploy a commit to the Hey API Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Aug 11, 2025
@flow96 flow96 force-pushed the fix/nested-class-generation branch from e5fc1e9 to 5a9b6f6 Compare August 11, 2025 17:43
@dosubot dosubot bot added bug 🔥 Something isn't working client Client package related labels Aug 11, 2025
@flow96 flow96 force-pushed the fix/nested-class-generation branch from 5a9b6f6 to c78c2ca Compare August 11, 2025 18:17
@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 11, 2025

Open in StackBlitz

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/nuxt@2426
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/openapi-ts@2426
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/vite-plugin@2426

commit: 7308d9b

@codecov
Copy link

codecov bot commented Aug 11, 2025

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 22.77%. Comparing base (7c64fc8) to head (7308d9b).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...s/openapi-ts/src/plugins/@hey-api/sdk/operation.ts 0.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2426      +/-   ##
==========================================
- Coverage   22.77%   22.77%   -0.01%     
==========================================
  Files         334      334              
  Lines       32941    32946       +5     
  Branches     1302     1302              
==========================================
  Hits         7502     7502              
- Misses      25430    25435       +5     
  Partials        9        9              
Flag Coverage Δ
unittests 22.77% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

mrlubos
mrlubos previously approved these changes Aug 12, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 12, 2025
@mrlubos mrlubos merged commit ee1d5ec into hey-api:main Aug 12, 2025
13 of 16 checks passed
@github-actions github-actions bot mentioned this pull request Aug 12, 2025
@flow96 flow96 deleted the fix/nested-class-generation branch August 13, 2025 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🔥 Something isn't working client Client package related lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maximum call stack size exceeded when using asClass: true

2 participants