使用Swagger Editor,我为我的API创建了一个规范。我看到Swagger在其Swagger编辑器中还提供了“生成客户端”选项(可能使用Swagger Codegen)。
[我想生成一个客户端并在我的React应用程序(使用create-react-app创建)中使用它,并且最好享受一些静态键入功能(当前使用flow)。
Swagger编辑器中的所有选项似乎都不起作用:
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)
]选项与js不兼容,我不必知道如何/想要将TypeScript添加到我的项目中。typescript-*
选项当然是不相关的。*-angular
文件并将其转换为.ts
。怎么样??flow
文件添加到我的项目中。当前不起作用,因为生成的代码带有其自己的依赖项。.js
吗?)。怎么样??谢谢
有一个简单的解决方案,直到生成器退出使用动态实现,例如flow
为止