🎯 feat: Add customRenderTemplateData hook for fine-grained file generation control#511
Merged
rookie-luochao merged 7 commits intoopenapi-ui:mainfrom Sep 30, 2025
Merged
🎯 feat: Add customRenderTemplateData hook for fine-grained file generation control#511rookie-luochao merged 7 commits intoopenapi-ui:mainfrom
rookie-luochao merged 7 commits intoopenapi-ui:mainfrom
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 |
Member
rookie-luochao
left a comment
There was a problem hiding this comment.
good job, 但是下面的细节需要调整一下:
customGenFileFromTemplateList =》customRenderTemplateData 这些命名都需要调整一下
| 'openapi-ts-request': minor | ||
| --- | ||
|
|
||
| Added customGenFileFromTemplateList hook functionality |
Member
There was a problem hiding this comment.
feat: Added customRenderTemplateData hook functionality
|
|
||
| // 根据不同的文件类型调用相应的 hook 函数 | ||
| switch (type) { | ||
| case 'serviceController': |
Member
There was a problem hiding this comment.
case TypescriptFileType.serviceController
| try { | ||
| const template = this.getTemplate(type); | ||
|
|
||
| // 应用 customGenFileFromTemplateList hook (如果存在) |
Member
There was a problem hiding this comment.
hook命名调整一下:customRenderTemplateData
This was referenced Sep 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 概述
新增
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: 无新增依赖