我正在记录一个 api,但在 swagger web 中加载时添加了一些代码。 我正在 Eclipse 中使用 swagger 的适当注释编写我的 api,例如:
@ApiModelProperty(value = "Account number", example = "3507898", position = 3)
@Min(17)
@Max(9999999)
@NotNull
private Integer accountNumber;
但是当在 eclipse 中运行我的 java 应用程序并在 swagger 中加载文档时,它显示:
accountNumber integer($int32)
example: 3507898
minimum: 17
maximum: 9999999
exclusiveMinimum: false
exclusiveMaximum: false
Account number
那个 ExclusiveMinimum/exclusiveMaximum 从哪里来???为什么它是自己生成的?使用最小值和最大值时是否必须使用 ExclusiveMinimum/exclusiveMaximum?
希望有人能帮忙。 谢谢
阿莱霍
最佳答案
要排除边界值,
指定
exclusiveMinimum: true
和 exclusiveMaximum: true
对于上面的代码,它表示 accountNumber
可以具有从 17
到 9999999
的值。
虽然它不是强制属性,并且默认情况下带有 @Min
和 @Max
,但最小值和最大值包含在范围内,即
exclusiveMinimum: false
和 exclusiveMaximum: false
我希望这能回答你的问题
关于java - API 文档 Swagger 中遗漏添加了 ExclusiveMaximum 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61776710/