Skip to content

fix(sdk): nested operationIds and tags. Add tests for nested class generation #2426

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

Copy link

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

Copy link

changeset-bot bot commented Aug 11, 2025

⚠️ No Changeset found

Latest commit: c78c2ca

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

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
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: c78c2ca

Copy link

codecov bot commented Aug 11, 2025

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 22.77%. Comparing base (7c64fc8) to head (c78c2ca).

Files with missing lines Patch % Lines
...s/openapi-ts/src/plugins/@hey-api/sdk/operation.ts 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2426      +/-   ##
==========================================
- Coverage   22.77%   22.77%   -0.01%     
==========================================
  Files         334      334              
  Lines       32941    32944       +3     
  Branches     1302     1302              
==========================================
  Hits         7502     7502              
- Misses      25430    25433       +3     
  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.

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 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
1 participant