swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Invalid items validation with @ArraySchema with implementation

Open istibekesi opened this issue 1 year ago • 0 comments

Describe the bug

Using @ArraySchema annotation on a field with implementation parameter generates invalid openapi schema.

To Reproduce

public enum MyEnum {
    red,
    green
}

public enum MyOtherEnum {
    green,
    blue
}

@ArraySchema(schema = @Schema(implementation = MyOtherEnum.class))
@Size(min = 1, max = 3)
private List<MyEnum> setOfEnums;

Generated result:

"setOfEnums" : {
  "maxItems" : 3,
  "minItems" : 1,
  "type" : "array",
  "items" : {
    "maxLength" : 3,
    "minLength" : 1,
    "type" : "string",
    "enum" : [ "green", "blue" ]
  }
}

Expected behavior

"setOfEnums" : {
  "maxItems" : 3,
  "minItems" : 1,
  "type" : "array",
  "items" : {
    "type" : "string",
    "enum" : [ "green", "blue" ]
  }
}

istibekesi avatar Oct 16 '24 11:10 istibekesi