OpenAPITools / OpenAPITools/openapi-generator-cli

[BUG] Error when working with npm workspaces

Offen
#605 1 Kommentar 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@kay-schecker arbeitet bereits daran.

Seit 30.1.2022.

bug
Vorherrschende Sprache
TypeScript
Sterne
2k
Forks
208
Ø Merge
7 Std. 12 Min.
Gemergte PRs (30 T.)
6

Beschreibung

🐛 Bug Report:

Describe the bug

The generator crashes with the [error] Required option '-i' is missing error when running with different cwd.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create a npm project with two workspaces: packages/client and packages/server (server probably isn't even necessary)
  2. Save a spec in packages/openapi.yaml
  3. Reference it in packages/client/openapitools.json via "inputSpec": "../openapi.yaml"
  4. Add a script in client: "openapi": "openapi-generator-cli generate" and run it
    • It works ✔️
  5. Add a script in root "openapi": "npm run openapi --workspaces --if-present" and run it
    • See error ❌
    • Generates a openapitools.json in the root directory
Failing workaround

I created a packages/client/openapi.js script and let it run in client via "openapi": "node openapi.js" , but this also fails in the same way.

// try forcing the cwd to the client directory (works when checking with pwd command)
const child = require('child_process').exec('openapi-generator-cli generate', { cwd: __dirname });
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
child.on('exit', code => process.exit(code));
Expected behavior

I expect the generator to always find the file.

Operation System:
  • OS: Windows
  • Version 10
Package System:
  • npm v8.3.0

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.