I'm trying to generate as swagger es6
client for my react
application but I'm running into the following babel
error:
SyntaxError: /path/to/petstore/src/ApiClient.js: Support for the experimental syntax 'classProperties' isn't currently enabled (231:33):
The steps I've taken to reach this point:
- install
swagger-codegen@2
using homebrew - generate swagger client using
swagger-codegen generate -i http://petstore.swagger.io/v2/swagger.json -l javascript -o ./petstore --additional-properties usePromises=true,useES6=true
- added to
import { PetApi } from '../../../../petstore/src';
My application'ss package.json
contains the following:
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.5.5",
"ajv": "^6.10.2",
"babel": "^6.23.0",
"fuzzysort": "^1.1.4",
"immutability-helper": "^3.0.0",
"lodash": "^4.17.11",
"moment": "^2.24.0",
"moment-timezone": "^0.5.25",
"normalizr": "^3.4.0",
"prop-types-defined": "^15.6.0",
"react": "^16.8.6",
"react-redux": "^7.1.0",
"react-scripts": "3.0.1",
"redux": "^4.0.1",
"redux-mock-store": "^1.5.3",
"redux-persist": "^5.10.0",
"redux-testkit": "^1.0.6",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"superagent": "^5.1.0"
},
"devDependencies": {}
My application's babel.config.js
:
module.exports = {
presets: [
'module:metro-react-native-babel-preset'
],
plugins: [
[
'@babel/plugin-proposal-class-properties',
{
'loose': true
}
]
]
};
I have also tried wiping my node_modules
and reinstalling them with yarn
I have tried going through all the swagger generated files and changing class properties to functions, which leads me to another error:
TypeError: _petstore_src__WEBPACK_IMPORTED_MODULE_5__.PetApi.getPetByIdWithHttpInfo is not a function
when I attempt to run PetApi.getPetByIdWithHttpInfo(1)
Let me know if any extra information is required.
Thanks