Skip to content

Fix swagger enum#3223

Merged
LordofAvernus merged 2 commits intomainfrom
fix_swagger_enum
Mar 25, 2026
Merged

Fix swagger enum#3223
LordofAvernus merged 2 commits intomainfrom
fix_swagger_enum

Conversation

@iwanghc
Copy link
Copy Markdown
Collaborator

@iwanghc iwanghc commented Mar 25, 2026

User description

关联的 issue

https://github.com/actiontech/sqle-ee/issues/2656

描述你的变更

修复枚举状态对应错误,新增一个字段表示调优记录状态

确认项(pr提交后操作)

Tip

请在指定复审人之前,确认并完成以下事项,完成后✅


  • 我已完成自测
  • 我已记录完整日志方便进行诊断
  • 我已在关联的issue里补充了实现方案
  • 我已在关联的issue里补充了测试影响面
  • 我已确认了变更的兼容性,如果不兼容则在issue里标记 not_compatible
  • 我已确认了是否要更新文档,如果要更新则在issue里标记 need_update_doc


Description

  • 更新 OptimizationSQLDetail 结构体中 Status 枚举

  • 添加新的 OptimizeStatus 字段及其枚举定义

  • 同步修改 swagger 文档及 JSON/YAML 定义


Diagram Walkthrough

flowchart LR
  A["优化详情结构更新"]
  B["更新 Status 枚举"]
  C["新增 OptimizeStatus 字段"]
  D["文档同步更新"]
  A -- "修改" --> B
  A -- "增加" --> C
  D -- "更新" --> A
Loading

File Walkthrough

Relevant files
Enhancement
optimization.go
更新优化详情数据结构                                                                                             

sqle/api/controller/v2/optimization.go

  • 修改 Status 字段枚举列表
  • 添加 OptimizeStatus 字段及枚举
+3/-2     
Documentation
docs.go
更新 API 文档定义                                                                                           

sqle/docs/docs.go

  • 新增 optimize_status 定义
  • 更新 status 枚举选项
+15/-3   
swagger.json
更新 Swagger JSON 定义                                                                             

sqle/docs/swagger.json

  • 修改 JSON 中 status 枚举选项
  • 新增 optimize_status 字段定义
+15/-3   
swagger.yaml
更新 Swagger YAML 定义                                                                             

sqle/docs/swagger.yaml

  • 添加 optimize_status 字段定义
  • 修改 YAML 中 status 枚举选项
+12/-2   

@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

🎫 Ticket compliance analysis 🔶

2656 - Partially compliant

Compliant requirements:

  • 更新枚举状态
  • 新增字段
  • 同步更新文档

Non-compliant requirements:

[]

Requires further human verification:

[]

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
添加字段安全处理


建议检查OptimizeStatus字段在业务逻辑中的初始化和使用,确保在访问该字段时不会出现空值导致的未初始化问题。请在相关逻辑中增加必要的空值判断或提供默认值,防止潜在的panic风险。

sqle/api/controller/v2/optimization.go [134-136]

 Status         string `json:"status" enums:"rewriting,rewrite_done,advise_indexing,advise_index_done,finish,failed"` // SQLe 维护的状态
 StatusDetail   string `json:"status_detail"`                                                                         // SQLe 维护的状态详情
-OptimizeStatus string `json:"optimize_status" enums:"optimizing,failed,finish"`                                      // 优化状态
+OptimizeStatus string `json:"optimize_status" enums:"optimizing,failed,finish"`                                      // 优化状态,应确保已初始化或有默认值
Suggestion importance[1-10]: 5

__

Why: The suggestion recommends adding a safety check for the OptimizeStatus field to avoid nil issues, which is valid but a minor runtime safety addition without changing the structure.

Low
General
保证文档一致性

建议确认文档中optimize_status字段与代码中的定义保持完全一致,同时增加提示信息,明确说明各状态含义。这样可以避免前后端由于定义不一致而产生理解错误。

sqle/docs/docs.go [23698-23706]

 "optimize_status": {
-                "description": "优化状态",
+                "description": "优化状态,与代码保持一致",
                 "type": "string",
                 "enum": [
                     "optimizing",
                     "failed",
                     "finish"
                 ]
             },
Suggestion importance[1-10]: 4

__

Why: This suggestion improves clarity by updating the description for the optimize_status field, ensuring alignment with code, but it only affects documentation.

Low
完善 Swagger 描述

建议在 Swagger YAML
中为optimize_status字段添加更详细的描述,明确各状态的具体含义,并确保枚举定义与后端代码一致。这样可以提高API文档的准确性和可读性。

sqle/docs/swagger.yaml [7184-7190]

 optimize_status:
-    description: 优化状态
+    description: 优化状态,与后端逻辑保持一致
+    type: string
     enum:
-    - optimizing
-    - failed
-    - finish
-    type: string
+      - optimizing
+      - failed
+      - finish
Suggestion importance[1-10]: 4

__

Why: The recommendation to add more detail in the description aligns the Swagger doc with backend logic, yet the change is minor and only enhances documentation clarity.

Low

@LordofAvernus LordofAvernus merged commit a22dc8b into main Mar 25, 2026
4 checks passed
@iwanghc iwanghc deleted the fix_swagger_enum branch March 25, 2026 10:02
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

Successfully merging this pull request may close these issues.

2 participants