gpt4 book ai didi

java - OpenAPI validator 规则使用 max 而不是 size

转载 作者:行者123 更新时间:2023-12-02 09:44:58 25 4
gpt4 key购买 nike

我的合约描述符中有以下模型

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com