Description
Hopefully this is the correct library to handle this issue; I was referred here from springdoc/springdoc-openapi#2337 -- apologies if I got it wrong.
Using a simple DTO can reproduce this issue:
@Data
static class RequestDto {
@Size(min = 1, max = 5)
@Schema(description = "List of values.")
private List<String> values;
}
The @Size
validation is only (correctly) applied to the list size. However, the api spec itself is showing this:
Essentially, the API spec is stating that:
- the list must be between 1 and 5 elements (correct);
- the length of the string of each element must be between 1 and 5 characters (incorrect)
You can also see that the description is also being duplicated from the array down to the element as well. I am uncertain if this is intentional and or desirable so not sure if that should also be considered a bug as well.
Note that the actual runtime validation is only applied to point1 above (correct behavior IMO).
Point2 is not enforced by the validator at runtime even though the generated API spec is indicating that the string should be between 1 and 5 characters in length.
This also just started occurring when we updated springdoc-openapi-starter-webmvc-ui to 2.2.0 (from 2.1.0).