swagger-codegen react client-实验语法'classProperties'错误

Art*_*hur 6 babel swagger ecmascript-6 reactjs swagger-codegen

我正在尝试es6react应用程序生成swagger 客户端,但是遇到以下babel错误:

SyntaxError: /path/to/petstore/src/ApiClient.js: Support for the experimental syntax 'classProperties' isn't currently enabled (231:33):
Run Code Online (Sandbox Code Playgroud)

我为达到这一点而采取的步骤:

  1. swagger-codegen@2使用自制软件安装
  2. 使用生成生成器 swagger-codegen generate -i http://petstore.swagger.io/v2/swagger.json -l javascript -o ./petstore --additional-properties usePromises=true,useES6=true
  3. 添加到import { PetApi } from '../../../../petstore/src';

我的应用程序package.json包含以下内容:

    "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": {}
Run Code Online (Sandbox Code Playgroud)

我的应用程序是babel.config.js

module.exports = {
    presets: [
        'module:metro-react-native-babel-preset'
    ],
    plugins: [
        [
            '@babel/plugin-proposal-class-properties',
            {
                'loose': true
            }
        ]
    ]
};
Run Code Online (Sandbox Code Playgroud)

我也尝试过擦拭node_modules并重新安装yarn

我尝试遍历所有不可靠的文件并将类属性更改为函数,这导致我遇到另一个错误:

TypeError: _petstore_src__WEBPACK_IMPORTED_MODULE_5__.PetApi.getPetByIdWithHttpInfo is not a function
Run Code Online (Sandbox Code Playgroud)

当我尝试跑步时 PetApi.getPetByIdWithHttpInfo(1)

让我知道是否需要其他信息。

谢谢