openapi-typescript
openapi-typescript copied to clipboard
[CLI] Hangs when Options (-/-- flags) are out-of-order
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
- [x] My OpenAPI schema is valid and passes the Redocly validator (
npx @redocly/cli@latest lint)
Extra
- [x] I’m willing to open a PR (see CONTRIBUTING.md)