Oleh Kurpiak
Oleh Kurpiak

Reputation: 1369

OpenAPI validator rules to use max instead of size

I have following model in my contract descriptor

BaseGroup:
      type: object
      properties:
        name:
          type: string
          pattern: '^\p{Alnum}+$'
          maxLength: 50

which generates

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;
  }
...
}

is it possible somehow configure openapi generator to use @Max instead of @Size for length check?

I use this maven plugin to generate DTOs

<plugin>
  <groupId>org.openapitools</groupId>               
  <artifactId>openapi-generator-maven-plugin</artifactId>
  <version>3.3.4</version>
</plugin>

Upvotes: 0

Views: 1198

Answers (1)

Willem
Willem

Reputation: 1060

With the javax validation @max means max value not the max size

Upvotes: 1

Related Questions