From 1d54efc3b49d76c8090a3c21e371b2531c3e9324 Mon Sep 17 00:00:00 2001 From: jpfinne Date: Wed, 8 Apr 2026 18:25:35 +0200 Subject: [PATCH 1/4] Remove findBugs if useJspecify=true --- .../resources/Java/libraries/native/build.gradle.mustache | 2 ++ .../src/main/resources/Java/libraries/native/pom.mustache | 2 ++ .../Java/libraries/resttemplate/build.gradle.mustache | 2 ++ .../main/resources/Java/libraries/resttemplate/pom.mustache | 2 ++ .../Java/libraries/webclient/build.gradle.mustache | 2 ++ .../main/resources/Java/libraries/webclient/pom.mustache | 2 ++ .../JavaSpring/libraries/spring-boot/pom-sb3.mustache | 2 ++ .../JavaSpring/libraries/spring-boot/pom-sb4.mustache | 2 ++ .../resources/JavaSpring/libraries/spring-boot/pom.mustache | 2 ++ .../JavaSpring/libraries/spring-cloud/pom-sb3.mustache | 2 ++ .../JavaSpring/libraries/spring-cloud/pom-sb4.mustache | 2 ++ .../JavaSpring/libraries/spring-cloud/pom.mustache | 2 ++ .../libraries/spring-http-interface/pom-sb3.mustache | 2 ++ .../libraries/spring-http-interface/pom-sb4.mustache | 2 ++ .../petstore/java/native-jackson3-jspecify/build.gradle | 1 - .../client/petstore/java/native-jackson3-jspecify/pom.xml | 6 ------ .../resttemplate-springBoot4-jackson3-jspecify/build.gradle | 1 - .../java/resttemplate-springBoot4-jackson3-jspecify/pom.xml | 6 ------ .../webclient-springBoot4-jackson3-jspecify/build.gradle | 1 - .../java/webclient-springBoot4-jackson3-jspecify/pom.xml | 6 ------ .../openapi3/server/petstore/springboot-4-jspecify/pom.xml | 6 ------ 21 files changed, 28 insertions(+), 27 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/build.gradle.mustache index a90feb68c85e..4c31a9b03d60 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/native/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/build.gradle.mustache @@ -110,7 +110,9 @@ dependencies { {{#swagger2AnnotationLibrary}} implementation "io.swagger.core.v3:swagger-annotations:$swagger_annotations_version" {{/swagger2AnnotationLibrary}} + {{^useJspecify}} implementation "com.google.code.findbugs:jsr305:3.0.2" + {{/useJspecify}} {{^useJackson3}} implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version" implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_annotations_version" diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache index bd6529d2e189..a0e4008cd127 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache @@ -264,12 +264,14 @@ {{/useJackson3}} + {{^useJspecify}} com.google.code.findbugs jsr305 3.0.2 + {{/useJspecify}} jakarta.annotation jakarta.annotation-api diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache index 75da5d6a4380..58f89e8c1c75 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache @@ -153,7 +153,9 @@ dependencies { {{#swagger2AnnotationLibrary}} implementation "io.swagger.core.v3:swagger-annotations:$swagger_annotations_version" {{/swagger2AnnotationLibrary}} + {{^useJspecify}} implementation "com.google.code.findbugs:jsr305:3.0.2" + {{/useJspecify}} implementation "org.springframework:spring-web:$spring_web_version" implementation "org.springframework:spring-context:$spring_web_version" implementation "{{jacksonPackage}}.core:jackson-core:$jackson_version" diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache index 15638a3f1073..20d1e24e2ffc 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache @@ -238,12 +238,14 @@ {{/swagger2AnnotationLibrary}} + {{^useJspecify}} com.google.code.findbugs jsr305 3.0.2 + {{/useJspecify}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache index 9fc8554a58df..6b5e23870ae2 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache @@ -177,7 +177,9 @@ dependencies { {{#swagger2AnnotationLibrary}} implementation "io.swagger.core.v3:swagger-annotations:$swagger_annotations_version" {{/swagger2AnnotationLibrary}} + {{^useJspecify}} implementation "com.google.code.findbugs:jsr305:3.0.2" + {{/useJspecify}} implementation "io.projectreactor:reactor-core:$reactor_version" implementation "org.springframework.boot:spring-boot-starter-webflux:$spring_boot_version" implementation "io.projectreactor.netty:reactor-netty-http:$reactor_netty_version" diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache index a36111bd4b27..913204002824 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache @@ -87,12 +87,14 @@ {{/swagger2AnnotationLibrary}} + {{^useJspecify}} com.google.code.findbugs jsr305 3.0.2 + {{/useJspecify}} io.projectreactor diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom-sb3.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom-sb3.mustache index ba77e79ec655..8a439c186300 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom-sb3.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom-sb3.mustache @@ -158,12 +158,14 @@ {{/swagger2AnnotationLibrary}} {{/springDocDocumentationProvider}} + {{^useJspecify}} com.google.code.findbugs jsr305 3.0.2 + {{/useJspecify}} {{#withXml}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom-sb4.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom-sb4.mustache index fc288bbb36c0..4df090a4a326 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom-sb4.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom-sb4.mustache @@ -162,12 +162,14 @@ {{/swagger2AnnotationLibrary}} {{/springDocDocumentationProvider}} + {{^useJspecify}} com.google.code.findbugs jsr305 3.0.2 + {{/useJspecify}} {{#withXml}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache index 4353f0eebea9..0c4fd4d0885b 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache @@ -173,12 +173,14 @@ {{/swagger2AnnotationLibrary}} {{/springDocDocumentationProvider}} + {{^useJspecify}} com.google.code.findbugs jsr305 3.0.2 + {{/useJspecify}} {{#withXml}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom-sb3.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom-sb3.mustache index b986e987c14c..66056bed0d6b 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom-sb3.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom-sb3.mustache @@ -84,6 +84,7 @@ {{/swagger2AnnotationLibrary}} {{/springDocDocumentationProvider}} + {{^useJspecify}} com.google.code.findbugs @@ -92,6 +93,7 @@ 3.0.2 {{/parentOverridden}} + {{/useJspecify}} org.springframework.cloud spring-cloud-starter-openfeign diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom-sb4.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom-sb4.mustache index 849ed1f2690f..07ac87854389 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom-sb4.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom-sb4.mustache @@ -84,6 +84,7 @@ {{/swagger2AnnotationLibrary}} {{/springDocDocumentationProvider}} + {{^useJspecify}} com.google.code.findbugs @@ -92,6 +93,7 @@ 3.0.2 {{/parentOverridden}} + {{/useJspecify}} org.springframework.cloud spring-cloud-starter-openfeign diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache index df149577d339..848e237f2c15 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache @@ -99,6 +99,7 @@ {{/swagger2AnnotationLibrary}} {{/springDocDocumentationProvider}} + {{^useJspecify}} com.google.code.findbugs @@ -107,6 +108,7 @@ 3.0.2 {{/parentOverridden}} + {{/useJspecify}} org.springframework.cloud spring-cloud-starter-openfeign diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/pom-sb3.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/pom-sb3.mustache index fa310181bfad..68178062ba09 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/pom-sb3.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/pom-sb3.mustache @@ -57,12 +57,14 @@ org.springframework.boot spring-boot-starter-{{#reactive}}webflux{{/reactive}}{{^reactive}}web{{/reactive}} + {{^useJspecify}} com.google.code.findbugs jsr305 3.0.2 + {{/useJspecify}} jakarta.validation jakarta.validation-api diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/pom-sb4.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/pom-sb4.mustache index e617a22895ac..fb8fcf58d097 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/pom-sb4.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/pom-sb4.mustache @@ -57,12 +57,14 @@ org.springframework.boot spring-boot-starter-{{#reactive}}web{{/reactive}}{{^reactive}}rest{{/reactive}}client + {{^useJspecify}} com.google.code.findbugs jsr305 3.0.2 + {{/useJspecify}} jakarta.validation jakarta.validation-api diff --git a/samples/client/petstore/java/native-jackson3-jspecify/build.gradle b/samples/client/petstore/java/native-jackson3-jspecify/build.gradle index 58d94aee437d..4c1f924fc52a 100644 --- a/samples/client/petstore/java/native-jackson3-jspecify/build.gradle +++ b/samples/client/petstore/java/native-jackson3-jspecify/build.gradle @@ -76,7 +76,6 @@ ext { } dependencies { - implementation "com.google.code.findbugs:jsr305:3.0.2" implementation "tools.jackson.core:jackson-core:$jackson3_version" implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_annotations_version" implementation "tools.jackson.core:jackson-databind:$jackson3_version" diff --git a/samples/client/petstore/java/native-jackson3-jspecify/pom.xml b/samples/client/petstore/java/native-jackson3-jspecify/pom.xml index 30fe32515588..af5d53cdf9f8 100644 --- a/samples/client/petstore/java/native-jackson3-jspecify/pom.xml +++ b/samples/client/petstore/java/native-jackson3-jspecify/pom.xml @@ -214,12 +214,6 @@ - - - com.google.code.findbugs - jsr305 - 3.0.2 - jakarta.annotation jakarta.annotation-api diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/build.gradle b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/build.gradle index e83006b43583..efa5d8534d70 100644 --- a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/build.gradle +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/build.gradle @@ -107,7 +107,6 @@ ext { } dependencies { - implementation "com.google.code.findbugs:jsr305:3.0.2" implementation "org.springframework:spring-web:$spring_web_version" implementation "org.springframework:spring-context:$spring_web_version" implementation "tools.jackson.core:jackson-core:$jackson_version" diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/pom.xml b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/pom.xml index 3b6016d9894c..8030e9225051 100644 --- a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/pom.xml +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/pom.xml @@ -210,12 +210,6 @@ - - - com.google.code.findbugs - jsr305 - 3.0.2 - diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/build.gradle b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/build.gradle index 73af50da5449..96f4f08aa55a 100644 --- a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/build.gradle +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/build.gradle @@ -123,7 +123,6 @@ ext { } dependencies { - implementation "com.google.code.findbugs:jsr305:3.0.2" implementation "io.projectreactor:reactor-core:$reactor_version" implementation "org.springframework.boot:spring-boot-starter-webflux:$spring_boot_version" implementation "io.projectreactor.netty:reactor-netty-http:$reactor_netty_version" diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/pom.xml b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/pom.xml index c17f130652e8..982043248eab 100644 --- a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/pom.xml +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/pom.xml @@ -60,12 +60,6 @@ - - - com.google.code.findbugs - jsr305 - 3.0.2 - io.projectreactor diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify/pom.xml b/samples/openapi3/server/petstore/springboot-4-jspecify/pom.xml index 3878e13fbabd..67b57a62a4b6 100644 --- a/samples/openapi3/server/petstore/springboot-4-jspecify/pom.xml +++ b/samples/openapi3/server/petstore/springboot-4-jspecify/pom.xml @@ -55,12 +55,6 @@ springdoc-openapi-starter-webmvc-ui ${springdoc.version} - - - com.google.code.findbugs - jsr305 - 3.0.2 - jakarta.xml.bind From 2b5d549bfd9d3fd2d89b6c0f8fd5d0d321709817 Mon Sep 17 00:00:00 2001 From: jpfinne Date: Wed, 8 Apr 2026 18:53:41 +0200 Subject: [PATCH 2/4] Add unit tests --- .../codegen/java/JavaClientCodegenTest.java | 6 ++- .../java/spring/SpringCodegenTest.java | 40 ++++++++++++++----- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java index 5935b2e61aa0..5f6d74952baf 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java @@ -4269,12 +4269,14 @@ public void testJspecify(String library, boolean useSpringBoot4, boolean hasJspe if (hasJspecifyDependency) { assertThat(files.get("build.gradle")).content() - .contains("implementation \"org.jspecify:jspecify:1.0.0\""); + .contains("implementation \"org.jspecify:jspecify:1.0.0\"") + .doesNotContain("findbugs"); assertThat(files.get("pom.xml")).content() .contains( "org.jspecify", "jspecify", - "1.0.0"); + "1.0.0") + .doesNotContain("findbugs"); } else { assertThat(files.get("build.gradle")).content() .doesNotContain("org.jspecify"); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java index e9eacdc92c36..0c94e6aa1258 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java @@ -62,6 +62,7 @@ import static org.openapitools.codegen.TestUtils.*; import static org.openapitools.codegen.languages.AbstractJavaCodegen.GENERATE_BUILDERS; import static org.openapitools.codegen.languages.AbstractJavaCodegen.GENERATE_CONSTRUCTOR_WITH_ALL_ARGS; +import static org.openapitools.codegen.languages.JavaClientCodegen.USE_SPRING_BOOT4; import static org.openapitools.codegen.languages.SpringCodegen.*; import static org.openapitools.codegen.languages.features.DocumentationProviderFeatures.ANNOTATION_LIBRARY; import static org.openapitools.codegen.languages.features.DocumentationProviderFeatures.DOCUMENTATION_PROVIDER; @@ -6606,31 +6607,50 @@ public void shouldNotHaveDocumentationAnnotationWhenUsingLibrarySpringHttpInterf .assertMethod("addPet").assertParameter("pet").assertParameterAnnotations().doesNotContainWithName("Parameter"); } - @Test - public void testJspecify() throws IOException { - final Map files = generateFromContract("src/test/resources/3_0/java/jspecify.yaml", SPRING_BOOT, + @DataProvider(name = "jspecifyLibraries") + public Object[][] jspecifyLibraries() { + return new Object[][]{ + {SPRING_BOOT, false, "FooApi.java"}, + {SPRING_BOOT, true, "FooApi.java"}, + {SPRING_CLOUD_LIBRARY, false, "FooApi.java"}, + {SPRING_CLOUD_LIBRARY, true, "FooApi.java"}, + {SPRING_HTTP_INTERFACE, true, "DefaultApi.java"} + }; + } + + @Test(dataProvider = "jspecifyLibraries") + public void testJspecify(String library, boolean useSpringBoot4, String fooApiFilename) throws IOException { + final Map files = generateFromContract("src/test/resources/3_0/java/jspecify.yaml", library, Map.of(USE_JSPECIFY, true, "containerDefaultToNull", true, "openApiNullable", false, USE_BEANVALIDATION, true, - USE_SPRING_BOOT3, false + USE_SPRING_BOOT3, !useSpringBoot4, + USE_SPRING_BOOT4, useSpringBoot4 ), codegenConfigurator -> codegenConfigurator .addTypeMapping("OffsetDateTime", "java.time.Instant")); - assertThat(files.get("pom.xml")).content() - .contains( - "org.jspecify", - "jspecify", - "1.0.0"); + if (useSpringBoot4) { + assertThat(files.get("pom.xml")).content() + .doesNotContain("jspecify") + .doesNotContain("findbugs"); + } else { + assertThat(files.get("pom.xml")).content() + .contains( + "org.jspecify", + "jspecify", + "1.0.0") + .doesNotContain("findbugs"); + } JavaFileAssert.assertThat(files.get("Foo.java")) .fileContains( "private java.time.@Nullable Instant dt;", "private org.springframework.core.io.@Nullable Resource binary", "setBinary(org.springframework.core.io.@Nullable Resource binary)" ); - JavaFileAssert.assertThat(files.get("FooApi.java")) + JavaFileAssert.assertThat(files.get(fooApiFilename)) .fileContains( "java.time.@Nullable Instant dtParam", "java.time.@Nullable Instant dtQuery", From 40396733714e671e2b0189e990f4dfce795519bf Mon Sep 17 00:00:00 2001 From: jpfinne Date: Wed, 8 Apr 2026 19:27:58 +0200 Subject: [PATCH 3/4] Improve formatting --- .../src/main/resources/Java/libraries/native/pom.mustache | 2 +- .../main/resources/Java/libraries/resttemplate/pom.mustache | 4 ++-- .../src/main/resources/Java/libraries/webclient/pom.mustache | 4 ++-- samples/client/petstore/java/native-jackson3-jspecify/pom.xml | 1 - .../java/resttemplate-springBoot4-jackson3-jspecify/pom.xml | 2 -- .../java/webclient-springBoot4-jackson3-jspecify/pom.xml | 2 -- 6 files changed, 5 insertions(+), 10 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache index a0e4008cd127..def5d8a1c914 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache @@ -263,8 +263,8 @@ {{/useJackson3}} - {{^useJspecify}} + com.google.code.findbugs diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache index 20d1e24e2ffc..ad2532db6d42 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache @@ -237,16 +237,16 @@ ${swagger-annotations-version} {{/swagger2AnnotationLibrary}} - {{^useJspecify}} + com.google.code.findbugs jsr305 3.0.2 - {{/useJspecify}} + {{/useJspecify}} org.springframework diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache index 913204002824..72e304865408 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache @@ -86,16 +86,16 @@ ${swagger-annotations-version} {{/swagger2AnnotationLibrary}} - {{^useJspecify}} + com.google.code.findbugs jsr305 3.0.2 - {{/useJspecify}} + {{/useJspecify}} io.projectreactor reactor-core diff --git a/samples/client/petstore/java/native-jackson3-jspecify/pom.xml b/samples/client/petstore/java/native-jackson3-jspecify/pom.xml index af5d53cdf9f8..12373cb5a80a 100644 --- a/samples/client/petstore/java/native-jackson3-jspecify/pom.xml +++ b/samples/client/petstore/java/native-jackson3-jspecify/pom.xml @@ -213,7 +213,6 @@ - jakarta.annotation jakarta.annotation-api diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/pom.xml b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/pom.xml index 8030e9225051..0df13fe9e0c0 100644 --- a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/pom.xml +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/pom.xml @@ -209,8 +209,6 @@ - - org.springframework diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/pom.xml b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/pom.xml index 982043248eab..cd5b03bf6356 100644 --- a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/pom.xml +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/pom.xml @@ -59,8 +59,6 @@ - - io.projectreactor reactor-core From 703b39809d9813fd3a69380e712686a53f287d22 Mon Sep 17 00:00:00 2001 From: jpfinne Date: Wed, 8 Apr 2026 20:15:19 +0200 Subject: [PATCH 4/4] Test spring-boot 2, 3 and 4 --- .../java/spring/SpringCodegenTest.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java index 0c94e6aa1258..96444d9aee77 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java @@ -6610,29 +6610,32 @@ public void shouldNotHaveDocumentationAnnotationWhenUsingLibrarySpringHttpInterf @DataProvider(name = "jspecifyLibraries") public Object[][] jspecifyLibraries() { return new Object[][]{ - {SPRING_BOOT, false, "FooApi.java"}, - {SPRING_BOOT, true, "FooApi.java"}, - {SPRING_CLOUD_LIBRARY, false, "FooApi.java"}, - {SPRING_CLOUD_LIBRARY, true, "FooApi.java"}, - {SPRING_HTTP_INTERFACE, true, "DefaultApi.java"} + {SPRING_BOOT, 2, "FooApi.java"}, + {SPRING_BOOT, 3, "FooApi.java"}, + {SPRING_BOOT, 4, "FooApi.java"}, + {SPRING_CLOUD_LIBRARY, 2, "FooApi.java"}, + {SPRING_CLOUD_LIBRARY, 3, "FooApi.java"}, + {SPRING_CLOUD_LIBRARY, 4, "FooApi.java"}, + {SPRING_HTTP_INTERFACE, 3, "DefaultApi.java"}, + {SPRING_HTTP_INTERFACE, 4, "DefaultApi.java"} }; } @Test(dataProvider = "jspecifyLibraries") - public void testJspecify(String library, boolean useSpringBoot4, String fooApiFilename) throws IOException { + public void testJspecify(String library, int springBootVersion, String fooApiFilename) throws IOException { + String springVersionProperty = springBootVersion == 4? USE_SPRING_BOOT4: USE_SPRING_BOOT3; final Map files = generateFromContract("src/test/resources/3_0/java/jspecify.yaml", library, Map.of(USE_JSPECIFY, true, - "containerDefaultToNull", true, - "openApiNullable", false, + CONTAINER_DEFAULT_TO_NULL, true, + OPENAPI_NULLABLE, false, USE_BEANVALIDATION, true, - USE_SPRING_BOOT3, !useSpringBoot4, - USE_SPRING_BOOT4, useSpringBoot4 + springVersionProperty, springBootVersion > 2 ), codegenConfigurator -> codegenConfigurator .addTypeMapping("OffsetDateTime", "java.time.Instant")); - if (useSpringBoot4) { + if (springBootVersion == 4) { assertThat(files.get("pom.xml")).content() .doesNotContain("jspecify") .doesNotContain("findbugs");