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

Conversation

@Shinigami92
Copy link
Contributor

@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 6, 2025

🦋 Changeset detected

Latest commit: 504edb5

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 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hey-api-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2025 3:21pm

Copy link
Member

@mrlubos mrlubos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be all that's needed!

Build the library with pnpm openapi-ts build and then update snapshots with pnpm openapi-ts-tests test:update. If anything fails, you probably need to build the failing dependency as well

@Shinigami92
Copy link
Contributor Author

pnpm openapi-ts build

FYI, when exec pnpm openapi-ts build, I get:

> openapi-ts-monorepo@0.1.0 openapi-ts D:\shinigami\OpenSource\openapi-ts
> turbo run $1 --filter="@hey-api/openapi-ts" "build"

turbo 2.5.5

 WARNING  Unable to calculate transitive closures: Workspace 'examples/openapi-ts-nuxt/.output/server' not found in lockfile.
  × Missing tasks in project
  ╰─▶   × Could not find task `$1` in project

 ELIFECYCLE  Command failed with exit code 1.

(same for pnpm openapi-ts-tests test:update)

pnpm run build works just fine

I assume $1 is not compatible with exec in git bash on windows 11

I will run the commands manually, ergo:

  • pnpm turbo run build --filter="@hey-api/openapi-ts"
  • pnpm turbo run test:update --filter="./packages/openapi-ts-tests/**/*"

...

however I get a lot of file changes that are only changed in eol, even with the .gitattributes 🤷
switching to my Mac ...

@Shinigami92
Copy link
Contributor Author

ok, I ran rm -Rf packages/openapi-ts-tests/main/test/__snapshots__ and then pnpm openapi-ts-tests test:update on my Mac
the output was very similar to windows if not even the same
however that were 2k file changes... so that's not reviewable by a human and you can ignore the fc09655 commit while reviewing. I suggest to reproduce the both commands on your machine to verify that I did exactly these because no other changes should be applied on come up in your staged files.

There is now another test error: https://github.com/hey-api/openapi-ts/actions/runs/16781162735/job/47519904281?pr=2396#step:10:300
Tell me please what I should execute

@Shinigami92 Shinigami92 requested a review from mrlubos August 6, 2025 15:25
@mrlubos
Copy link
Member

mrlubos commented Aug 6, 2025

@Shinigami92 I think it's something around that index.ts conditional. What's the desired outcome of that if check?

EDIT: I'd like to see unit tests for the packages/openapi-ts/src/generate/client.ts file. That might give us an answer

@Shinigami92
Copy link
Contributor Author

@Shinigami92 I think it's something around that index.ts conditional. What's the desired outcome of that if check?

similar to the output base directory, the bundled client generates an index.ts file. however this should be an index.ts and not an index.gen.ts, because otherwise we would need to fix even more imports in many other files that just imports from ./client (which resolves to ./client/index.ts).

EDIT: I'd like to see unit tests for the packages/openapi-ts/src/generate/client.ts file. That might give us an answer

an answer to what exactly? maybe you should have a look into the snapshot files, because then you can see how the new structure is build.
example:

@mrlubos
Copy link
Member

mrlubos commented Aug 7, 2025

@dosu any idea why tests are failing?

@mrlubos
Copy link
Member

mrlubos commented Aug 8, 2025

@Shinigami92 Can you update the snapshots and open the pull request if it's ready for review? I can fix the failing tests after it's merged

@Shinigami92 Shinigami92 force-pushed the fix-infix-dot-gen-to-client-and-core branch from fc09655 to ce246ca Compare August 9, 2025 09:59
@vercel
Copy link

vercel bot commented Aug 9, 2025

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

A member of the Team first needs to authorize it.

@Shinigami92 Shinigami92 marked this pull request as ready for review August 9, 2025 10:06
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. client Client package related labels Aug 9, 2025
@Shinigami92
Copy link
Contributor Author

@Shinigami92 Can you update the snapshots and open the pull request if it's ready for review? I can fix the failing tests after it's merged

@mrlubos

  • rebase the PR on latest changes
  • regenerated the snapshots (as described above)
  • opened the PR and you can modify as you need

tip, you can use gh tools and checkout this PR with gh pr checkout 2396

@mrlubos
Copy link
Member

mrlubos commented Aug 9, 2025

@Shinigami92 looking at the diff, it's interesting that it detects some changes as file renames while some are treated as new files. Any idea why?

Screenshot 2025-08-09 at 6 13 16 pm

bodySerializer and types should be also detected as renamed. Has anything changed inside the files?

EDIT: hm, it's just imports

@Shinigami92
Copy link
Contributor Author

@Shinigami92 looking at the diff, it's interesting that it detects some changes as file renames while some are treated as new files. Any idea why?

Screenshot 2025-08-09 at 6 13 16 pm bodySerializer and types should be also detected as renamed. Has anything changed inside the files?

I was confused as well about that because the changes are not that big. But at the top of these files, obviously the import statements have changed to import from '... .gen'

@mrlubos
Copy link
Member

mrlubos commented Aug 9, 2025

Yeah I would've thought it can detect that. I'll merge it and see what's up!

Copy link
Member

@mrlubos mrlubos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I found what the problem might be. You added infixDotGenToFiles calls to generateClientBundle. This function is called from both legacy and current output generate step. Try adding a flag argument to generateClientBundle controlling whether infixDotGenToFiles will be called. If it's false (this will apply for the legacy approach), don't call infixDotGenToFiles, i.e. this pull request won't impact it. If you look at the snapshot diffs, the files in test/generated were simply deleted with no replacement found. We don't want to support the legacy stuff, it only complicates things!

@Shinigami92
Copy link
Contributor Author

I think I found what the problem might be. You added infixDotGenToFiles calls to generateClientBundle. This function is called from both legacy and current output generate step. Try adding a flag argument to generateClientBundle controlling whether infixDotGenToFiles will be called. If it's false (this will apply for the legacy approach), don't call infixDotGenToFiles, i.e. this pull request won't impact it. If you look at the snapshot diffs, the files in test/generated were simply deleted with no replacement found. We don't want to support the legacy stuff, it only complicates things!

What could be the best strategy to clean the packages/openapi-ts-tests/main/test/__snapshots__ directory?
Because when I regenerate the files without cleaning them, it will leave behind like bodySerializer.ts and just adds next to it a bodySerializer.gen.ts.

@Shinigami92
Copy link
Contributor Author

ok, I made one adjustment commit with the legacy flag
and then I called git checkout main -- packages/openapi-ts-tests/main/test/__snapshots__/test/generated and committed that one

@mrlubos
Copy link
Member

mrlubos commented Aug 9, 2025

I think I found what the problem might be. You added infixDotGenToFiles calls to generateClientBundle. This function is called from both legacy and current output generate step. Try adding a flag argument to generateClientBundle controlling whether infixDotGenToFiles will be called. If it's false (this will apply for the legacy approach), don't call infixDotGenToFiles, i.e. this pull request won't impact it. If you look at the snapshot diffs, the files in test/generated were simply deleted with no replacement found. We don't want to support the legacy stuff, it only complicates things!

What could be the best strategy to clean the packages/openapi-ts-tests/main/test/__snapshots__ directory?

Because when I regenerate the files without cleaning them, it will leave behind like bodySerializer.ts and just adds next to it a bodySerializer.gen.ts.

Delete it manually. Whenever you rename or delete snapshots that's what I do. Yes, it should be automated, but isn't right now

@@ -135,6 +163,11 @@ export const generateClientBundle = ({
ensureDirSync(coreOutputPath);
const coreDistPath = path.resolve(packageRoot, 'dist', 'clients', 'core');
copyRecursivePnP(coreDistPath, coreOutputPath);

if (legacy !== true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (legacy !== true) {
if (!legacy) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this wont work, as I have not set legacy to false but undefined in the non-legacy variant

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!legacy doesn’t mean legacy === false, it means any falsy value. 0, empty string, undefined, null, and false are all falsy values

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my brain was not braining
I confused myself with the legacy: false I did before

@Shinigami92
Copy link
Contributor Author

sry I'm playing a game at the side ^^

@mrlubos
Copy link
Member

mrlubos commented Aug 9, 2025

sry I'm playing a game at the side ^^

Which game? The new Mafia just came out, are you playing that?

@Shinigami92
Copy link
Contributor Author

sry I'm playing a game at the side ^^

Which game? The new Mafia just came out, are you playing that?

image

@mrlubos mrlubos force-pushed the fix-infix-dot-gen-to-client-and-core branch from 19ac4de to 504edb5 Compare August 9, 2025 12:52
@mrlubos
Copy link
Member

mrlubos commented Aug 9, 2025

don't have any more patience for this, I'll just remove that snapshot test

@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 9, 2025

Open in StackBlitz

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

commit: 504edb5

@codecov
Copy link

codecov bot commented Aug 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 22.42%. Comparing base (11a6921) to head (504edb5).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2396      +/-   ##
==========================================
- Coverage   22.43%   22.42%   -0.02%     
==========================================
  Files         325      325              
  Lines       32031    32061      +30     
  Branches     1234     1234              
==========================================
+ Hits         7187     7189       +2     
- Misses      24835    24863      +28     
  Partials        9        9              
Flag Coverage Δ
unittests 22.42% <ø> (-0.02%) ⬇️

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 merged commit 15009fc into hey-api:main Aug 9, 2025
13 of 16 checks passed
@github-actions github-actions bot mentioned this pull request Aug 9, 2025
@Shinigami92 Shinigami92 deleted the fix-infix-dot-gen-to-client-and-core branch August 9, 2025 13:35
@swisscat
Copy link

swisscat commented Aug 9, 2025

I think this may have broken ESM SDK generation. Have a look at this sample repo I created to reproduce:

https://github.com/swisscat/openapi-ts-esm-bug

  • With 0.80.6, client/client.ts files contain .js extensions for included files
  • With 0.80.7, client/client.gen.ts does not include the extensions anymore, so compilation as ESM is not working anymore

@mrlubos
Copy link
Member

mrlubos commented Aug 10, 2025

Thanks @swisscat! @Shinigami92 are you going to open another pull request?

@Shinigami92
Copy link
Contributor Author

Thanks @swisscat! @Shinigami92 are you going to open another pull request?

I would like first try tomorrow if I have the same issue at company work.
But I think I won't have this issue because we use moduleResolution:bundler instead of nodenext.

I also explicitly didn't touched the shouldAppendJs logic and that's why I added the infix before that blocks.

So if we really do not have an issue in our project but @swisscat has in theirs, they should open a new issue and try to fix it.

@mrlubos
Copy link
Member

mrlubos commented Aug 10, 2025

Sounds good. If the issue persists we might revert this pull request however to avoid breaking the existing functionality which seems to be the case

@Shinigami92
Copy link
Contributor Author

Sounds good. If the issue persists we might revert this pull request however to avoid breaking the existing functionality which seems to be the case

everything works fine on our side with 0.80.8 👍

@mrlubos
Copy link
Member

mrlubos commented Aug 11, 2025

😎 🤘

@swisscat
Copy link

Thanks, I confirm everything is working fine !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants