Skip to content
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

fix: infinite loop in transforms #712

Merged
merged 5 commits into from
Jun 24, 2024
Merged

fix: infinite loop in transforms #712

merged 5 commits into from
Jun 24, 2024

Conversation

mrlubos
Copy link
Member

@mrlubos mrlubos commented Jun 23, 2024

Closes #705

Copy link

stackblitz bot commented Jun 23, 2024

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

Copy link

vercel bot commented Jun 23, 2024

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 Jun 24, 2024 3:47am

Copy link

changeset-bot bot commented Jun 23, 2024

🦋 Changeset detected

Latest commit: 0ce82e5

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

@mrlubos mrlubos marked this pull request as ready for review June 24, 2024 03:37
Copy link

codecov bot commented Jun 24, 2024

Codecov Report

Attention: Patch coverage is 25.25253% with 518 lines in your changes missing coverage. Please review.

Project coverage is 69.67%. Comparing base (0e79f7b) to head (0ce82e5).
Report is 2 commits behind head on main.

Files Patch % Lines
...ackages/openapi-ts/src/utils/write/transformers.ts 11.89% 289 Missing ⚠️
packages/openapi-ts/src/compiler/transform.ts 8.23% 78 Missing ⚠️
packages/openapi-ts/src/utils/write/services.ts 8.69% 63 Missing ⚠️
packages/openapi-ts/src/utils/write/types.ts 59.67% 25 Missing ⚠️
packages/openapi-ts/src/utils/write/type.ts 46.15% 21 Missing ⚠️
packages/openapi-ts/src/compiler/function.ts 15.78% 16 Missing ⚠️
packages/openapi-ts/src/utils/write/client.ts 47.82% 11 Missing and 1 partial ⚠️
packages/openapi-ts/src/compiler/convert.ts 30.00% 7 Missing ⚠️
packages/openapi-ts/src/compiler/return.ts 28.57% 5 Missing ⚠️
packages/openapi-ts/src/compiler/index.ts 90.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #712      +/-   ##
==========================================
- Coverage   71.06%   69.67%   -1.39%     
==========================================
  Files          76       78       +2     
  Lines        8034     8267     +233     
  Branches      710      709       -1     
==========================================
+ Hits         5709     5760      +51     
- Misses       2321     2502     +181     
- Partials        4        5       +1     
Flag Coverage Δ
unittests 69.67% <25.25%> (-1.39%) ⬇️

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.

@mrlubos mrlubos merged commit 9a1e8c9 into main Jun 24, 2024
14 of 16 checks passed
@mrlubos mrlubos deleted the fix/transform-multiple-void branch June 24, 2024 03:51
@github-actions github-actions bot mentioned this pull request Jun 24, 2024
if (config.debug) {
console.warn(
`⚠️ Transformers warning: route ${operation.method} ${operation.path} has ${responses.length} success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`,
);

Choose a reason for hiding this comment

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

I do think putting this behind a debug flag is inviting people to have weird issues and blame the package. If it fires it should be because a type IS wrong and that's something devs need to know up front

thenStatement: ts.factory.createBlock(statements),
}),
];
})

Choose a reason for hiding this comment

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

What happens if there's an endpoint with two different models on responses? Looks like this attempts to handle it but there's no test?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you have an example? It's meant to handle only FooResponse | void and there's a snapshot for that

Choose a reason for hiding this comment

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

Ah you're right, i missed that you're still bailing out for 2+ non-void models.

Should be easy to adapt to support multiple responses when one of us has time for

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transform generation fails if route has multiple success responses
2 participants