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..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,6 +263,7 @@
{{/useJackson3}}
+ {{^useJspecify}}
@@ -270,6 +271,7 @@
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..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,6 +237,7 @@
${swagger-annotations-version}
{{/swagger2AnnotationLibrary}}
+ {{^useJspecify}}
@@ -245,6 +246,7 @@
3.0.2
+ {{/useJspecify}}
org.springframework
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..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,6 +86,7 @@
${swagger-annotations-version}
{{/swagger2AnnotationLibrary}}
+ {{^useJspecify}}
@@ -94,6 +95,7 @@
3.0.2
+ {{/useJspecify}}
io.projectreactor
reactor-core
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/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..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
@@ -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,53 @@ 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, 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, 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, false
+ springVersionProperty, springBootVersion > 2
),
codegenConfigurator ->
codegenConfigurator
.addTypeMapping("OffsetDateTime", "java.time.Instant"));
- assertThat(files.get("pom.xml")).content()
- .contains(
- "org.jspecify",
- "jspecify",
- "1.0.0");
+ if (springBootVersion == 4) {
+ 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",
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..12373cb5a80a 100644
--- a/samples/client/petstore/java/native-jackson3-jspecify/pom.xml
+++ b/samples/client/petstore/java/native-jackson3-jspecify/pom.xml
@@ -213,13 +213,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..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,14 +209,6 @@
-
-
-
- com.google.code.findbugs
- jsr305
- 3.0.2
-
-
org.springframework
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..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,14 +59,6 @@
-
-
-
- com.google.code.findbugs
- jsr305
- 3.0.2
-
-
io.projectreactor
reactor-core
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