Skip to content

Fix boolean flags not being parsed as bools and thus consuming the input argument if it is given last#2694

Open
Qluxzz wants to merge 4 commits intoopenapi-ts:mainfrom
Qluxzz:fix-boolean-flags-not-parsing-correctly
Open

Fix boolean flags not being parsed as bools and thus consuming the input argument if it is given last#2694
Qluxzz wants to merge 4 commits intoopenapi-ts:mainfrom
Qluxzz:fix-boolean-flags-not-parsing-correctly

Conversation

@Qluxzz
Copy link

@Qluxzz Qluxzz commented Mar 17, 2026

When trying to generate a types file by having the input argument last, it is consumed by the flag since the BOOLEAN_FLAGS array items are camel cased but the arguments are kebab case, even though camel case expansion is true.

Example:
npx openapi-typescript --enum-values openapi.json

Here --enum-values treats the following openapi.json as a string value and then the input variable is never set, so we're stuck waiting for stdin.

npx openapi-typescript --enumValues openapi.json

Now we match the flag defined in the boolean flags array and openapi.json is correctly set as input rather than the value of --enum-values.

By changing the casing of all flags in the boolean flags array these are now parsed correctly as bools and the file argument is no longer treated as a string value for the previous flag.

@Qluxzz Qluxzz requested a review from a team as a code owner March 17, 2026 20:56
@Qluxzz Qluxzz requested a review from drwpow March 17, 2026 20:56
@netlify
Copy link

netlify bot commented Mar 17, 2026

👷 Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit fdd0889

@changeset-bot
Copy link

changeset-bot bot commented Mar 17, 2026

🦋 Changeset detected

Latest commit: fdd0889

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

This PR includes changesets to release 1 package
Name Type
openapi-typescript 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

@Qluxzz Qluxzz changed the title kebab-case boolean flags Fix boolean flags not being parsed as bools and thus consuming the input argument if it is given last Mar 17, 2026
@duncanbeevers
Copy link
Contributor

Seems like a decent change. Would you please add some tests capturing the old failing behavior and demonstrating the new correct behavior?

@Qluxzz
Copy link
Author

Qluxzz commented Mar 17, 2026

I've added two tests based on two existing snapshot tests which were using a kebab cased boolean flag, and swapped the order on the arguments so the input file is last in both of them.

Without the fix these tests timed out waiting for stdin and failed after we hit the timeout.

With the fix they are now generated as expected.

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