我的合约描述符中有以下模型
BaseGroup:
type: object
properties:
name:
type: string
pattern: '^\p{Alnum}+$'
maxLength: 50
生成
public class BaseGroupDto {
@JsonProperty("name")
private String name;
/**
* Get name
* @return name
*/
@ApiModelProperty(required = true, value = "")
@NotNull
@Pattern(regexp="^\\p{Alnum}+$")
@Size(max=50)
public String getName() {
return name;
}
...
}
是否可以以某种方式配置 openapi 生成器以使用 @Max
而不是 @Size
进行长度检查?
我使用这个maven插件来生成DTO
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>3.3.4</version>
</plugin>
最佳答案
使用javax验证@max意味着最大值而不是最大大小
关于java - OpenAPI validator 规则使用 max 而不是 size,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56734922/