thim81 / openapi-format

Format an OpenAPI document by ordering, formatting and filtering fields.
MIT License
79 stars 14 forks source link

Node 12 Support broken #21

Closed BerniWittmann closed 2 years ago

BerniWittmann commented 2 years ago

With commit https://github.com/thim81/openapi-format/commit/56713e7e7be7309937b21b8a42c3d2c19036ab52 this library started using more modern language features.

This causes problems when running the library on node 12

Reproduction:

# set node version 12
nvm use 12
# download petstore example
curl https://petstore3.swagger.io/api/v3/openapi.json --output ./tmp/docs-json 
# use library to convert
npx openapi-format ./tmp/docs-json

This result in the Error: Unexpected token '.' (To be exact bin/cli.js:143 cliLog.unusedComp = resFilter?.resultData?.unusedComp;

Doing the above on node 14 works flawlessly.

I would advise to specify the engines option in package.json and then install a compiler like Babel or sth. similar for easy compatibility with older node versions

In the meantime the workaround is to use node 14

thim81 commented 2 years ago

@BerniWittmann

Thank you for reporting the issue. I was not aware.

I m no expert in Babel, so that is why I m trying to use simple JavaScript.

I ll see what I can do to fix the issue: or try Babel or replace the optional chaining with plain chained if.

thim81 commented 2 years ago

@BerniWittmann

In the 1.6.4 release of openapi-format, NodeJS 12 should be supported and the package is set to require minimum nodejs 12 to prevent future unclarity.

BerniWittmann commented 2 years ago

@thim81 Awesome, thank you very much. Especially thanks for the quick response 👍

thim81 commented 2 years ago

@BerniWittmann Based on your feedback, we can make the package more stable, so thank you for taking the time to provide the feedback.