umi icon indicating copy to clipboard operation
umi copied to clipboard

[Feature Request] openapi生成api是否可以分目录

Open csshidi opened this issue 1 year ago • 3 comments

Background

所有type都在一个文件typing.d.ts,请求实体通常比较多,不好维护

Proposal

能否分目录生成实体表单

Additional context

现在就像这样,所有请求实体都在一个文件里面 typescript declare namespace API { type deleteUsingDELETEParams = { id: number; };

type getParams = { id: number; };

type listParams = { name?: string; };

type Login = { account: string; password: string; };

type ModifyPassword = { oldPassword: string; newPassword: string; confirmPassword: string; };

type pageParams = { name?: string; pageNum?: number; pageSize?: number; };

type PageVO = { pageNum?: number; pageSize?: number; total?: number; pages?: number; list?: Record<string, any>[]; }; / type R = { code?: number; message?: string; data?: Record<string, any>; };

type updateParams = { id: number; };

type User = { account: string; name: string; }; }

csshidi avatar Mar 19 '23 12:03 csshidi

什么样的场景下需要维护这个数据, 这个数据不是通过协议生成的吗 看了下 没有提供分目录的能力, 可以给 openapi2typescript 贡献或者提 feature 推动支持

  • https://github.com/chenshuai2144/openapi2typescript
  • https://github.com/umijs/umi-presets-pro/tree/master/packages/max-plugin-openapi

xierenyuan avatar Mar 21 '23 11:03 xierenyuan

请教openapi的配置文件,我尝试了不成功

ngto avatar Mar 28 '23 12:03 ngto

请教openapi的配置文件,我尝试了不成功

我步骤如下:

  1. 创建项目 pnpm dlx create-umi@latest demo,我选择的是Ant Design Pro模板
  2. 安装并在.umirc.ts开启@umijs/max-plugin-openapi插件 pnpm i @umijs/max-plugin-openapi image
  3. 在package.json中添加项目名称 name: 'demo'
  4. 在umirc.ts中添加api生成配置文件 image
  5. package.json配置script image

运行pnpm api即可生成

csshidi avatar Mar 28 '23 13:03 csshidi