- 
                Notifications
    
You must be signed in to change notification settings  - Fork 253
 
Description
Thank you so much for this project! I hope this project could have an additional feature.
非常感谢你的这个项目!我希望这个项目能新增一个功能。
Currently, the tool supports the five standard CRUD interfaces (GET one, GET list, POST, PUT, DELETE, etc.) following RESTful conventions, but lacks support for the PATCH method.
目前,该工具支持符合 RESTful 规范的五种标准 CRUD 接口(GET one、GET list、POST、PUT、DELETE 等),但缺少对 PATCH 方法的支持。
For nullable field in database: When handling PATCH requests, it's often necessary to accurately distinguish between two operations from the frontend for a specific field: one is explicitly passing null to set the field to null; the other is not passing the field at all (in which case the original value of the field should be retained). However, implementing this judgment in Go involves cumbersome logic handling.
Currently, I usually solve this in two ways: sometimes using the JSON Patch specification, and sometimes relying on the library https://github.com/oapi-codegen/nullable. But either way, additional logic needs to be written for adaptation each time, which consumes a lot of development time. It would greatly improve development efficiency and reduce repetitive work if there were tools to support automatic generation for this scenario
对于数据库中值可能为null的字段来说:在处理 PATCH 请求时,经常需要准确区分前端对某个字段的两种操作:一是明确传递了 null 希望将字段设为 null;二是完全未传递该字段(此时应保留字段原有值)。但在 Go 中实现这种判断逻辑处理起来比较繁琐。
目前我通常会采用两种方式解决:有时使用 JSON Patch 规范来处理,有时借助 https://github.com/oapi-codegen/nullable 这个库。但无论哪种方式,每次都需要编写额外的逻辑来适配,这会消耗大量开发时间。如果能有工具支持这一场景的自动生成,将会极大提升开发效率,减少重复劳动。
Describe the solution you'd likeI hope the tool can be enhanced to automatically generate PATCH interface code for partial updates, following these specifications:
HTTP Method: PATCH
Endpoint: Consistent with the resource's detail route (e.g., /api/resources/{id})
Logic: Only update the fields explicitly provided in the request body, leaving other existing fields unchanged.
Code Generation: Automatically generate corresponding controller methods, request validation rules (validating only provided fields), and documentation (e.g., API comments indicating it’s for partial updates).
希望工具能增强对局部更新的支持,自动生成 PATCH 接口代码,具体规范如下:
HTTP 方法:PATCH
端点:与资源的详情路由一致(如/api/resources/{id})
逻辑:仅更新请求体中明确提供的字段,保留其他现有字段不变
代码生成:自动生成对应的控制器方法、请求验证规则(仅验证提供的字段)及文档(如标注为局部更新的 API 注释)