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

feat(parser): generate enums into their own file #358

Merged
merged 3 commits into from
Apr 12, 2024
Merged

Conversation

mrlubos
Copy link
Member

@mrlubos mrlubos commented Apr 12, 2024

No description provided.

Copy link

changeset-bot bot commented Apr 12, 2024

🦋 Changeset detected

Latest commit: a786c22

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

This PR includes changesets to release 2 packages
Name Type
@hey-api/openapi-ts Minor
openapi-ts-docs 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

Copy link

vercel bot commented Apr 12, 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 Apr 12, 2024 2:15am

Copy link

codecov bot commented Apr 12, 2024

Codecov Report

Attention: Patch coverage is 67.05882% with 84 lines in your changes are missing coverage. Please review.

Project coverage is 84.16%. Comparing base (c96c3ec) to head (a786c22).

Files Patch % Lines
packages/openapi-ts/src/utils/write/models.ts 45.58% 37 Missing ⚠️
packages/openapi-ts/src/compiler/types.ts 50.00% 26 Missing ⚠️
packages/openapi-ts/src/utils/write/core.ts 89.28% 6 Missing ⚠️
packages/openapi-ts/src/utils/write/index.ts 64.70% 6 Missing ⚠️
packages/openapi-ts/src/utils/write/services.ts 68.75% 5 Missing ⚠️
packages/openapi-ts/src/utils/enum.ts 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #358      +/-   ##
==========================================
- Coverage   84.51%   84.16%   -0.35%     
==========================================
  Files          73       73              
  Lines        4765     4813      +48     
  Branches      548      549       +1     
==========================================
+ Hits         4027     4051      +24     
- Misses        737      761      +24     
  Partials        1        1              
Flag Coverage Δ
unittests 84.16% <67.05%> (-0.35%) ⬇️

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.

/**
* This is a simple enum with strings
*/
export type foo_bar_enum_ = 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串';
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is up with these?

* These are the HTTP error code enums
*/
export type statusCode = '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar';

/**
* This is a model with one enum with escaped name
*/
export type ModelWithEnumWithHyphen = {
'foo-bar-baz-qux'?: '3.0';
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

whats going on here? why is it generate separately

FOO = 'foo',
BAR = 'bar',
}
export type foo = 'Bar';
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are these being generated now?

@@ -31,6 +32,11 @@ export class TypeScriptFile {
this._imports = [...this._imports, compiler.import.named(...params)];
}

public setPath(path: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we pass the path in the class contructor (same with a header)? Its probably cleaner than doing this. And they can be optional


```js
import { Enum, DefaultService } from 'client' // [!code --]
import { Enum } from 'client/enums.gen.ts' // [!code ++]
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably work on renaming all files to .gen.ts for consistency

@mrlubos mrlubos merged commit 7e7f44c into main Apr 12, 2024
14 of 16 checks passed
@mrlubos mrlubos deleted the fix/enums-file branch April 12, 2024 02:21
@github-actions github-actions bot mentioned this pull request Apr 12, 2024
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.

2 participants