1

I am using the OpenAPI Generator https://openapi-generator.tech/ for generating clients and servers as listed in the OpenApi generator list https://openapi-generator.tech/docs/generators.

I have installed openapi-generator-cli using npm i.e. $ npm install @openapitools/openapi-generator-cli -g.

Output on terminal:

/usr/local/bin/openapi-generator -> /usr/local/lib/node_modules/@openapitools/openapi-generator-cli/bin/openapi-generator /usr/local/lib └── @openapitools/[email protected]

However, after I am trying to generate a ruby client from a valid petstore.yaml doc:

$ openapi-generator generate -i petstore.yaml -g ruby -o /tmp/test/

I keep getting an error:

/usr/local/lib/node_modules/@openapitools/openapi-generator-cli/bin/openapi-generator:3
const {spawn} = require('child_process');
      ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3

PS! I've $ npm -v version 3.5.2 and $ nodejs -v version v4.2.6.

Any insight into this issue?

Thanks & looking forward.

1 Answer 1

2

I actually solved the issue and the error was due to the npm & nodejs version.

Previsouly, I had $npm -v version 3.5.2 and $ nodejs -v version v4.2.6. .

But after I pull node-v12.18.3 source code from https://nodejs.org/en/download/ and install it from source using:

cd ~/node-v12.18.3
./configure
make -j 4
sudo make install

And then I have installed openapi-generator-cli using npm i.e. $ npm install @openapitools/openapi-generator-cli -g. And finally, I can generate a ruby client from a valid petstore.yaml doc using:

openapi-generator generate -i petstore.yaml -g ruby -o /tmp/test/
arslan@arslan:/tmp/test$ ls
docs  Gemfile  git_push.sh  lib  openapi_client.gemspec  Rakefile  README.md  spec

PS! After compiling node-v12.18.3 from source It show up $ npm -v 6.14.6 $ node -v v12.18.3.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.