javascript react app fails to compile with generated openapi-client

Viewed 80

I've created a React App (written in js) and now I want to add an openapi client which is generated via SwaggerCodegen but it fails to compile.

I've generated the client for js via:

docker run -it -v "$(pwd):/specs" swaggerapi/swagger-codegen-cli-v3 generate -i /specs/myapi.json -o /specs/myapi-client -l javascript

In the generated Readme it says, that you can push the generated client code to a git repository and add it as a dependency from there, which I've done via npm install <me>/<my-repo> --save. But now when I run npm start as before, I get the following error:

Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation. If you want to leave it as-is, add @babel/plugin-syntax-class-properties (https://git.io/vb4yQ) to the 'plugins' section to enable parsing.

So I tried exactly this. In different forums they described, that you have to add to your package.json something like the following and have to install the @babel/plugin-proposal-class-properties.

"babel": {
   "presets": [
      "@babel/preset-env",
      "@babel/preset-react"
      ],
   "plugins": [
      "@babel/plugin-proposal-class-properties"
      ]
}

I also tried to work with a babel.config.js file and I added the option {"loose": true} to the plugins-section. But whatever I tried - the error during the compiling stayed.

How can I fix this compilation error to get the client to work in my react frontend?

0 Answers
Related