OpenAPITools / OpenAPITools/openapi-generator-cli

[BUG] Error when working with npm workspaces

Aperta
#605 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@kay-schecker ci sta già lavorando.

Dal 30/1/2022.

bug
Lingua principale
TypeScript
Stelle
2k
Fork
208
Merge medio
7h 12m
PR unite (30g)
6

Descrizione

🐛 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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.