Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@ protected boolean applyBeanValidatorAnnotations(Schema property, Annotation[] an
}
}

if (annos.containsKey("javax.validation.constraints.NotEmpty")) {
if (annos.containsKey("javax.validation.constraints.NotEmpty") && applyNotNullAnnotations ) {
NotEmpty anno = (NotEmpty) annos.get("javax.validation.constraints.NotEmpty");
boolean apply = checkGroupValidation(anno.groups(), invocationGroups, acceptNoGroups);
if (apply) {
Expand All @@ -1829,7 +1829,7 @@ protected boolean applyBeanValidatorAnnotations(Schema property, Annotation[] an
}
}

if (annos.containsKey("javax.validation.constraints.NotBlank")) {
if (annos.containsKey("javax.validation.constraints.NotBlank") && applyNotNullAnnotations ) {
NotBlank anno = (NotBlank) annos.get("javax.validation.constraints.NotBlank");
boolean apply = checkGroupValidation(anno.groups(), invocationGroups, acceptNoGroups);
if (apply) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public void testRequiredProperty() {
assertTrue(model.getRequired().contains("modeRequired"));
assertFalse(model.getRequired().contains("modeNotRequired"));
assertFalse(model.getRequired().contains("modeNotRequiredWithAnnotation"));
assertFalse(model.getRequired().contains("modeNotRequiredWithAnnotationForNotBlank"));
assertFalse(model.getRequired().contains("modeNotRequiredWithAnnotationForNotEmpty"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import io.swagger.v3.oas.annotations.media.Schema;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;

import java.util.List;

public class RequiredFields {
@Schema(description = "required", required = true)
Expand Down Expand Up @@ -31,4 +35,12 @@ public class RequiredFields {
@Schema(description = "mode not required with annotation", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@NotNull
public Long modeNotRequiredWithAnnotation;

@Schema(description = "mode not required with annotation for NotBlank", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@NotBlank
public String modeNotRequiredWithAnnotationForNotBlank;

@Schema(description = "mode not required with annotation for NotEmpty", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@NotEmpty
public List<String> modeNotRequiredWithAnnotationForNotEmpty;
}