Skip to content

[CLI] Hangs when Options (-/-- flags) are out-of-order #2523

@devBaunz

Description

@devBaunz

openapi-typescript version

7.10.1

Node.js version

24.7.0

OS + version

macOS 15.6.1

Description

This unfortunately burned way too much of my time to manually stick debug prints and find out how the parsing works.
When providing flags such as --array-length as the first parameters, the CLI will interpret them as part of the schema-file instead of flags and just hang during the resolution under this code:

  if (schema instanceof node_stream.Readable) {
    const contents = await new Promise((resolve) => {
      schema.resume();
      schema.setEncoding("utf8");
      let content = "";
      schema.on("data", (chunk) => {
        content += chunk;
      });
      schema.on("end", () => {
        resolve(content.trim());
      });
    });

Reproduction

Run any flag such as --array-length before providing the schema

DEBUG=* npx openapi-typescript --array-length ./openapi.json -o ./generated-api.d.ts

Expected result

Parse flags using a CLI library such as yargs OR validate a minimal startswith("-") to alert user of how to use

Required

  • My OpenAPI schema is valid and passes the Redocly validator (npx @redocly/cli@latest lint)

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopenapi-tsRelevant to the openapi-typescript library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions