Springfox Java Bean 验证未在 Swagger 输出中显示验证组

Springfox Java Bean Validations not displaying Validation Groups in Swagger Output

我有一个 spring 启动应用程序,我已经在其中实现了 JSR 验证组。

@Size(max=100, groups = {SomeGroup.class})
@Size(max=50, groups = {SomeOtherGroup1.class,SomeOtherGroup2.class})
private String someString;

我试图让这些组反映在我的 API 文档中,但没有成功。我目前正在使用 springfox 3.0。 springfox 有办法做到这一点吗?如果没有,是否有其他文档框架可以处理显示哪些组需要字段?

提前致谢, 布莱恩

我写了一个类似于这里的 ModelPropertyBuilderPlugin:https://github.com/springfox/springfox/issues/2739

我的 swagger 页面现在显示类似于:

example: someString
x-1-validation-type-Size: groups: SomeGroup | other attributes: min: 0, max: 100
x-2-validation-type-Size: groups: SomeOtherGroup1, SomeOtherGroup2 | other attributes: min: 0, max: 50

description of someString

正在创建 springfox.documentation.service.VendorExtension 的列表,然后如下设置。

context.getSpecificationBuilder().vendorExtensions(extensions);
context.getBuilder().extensions(extensions);