fmvilas / swagger-node-codegen

An OpenAPI 3.x/Swagger 2 code generator for Node.js
Apache License 2.0
200 stars 55 forks source link

Error on update of openapi spec #33

Closed BradCrumb closed 6 years ago

BradCrumb commented 6 years ago

When I update my openapi.json (or yml) with for example an extra endpoint the codegen fails on existing files.

In my opinion the library has to overwrite existing files and has to ignore files according to an ignore file.

The library now simply fails with an error:

Aaww 💩. Something went wrong:
Error: File /app/.editorconfig exists.
    at copyHelper (/app/node_modules/fs.extra/fs.copy.js:22:19)
    at FSReqWrap.oncomplete (fs.js:153:5)
fmvilas commented 6 years ago

Yes, this was done on purpose to prevent the code generator to overwrite your code and lose it. What might makes more sense is to add a flag so you can specify that you want files to be overwritten. Would you like to create a PR?

BradCrumb commented 6 years ago

Just analyzed the code. We have todo a lot of refactoring because of copyRecursive doesn't support an overwrite option. I think we have to extend this method with our own implementation.

fmvilas commented 6 years ago

@BradCrumb sorry for the late response. I'm not going to maintain this package for so long anymore. You might want to try out this package https://github.com/fmvilas/openapi3-generator. It should suit your needs and doesn't perform a copyRecursive anymore.

Usage example:

og -o ./my-api openapi.yaml express