使用Swagger Editor,我为我的API创建了一个规范。我看到Swagger在其Swagger编辑器中还提供了“生成客户端”选项(可能使用Swagger Codegen)。
我想生成一个客户端并在我的React应用程序(通过create-react-app创建)中使用它,并且最好享受一些静态类型输入功能(当前使用flow)。
Swagger Editor中的所有选项似乎都不起作用:
javascript-提供了所需的香草节点模块npm install作为项目的依赖项。现在,不仅没有任何类/类型,而且还失败了:
Uncaught Error: Cannot find module "ApiClient"
at webpackMissingModule (index.js:17)
at exports.ApiClient (index.js:17)
at Object.<anonymous> (index.js:22)
at __webpack_require__ (bootstrap 75f547b…:555)
at fn (bootstrap 75f547b…:86)
at new Index (index.js:87)
at ReactCompositeComponent.js:295
at measureLifeCyclePerf (ReactCompositeComponent.js:75)
at ReactCompositeComponentWrapper._constructComponentWithoutOwner (ReactCompositeComponent.js:294)
at ReactCompositeComponentWrapper._constructComponent (ReactCompositeComponent.js:280)
typescript-* 选项与js不兼容,我不必知道如何/想要将TypeScript添加到我的项目中。*-angular 选项当然是无关紧要的。.ts文件并将其隐藏到flow。怎么样??.js文件添加到我的项目中。当前不起作用,因为生成的代码带有其自己的依赖项。flow吗?)。怎么样??谢谢