diff --git a/.changeset/flat-bugs-type.md b/.changeset/flat-bugs-type.md new file mode 100644 index 000000000..390d1d3dd --- /dev/null +++ b/.changeset/flat-bugs-type.md @@ -0,0 +1,5 @@ +--- +"openapi-typescript": patch +--- + +Fix boolean flags not being parsed as bools and thus consuming the input argument if it is given last diff --git a/packages/openapi-typescript/bin/cli.js b/packages/openapi-typescript/bin/cli.js index 31be6e795..d3395ff01 100755 --- a/packages/openapi-typescript/bin/cli.js +++ b/packages/openapi-typescript/bin/cli.js @@ -73,29 +73,29 @@ if (args.includes("--root-types-keep-casing") && !args.includes("--root-types")) } const BOOLEAN_FLAGS = [ - "additionalProperties", + "additional-properties", "alphabetize", - "arrayLength", + "array-length", "check", - "conditionalEnums", - "contentNever", - "dedupeEnums", - "defaultNonNullable", - "emptyObjectsUnknown", + "conditional-enums", + "content-never", + "dedupe-enums", + "default-non-nullable", + "empty-objects-unknown", "enum", - "enumValues", - "excludeDeprecated", - "exportType", - "generatePathParams", + "enum-values", + "exclude-deprecated", + "export-type", + "generate-path-params", "help", "immutable", - "makePathsEnum", - "pathParamsAsTypes", - "propertiesRequiredByDefault", - "readWriteMarkers", - "rootTypes", - "rootTypesKeepCasing", - "rootTypesNoSchemaPrefix", + "make-paths-enum", + "path-params-as-types", + "properties-required-by-default", + "read-write-markers", + "root-types", + "root-types-keep-casing", + "root-types-no-schema-prefix", ]; const flags = parser(args, { diff --git a/packages/openapi-typescript/test/cli.test.ts b/packages/openapi-typescript/test/cli.test.ts index b61aed0d5..f6941f258 100644 --- a/packages/openapi-typescript/test/cli.test.ts +++ b/packages/openapi-typescript/test/cli.test.ts @@ -44,6 +44,14 @@ describe("CLI", () => { ci: { timeout: TIMEOUT }, }, ], + [ + "snapshot > GitHub API (root types, input file last)", + { + given: ["--root-types", "./examples/github-api.yaml"], + want: new URL("./examples/github-api-root-types.ts", root), + ci: { timeout: TIMEOUT }, + }, + ], [ "snapshot > GitHub API (next)", { @@ -84,6 +92,14 @@ describe("CLI", () => { ci: { timeout: TIMEOUT }, }, ], + [ + "snapshot > enum root types filtering, input file last", + { + given: ["--root-types", "--enum", "--root-types-no-schema-prefix", "./examples/enum-root-types.yaml"], + want: new URL("./examples/enum-root-types.ts", root), + ci: { timeout: TIMEOUT }, + }, + ], ]; for (const [testName, { given, want, ci }] of tests) {