feat: add configurable operationId generation strategy#1132
feat: add configurable operationId generation strategy#1132acpplife wants to merge 1 commit intoTongchengOpenSource:masterfrom
Conversation
- Add OperationIdStrategyEnum with three strategies: METHOD_NAME, METHOD_ID, PATH_METHOD_HTTP - Add operationIdStrategy configuration option in ApiConfig - Update OpenApiBuilder to support multiple operationId generation patterns - Maintain backward compatibility with METHOD_NAME as default This allows users to choose different operationId formats in smart-doc.json configuration file.
|
🔍 Before proceeding, please review the contribution guidelines This includes requirements for:
Thanks for your PR. 🙏 In addition, if you have added new features, please provide example code in the repository smart-doc-group/smart-doc-example-cn. This will help other users understand how to use the new features. Code Style Reminder: 🔍 提交前请务必完成以下检查 需特别注意:
感谢您提交的PR。 🙏 另外,如果您添加了新功能,请在仓库smart-doc-group/smart-doc-example-cn中提供示例代码。这将帮助其他用户了解如何使用新功能。 代码风格提示: |
|
Hi @acpplife thanks for your contribution! Before we can review and merge this PR, could you please follow the guidelines outlined in the CONTRIBUTING.md file? Specifically:
Once these changes are made, let us know and we'll continue with the review. Looking forward to your updates! 你好 @acpplife ,感谢你的贡献! 在我们能够继续审查和合并这个 PR 之前,请你按照项目中的 CONTRIBUTING.md 文件中的指南进行调整。具体包括:
修改完成后欢迎继续更新此 PR,我们会继续跟进审核。 期待你的更新! |
Summary
This PR adds a configurable operationId generation strategy to allow users to choose different formats for
operationId in the generated OpenAPI documentation.
Motivation
After commit b279aa6, the operationId was changed from methodId (e.g.,
athena-machine-getGuarderToken-POST)to method name only (e.g.,
openRoomAndUploadNextSection). This PR provides a configuration option to supportmultiple strategies.
Changes
OperationIdStrategyEnumwith three strategies:METHOD_NAME: Use the method name only (default, with duplicate handling)METHOD_ID: Use the methodId (MD5 hash)PATH_METHOD_HTTP: Use path + method name + HTTP method typeoperationIdStrategyconfiguration field inApiConfigOpenApiBuilderto implement the strategy logicMETHOD_NAMEas defaultUsage Example
In
smart-doc.json:{ "operationIdStrategy": "PATH_METHOD_HTTP" } Examples - METHOD_NAME: getUserInfo or getUserInfo_1 for duplicates - METHOD_ID: user-controller-getUserInfo-1-a1b2c3d4e5f6 - PATH_METHOD_HTTP: api-users-updateProfile-POST