@@ -10442,6 +10442,34 @@ public void useRecordsWithoutOpenApiNullable() throws IOException {
1044210442 .doesNotContain("JsonNullable", "if (nickname == null)");
1044310443 }
1044410444
10445+ @Test
10446+ public void useRecordsWithoutBeanValidationHasNoNotNullAnnotationNorImport_issue23751() throws IOException {
10447+ Map<String, File> files = generateRecords(RECORDS_SPEC, Map.of(SpringCodegen.USE_BEANVALIDATION, "false"));
10448+
10449+ assertSource(files, "Pet.java")
10450+ .contains("public record Pet(", "String name,")
10451+ .doesNotContain("@NotNull", "@Size", "validation.constraints");
10452+ assertSource(files, "Owner.java")
10453+ .doesNotContain("@NotNull", "validation.constraints");
10454+ }
10455+
10456+ @Test
10457+ public void useRecordsWithoutBeanValidationHasNoRequiredNullableMarker_issue23751() throws IOException {
10458+ Map<String, File> files = generateRecords(RECORDS_FIELDS_SPEC, Map.of(SpringCodegen.USE_BEANVALIDATION, "false"));
10459+
10460+ assertSource(files, "Defaults.java")
10461+ .contains("public record Defaults(", "JsonNullable<String> reqNullable,")
10462+ .doesNotContain("@NotNull", "@Present", "validation.constraints");
10463+ }
10464+
10465+ @Test
10466+ public void useRecordsWithBeanValidationKeepsNotNullAndItsImport() throws IOException {
10467+ Map<String, File> files = generateRecords(RECORDS_SPEC, Map.of(SpringCodegen.USE_BEANVALIDATION, "true"));
10468+
10469+ assertSource(files, "Pet.java")
10470+ .contains("@NotNull @Size(min = 2)", "import jakarta.validation.constraints.*;");
10471+ }
10472+
1044510473 @Test
1044610474 public void useRecordsHasOnlyTheCanonicalConstructor() throws IOException {
1044710475 for (Map<String, Object> options : List.<Map<String, Object>>of(
0 commit comments