Swagger默认情况下会显示所有枚举值作为可用值。如果您希望某些枚举值在Swagger中不可见,可以使用@ApiModelProperty注解来指定可见的枚举值。

例如,假设有一个名为Status的枚举类,其中包含ACTIVEINACTIVEDELETED三个枚举值。如果您只希望在Swagger中显示ACTIVEINACTIVE,则可以在Status枚举中添加@ApiModelProperty注解并设置hidden = true,如下所示:

public enum Status {
    @ApiModelProperty(hidden = true)
    DELETED,
    ACTIVE,
    INACTIVE
}

这样,Swagger将只显示ACTIVEINACTIVE作为可用值。

请注意,使用@ApiModelProperty注解需要导入io.swagger.annotations.ApiModelProperty类。


原文地址: http://www.cveoy.top/t/topic/jgEr 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录