Skip to content

@Size annotation on List<String> causes incorrect openapi spec to be generated. #2337

Closed
@caspianb

Description

@caspianb

Using a simple DTO can reproduce this issue:

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:
image

The generated 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions