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
Open
Conversation
👷 Deploy request for openapi-ts pending review.Visit the deploys page to approve it
|
🦋 Changeset detectedLatest commit: fdd0889 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Contributor
|
Seems like a decent change. Would you please add some tests capturing the old failing behavior and demonstrating the new correct behavior? |
Author
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When trying to generate a types file by having the input argument last, it is consumed by the flag since the
BOOLEAN_FLAGSarray items are camel cased but the arguments are kebab case, even though camel case expansion is true.Example:
npx openapi-typescript --enum-values openapi.jsonHere --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.jsonNow 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.