相关疑难解决方法(0)

Swagger / OpenAPI API规范的Reactjs客户端

背景

使用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文件添加到我的项目中。当前不起作用,因为生成的代码带有其自己的依赖项。
  • 将TypeScript添加到我的项目中(我应该替换掉flow吗?)。怎么样??

谢谢

swagger typescript reactjs flowtype swagger-codegen

5
推荐指数
1
解决办法
1505
查看次数

标签 统计

flowtype ×1

reactjs ×1

swagger ×1

swagger-codegen ×1

typescript ×1