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

alova 插件接口,可否独立生成枚举文件 #22

Open
ByteXiong opened this issue Aug 15, 2024 · 1 comment
Open

alova 插件接口,可否独立生成枚举文件 #22

ByteXiong opened this issue Aug 15, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@ByteXiong
Copy link

在实际开发中 OpenApi 文件生成的枚举 不能直观的用到,容易混淆
插件生成
export type RoleTypeEnum = 10 | 20 | 30 | 40;
希望达到的效果
export enum RoleTypeEnum {
系统角色 = 10,
公司角色 = 20,
部门角色 = 30,
个人角色 = 40,
}

在业务中
if (RoleTypeEnum.系统角色 == info.value.type)

提高代码复用率, 精确锁定引用

我的解决思路:
1.独立一个新的枚举
2.规定代码格式
3.alova.config.ts 是否更新排除枚举文件

@czhlin czhlin added the enhancement New feature or request label Aug 16, 2024
@czhlin
Copy link
Contributor

czhlin commented Aug 16, 2024

我看可以使用一个external字段排除要生成的类型,顶部导入语句可以用户配置。
不过需要$ref符合命名规范,比如:$ref:"#/components/schemas/AddDeptParam"。而不是“#/components/schemas/你好_xxx”。然后exteranl就可以配置["AddDeptParam" ],externalImport:"import {AddDeptParam} from "./foo/xxxx.ts""

@czhlin czhlin self-assigned this Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants