Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-cli-kebab-flag-order.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"openapi-typescript": patch
---

Fix CLI hanging when multi-word flags appear before the schema file argument. Flags such as `--enum-values`, `--path-params-as-types`, `--dedupe-enums`, `--empty-objects-unknown`, and others were not recognized as boolean by the argument parser when written in kebab-case, causing the schema path to be silently consumed as the flag's value and leaving the CLI waiting on stdin. Both camelCase and kebab-case forms are now registered as boolean.
8 changes: 7 additions & 1 deletion packages/openapi-typescript/bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,14 @@ const BOOLEAN_FLAGS = [
"rootTypesNoSchemaPrefix",
];

// yargs-parser only recognizes boolean flags by their exact registered name,
// so --enum-values (kebab-case) is not treated as boolean unless "enum-values"
// is also in the boolean list. Generate kebab-case equivalents so positional
// args after multi-word flags aren't silently consumed as flag values.
const BOOLEAN_FLAGS_KEBAB = BOOLEAN_FLAGS.map((f) => f.replace(/([A-Z])/g, (c) => `-${c.toLowerCase()}`));

const flags = parser(args, {
boolean: BOOLEAN_FLAGS,
boolean: [...BOOLEAN_FLAGS, ...BOOLEAN_FLAGS_KEBAB],
string: ["output", "redocly"],
alias: {
redocly: ["c"],
Expand Down
Loading