Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

期望能透传“@umijs/openapi”的参数GenerateServiceProps来实现更灵活的代码生成 #19

Open
HongKing opened this issue Aug 7, 2024 · 0 comments

Comments

@HongKing
Copy link

HongKing commented Aug 7, 2024

当前的参数属性“IConfigFromPluginsJoi”只有部分“@umijs/openapi”属性可进行配置,期望将GenerateServiceProps的参数都能透传到config.ts的openAPI中配置
需求背景:

  1. 准备用自定义的模板生成service,需参数:templatesFolder
  2. 准备按自定义的目录生成mock文件,需参数:mockFolder
  3. 准备按自定义的方式对path分组输出到不同文件,需参数:hook.customFileNames

目前执行npm run openapi后的目录现状

|-mock
|  |-currentUser.mock.ts
|  |-getFakeCaptcha.mock.ts
|  
|-src
|   |-service
|       |- projectName
|            |- api.ts
|            |- login.ts
|            |- index.ts
|            |- typings.d.ts

可以看出,mock文件是按operationId命名的,相当于一个方法一个文件,且没有放到projectName下,这对于一个系统好几百个接口,就有问题了,不好排查,service文件是按照tags做了分组,一个项目的在一个目录下,对于微服务架构的后台,这种方式是可以的,但对于单体服务,就不太合适了,所以希望这里能再灵活一些。

期望效果

  1. mock的文件命名及目录的生成规则能同service,这样查找和使用也方便
  2. service目前按projectName和tags做的分组是可以的,希望能再扩充一下,在projectName后面增加二级目录的自定义,如对paths做截取处理来生成二级目录
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant