OpenAPITools / OpenAPITools/openapi-generator-cli
Reading of config not working with yarn on Windows
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 2k
- Forks
- 208
- Ø Merge
- 7 Std. 12 Min.
- Gemergte PRs (30 T.)
- 6
Beschreibung
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 generatein project root - CLI version:
2.4.26 - yarn:
1.22.4 - node:
14.19.0 - OS:
Windows server 2016
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie damit, yarn openapi-generator-cli generate aus dem Projektstammverzeichnis unter Windows Server 2016 mit CLI 2.4.26 zu reproduzieren. Untersuchen Sie anschließend die Suche nach der Konfigurationswurzel, die process.env.PWD verwendet. Vergleichen Sie sie mit process.env.INIT_CWD und process.cwd() und verifizieren Sie, dass openapitools.json gefunden und die darin konfigurierte Generatorversion unter Yarn verwendet wird, ohne das npm-Verhalten zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- nodejs, openapi, typescript
- Bereich
- backend, cli
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100