[Bug]: @Size without min drops the minimum set by @NotEmpty or @NotBlank

Author: AdzerKICreated Sep 30, 2026Updated Oct 1, 2026
Labelsbacklog

Description of the problem/issue

@NotEmpty or @NotBlank combined with a @Size that only sets max loses the minimum in the generated schema:

java
@NotEmpty
@Size(max = 10)
private List<String> items;   // minItems: 0, maxItems: 10

@NotBlank
@Size(max = 20)
private String name;          // minLength: 0, maxLength: 20

ModelResolver applies @NotEmpty / @NotBlank first (minimum 1), then ValidationAnnotationsUtils.applySizeConstraint overwrites the minimum with @Size.min(), which defaults to 0. Clients generated from the spec then accept an empty list or string that the server rejects.

Affected Version

2.2.55, same code on master.

Steps to Reproduce

  1. Put the two fields above on a model.
  2. ModelConverters.getInstance().readAll(Model.class) (springdoc shows the same).

Expected Behavior

items: minItems: 1, maxItems: 10; name: minLength: 1, maxLength: 20.

Actual Behavior

minItems: 0 and minLength: 0.

Additional Context

@NotEmpty @Size(min = 3, max = 10) already gives 3, so the fix is to keep the larger of the existing and the new minimum in the size and not-empty rules. PR follows.

Checklist

  • I have searched the existing issues and this is not a duplicate.
  • I have provided sufficient information for maintainers to reproduce the issue.

Source: swagger-api/swagger-core