-
Notifications
You must be signed in to change notification settings - Fork 56
🎯 feat: Add customRenderTemplateData hook for fine-grained file generation control #511
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
Conversation
🦋 Changeset detectedLatest commit: 1d1fda8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
rookie-luochao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job, 但是下面的细节需要调整一下:
customGenFileFromTemplateList =》customRenderTemplateData 这些命名都需要调整一下
.changeset/common-corners-walk.md
Outdated
| 'openapi-ts-request': minor | ||
| --- | ||
|
|
||
| Added customGenFileFromTemplateList hook functionality |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feat: Added customRenderTemplateData hook functionality
src/generator/serviceGenarator.ts
Outdated
|
|
||
| // 根据不同的文件类型调用相应的 hook 函数 | ||
| switch (type) { | ||
| case 'serviceController': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case TypescriptFileType.serviceController
src/generator/serviceGenarator.ts
Outdated
| try { | ||
| const template = this.getTemplate(type); | ||
|
|
||
| // 应用 customGenFileFromTemplateList hook (如果存在) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hook命名调整一下:customRenderTemplateData
📋 概述
新增
customRenderTemplateDatahook 功能,允许用户在模板渲染前对genFileFromTemplate方法的list参数进行自定义处理,为不同文件类型提供精细化控制能力。✨ 功能特性
🔧 主要变更
核心实现文件
src/index.tscustomRenderTemplateDatahook 类型定义ControllerType,ISchemaItem)src/generator/serviceGenarator.tsgenFileFromTemplate方法中实现 hook 调用逻辑测试文件
test/customRenderTemplateData.spec.tstest/example-files/openapi-custom-gen-file-list-hook.json文档更新
README.md&README-en_US.md🎯 支持的文件类型
serviceControllerAPIDataType[]interfaceITypeItem[]displayEnumLabelITypeItem[]displayTypeLabelITypeItem[]schemaISchemaItem[]serviceIndexControllerType[]reactQueryAPIDataType[]💡 使用示例
🧪 测试覆盖
测试结果: 12 个测试用例全部通过,生成 12 个快照文件
🔄 向后兼容性
📚 相关文档
🎉 使用场景
这个功能特别适用于以下场景:
Breaking Changes: 无
Migration Required: 无
Dependencies: 无新增依赖