0

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>
Grokify
  • 15,092
  • 6
  • 60
  • 81
Oleh Kurpiak
  • 1,339
  • 14
  • 34
  • Related: [Difference between @size(max = value) and @min(value) @max(value)](https://stackoverflow.com/q/11189398/113116) – Helen Jun 24 '19 at 10:54

1 Answers1

1

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

Willem
  • 992
  • 6
  • 13