OpenAPITools / OpenAPITools/openapi-generator-cli
Reading of config not working with yarn on Windows
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- TypeScript
- Estrellas
- 2k
- Forks
- 208
- Merge medio
- 7 h 12 min
- PR fusionados (30 d)
- 6
Descripción
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
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comience reproduciendo yarn openapi-generator-cli generate desde la raíz del proyecto en Windows Server 2016 con CLI 2.4.26; después, inspeccione la búsqueda de la raíz de configuración que usa process.env.PWD. Compárela con process.env.INIT_CWD y process.cwd() y verifique que openapitools.json se encuentre y que se use la versión del generador configurada en él bajo Yarn, sin cambiar el comportamiento de npm.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- nodejs, openapi, typescript
- Área
- backend, cli
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100