OpenAPITools / OpenAPITools/openapi-generator-cli

Reading of config not working with yarn on Windows

Aperta
#624 0 commenti 3 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

When running openapi-generator-cli generate with yarn (with the below defined script from package.json) it will ignore my openapitools.json, but it works if npm run is used instead. The effect of this is that different team members can get different versions of the cli.

This issue seems to be related to how the root of the project is fetched to find the config file, depending on if yarn or npm is used. In the case of yarn it will get a path like /d/{my_project_path} and after using path.resolve on the path the resulting config file path will be D:\d\{my_project_path}, which will not work of course.

I have tracked the problem to this issue and this commit where the added default process.env.PWD will generate the above issue, while process.env.INIT_CWD and process.cwd() would have given a correct path. After removing process.env.PWD from the node_modules instance the config is read correctly in yarn.

Is this to be considered a bug? Or does it exist a work around other than using npm instead of yarn?

openapitools.json:

{
  "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "5.4.0"
  }
}

package.json (exerpt):

"scripts": {
 "generate": "openapi-generator-cli generate --input-spec ./swagger.json --generator-name typescript-fetch  --output ./output  --additional-properties modelPropertyNaming=original,typescriptThreePlus=true",
}
  • command: yarn openapi-generator-cli generate in project root
  • CLI version: 2.4.26
  • yarn: 1.22.4
  • node: 14.19.0
  • OS: Windows server 2016

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.

Direzione di ricerca

Inizia riproducendo yarn openapi-generator-cli generate dalla radice del progetto su Windows Server 2016 con CLI 2.4.26, quindi esamina la ricerca della radice della configurazione che usa process.env.PWD. Confrontala con process.env.INIT_CWD e process.cwd() e verifica che openapitools.json venga trovato e che venga usata la versione del generatore configurata al suo interno con Yarn, senza modificare il comportamento di npm.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
nodejs, openapi, typescript
Ambito
backend, cli
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.