qinxh
qinxh
enable_distinct_file设置 false 试试
> [@qinxh](https://github.com/qinxh) yapi只支持在request/response的json body中设置长度,不支持在参数上设置。如果你是在POJO类上注解jakarta.validation.constraints.Size,那你可以尝试在Preferences(Settings) > Remote里加上 https://raw.githubusercontent.com/tangcent/easy-yapi/master/third/javax.validation.config 试试 测试了没有效果,包括手动增加配置文件也没有效果,不知道是不是不支持jakarta相关注解,仅支持javax下面的。目前配置如下: 在项目根目录增加配置文件:.easy.api.config 简化配置如下: # rules for jakarta.validation # jakarta.validation.constraints.Size field.advanced[@jakarta.validation.constraints.Size]=groovy:``` return [maxLength:111] ``` 实际测试同步到Yapi后,没有设置最大长度,抓包测试,调用save接口的请求确实也没有maxLength的设置。
测试代码: ``` @RequiredArgsConstructor @RequestMapping(Routing.PREFIX + "user") @RestController public class UserController { /** * 创建新用户 * 通过POST请求体传入用户信息 */ @PostMapping("/add") public UserInfo add(@Validated @RequestBody UserInfo userInfo) { return userInfo; } public static...
运行后,同步了add接口:  UserInfo增加了Size:  依然没有效果,没有同步配置 maxLength 我基于自己的项目,也写个简单的demo项目试试 @tangcent
@tangcent 我也做了一个demo项目:https://github.com/qinxh/easy-api-demo/tree/master 麻烦试试同步一下:https://github.com/qinxh/easy-api-demo/blob/master/service/service-admin/src/main/java/service/admin/controller/UserController.java 我这同步后没有最大长度,IDEA版本是 IDEA 2025.1.2 (Ultimate Edition)
日志内容如下,确实不行,set maxLength of 的日志也没有输出,你的IDEA什么版本,要不要我降级试试 ``` [TRACE] found config file:C:\temp\easy-api-demo\.easy.api.config [INFO] search api from: host.server.controller.DemoController [INFO] search api from: service.admin.controller.UserController [INFO] call:http://api.hjsoft.lo/api/project/get?token=cb280942fab6ed4b8d83a3e5054cd9a9a7760fc370c0364993ffbb2d8f77b392 [INFO] body:null [INFO] call:http://api.hjsoft.lo/api/project/get?token=cb280942fab6ed4b8d83a3e5054cd9a9a7760fc370c0364993ffbb2d8f77b392&id=123 [INFO] body:null [INFO] call:http://api.hjsoft.lo/api/interface/list_cat?token=cb280942fab6ed4b8d83a3e5054cd9a9a7760fc370c0364993ffbb2d8f77b392&catid=880&limit=1000 [INFO]...
@tangcent 一样的版本,奇怪了,没有maxLength,和前端协作太不便了。  
@tangcent 日志输出和之前一样,没有新加的配置输出日志
@tangcent 好的,感谢支持,等有空我自己打包源码试试
@tangcent 同步下排查情况,目前通过源码自己打包的插件。YapiPsiClassHelper中增加的日志并没有输出,但是尝试在CustomizedPsiClassHelper中增加日志,试正常输出的。只能有空继续解读源码尝试了。