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

Issue with enum naming in @kubb/plugin-ts v3.4.5 #1592

Open
burt202 opened this issue Mar 10, 2025 · 2 comments
Open

Issue with enum naming in @kubb/plugin-ts v3.4.5 #1592

burt202 opened this issue Mar 10, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@burt202
Copy link

burt202 commented Mar 10, 2025

What version of kubb is running?

See below

What kind of platform do you use?

Linux

How does your kubb.config.ts config look like

See linked repo below

Swagger/OpenAPI file?

See linked repo below

What version of external packages are you using(@tanstack-query, MSW, React, Vue, ...)

See linked repo below

What steps can reproduce the bug?

When upgrading to the latest versions of the various kubb packages we use, i stumbled into an issue which turned out to be something changing how the generated enum const and types were named. I narrowed it down to a change in @kubb/plugin-ts v3.4.5 , 3.4.4 works

Basically in 3.4.4 the output is:

export const aiTypeEnum = {
  foo: 'foo',
  bar: 'bar',
} as const

export type AiTypeEnum = (typeof aiTypeEnum)[keyof typeof aiTypeEnum]

and in 3.4.5 its

export const AITypeEnum = {
  foo: 'foo',
  bar: 'bar',
} as const

export type AITypeEnum = (typeof AITypeEnum)[keyof typeof AITypeEnum]

Note the lower case 'ai' in the first example. In 3.4.5, both the const and type are named with the same casing which is causing issues for us. Is this a bug or is there something in the config that can be set to get the old behaviour back?

For repro, clone repo linked below and npm ci and npm run generate, upgrade @kubb/plugin-ts to v3.4.5 to see the breaking output

https://github.com/burt202/kubb-test

Cheers

How often does this bug happen?

Every time

What is the expected behavior?

No response

Additional information

No response

@burt202 burt202 added the bug Something isn't working label Mar 10, 2025
@stijnvanhulle
Copy link
Collaborator

@burt202 The reason why is that AI is set as capital letters in the Swagger/OpenAPI file which means that we keep capital letters inside of the defined string. What you can do is updating your Swagger file to use Ai instead of AI.

@burt202
Copy link
Author

burt202 commented Mar 17, 2025

Thanks for the reply, its much appreciated. I guess its still a breaking change on a patch update though. Would you expect the enumType: 'asConst' setting to keep the const enum as aiTypeEnum because that is not working either.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants