Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,15 @@
<!-- Note: jackson-datatype-jsr310 is included in jackson-databind for Jackson 3 -->
<!-- Note: jackson-databind-nullable is not yet available for Jackson 3 -->
{{/useJackson3}}
{{^useJspecify}}

<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
{{/useJspecify}}
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
<version>${swagger-annotations-version}</version>
</dependency>
{{/swagger2AnnotationLibrary}}
{{^useJspecify}}

<!-- @Nullable annotation -->
<dependency>
Expand All @@ -245,6 +246,7 @@
<version>3.0.2</version>
</dependency>

{{/useJspecify}}
<!-- HTTP client: Spring RestTemplate -->
<dependency>
<groupId>org.springframework</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<version>${swagger-annotations-version}</version>
</dependency>
{{/swagger2AnnotationLibrary}}
{{^useJspecify}}

<!-- @Nullable annotation -->
<dependency>
Expand All @@ -94,6 +95,7 @@
<version>3.0.2</version>
</dependency>

{{/useJspecify}}
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,14 @@
</dependency>
{{/swagger2AnnotationLibrary}}
{{/springDocDocumentationProvider}}
{{^useJspecify}}
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
{{/useJspecify}}
{{#withXml}}
<!-- XML processing: Jackson -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,14 @@
</dependency>
{{/swagger2AnnotationLibrary}}
{{/springDocDocumentationProvider}}
{{^useJspecify}}
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
{{/useJspecify}}
{{#withXml}}
<!-- XML processing: Jackson -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,14 @@
</dependency>
{{/swagger2AnnotationLibrary}}
{{/springDocDocumentationProvider}}
{{^useJspecify}}
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
{{/useJspecify}}
{{#withXml}}
<!-- XML processing: Jackson -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
</dependency>
{{/swagger2AnnotationLibrary}}
{{/springDocDocumentationProvider}}
{{^useJspecify}}
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
Expand All @@ -92,6 +93,7 @@
<version>3.0.2</version>
{{/parentOverridden}}
</dependency>
{{/useJspecify}}
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
</dependency>
{{/swagger2AnnotationLibrary}}
{{/springDocDocumentationProvider}}
{{^useJspecify}}
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: pom-sb4.mustache removes jsr305 when useJspecify=true but never adds the jspecify dependency, unlike other Spring Cloud templates. This can leave generated projects missing the annotation library when jspecify annotations are emitted.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom-sb4.mustache, line 87:

<comment>pom-sb4.mustache removes jsr305 when useJspecify=true but never adds the jspecify dependency, unlike other Spring Cloud templates. This can leave generated projects missing the annotation library when jspecify annotations are emitted.</comment>

<file context>
@@ -84,6 +84,7 @@
         </dependency>
         {{/swagger2AnnotationLibrary}}
         {{/springDocDocumentationProvider}}
+        {{^useJspecify}}
         <!-- @Nullable annotation -->
         <dependency>
</file context>
Fix with Cubic

<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
Expand All @@ -92,6 +93,7 @@
<version>3.0.2</version>
{{/parentOverridden}}
</dependency>
{{/useJspecify}}
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
</dependency>
{{/swagger2AnnotationLibrary}}
{{/springDocDocumentationProvider}}
{{^useJspecify}}
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
Expand All @@ -107,6 +108,7 @@
<version>3.0.2</version>
{{/parentOverridden}}
</dependency>
{{/useJspecify}}
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-{{#reactive}}webflux{{/reactive}}{{^reactive}}web{{/reactive}}</artifactId>
</dependency>
{{^useJspecify}}
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
{{/useJspecify}}
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-{{#reactive}}web{{/reactive}}{{^reactive}}rest{{/reactive}}client</artifactId>
</dependency>
{{^useJspecify}}
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
{{/useJspecify}}
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"<groupId>org.jspecify</groupId>",
"<artifactId>jspecify</artifactId>",
"<version>1.0.0</version>");
"<version>1.0.0</version>")
.doesNotContain("findbugs");
} else {
assertThat(files.get("build.gradle")).content()
.doesNotContain("org.jspecify");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -6606,31 +6607,50 @@ public void shouldNotHaveDocumentationAnnotationWhenUsingLibrarySpringHttpInterf
.assertMethod("addPet").assertParameter("pet").assertParameterAnnotations().doesNotContainWithName("Parameter");
}

@Test
public void testJspecify() throws IOException {
final Map<String, File> 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<String, File> 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,
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
USE_SPRING_BOOT4, useSpringBoot4
),
codegenConfigurator ->
codegenConfigurator
.addTypeMapping("OffsetDateTime", "java.time.Instant"));

assertThat(files.get("pom.xml")).content()
.contains(
"<groupId>org.jspecify</groupId>",
"<artifactId>jspecify</artifactId>",
"<version>1.0.0</version>");
if (useSpringBoot4) {
assertThat(files.get("pom.xml")).content()
.doesNotContain("jspecify")
.doesNotContain("findbugs");
} else {
assertThat(files.get("pom.xml")).content()
.contains(
"<groupId>org.jspecify</groupId>",
"<artifactId>jspecify</artifactId>",
"<version>1.0.0</version>")
.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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 0 additions & 7 deletions samples/client/petstore/java/native-jackson3-jspecify/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,6 @@
</dependency>
<!-- Note: jackson-datatype-jsr310 is included in jackson-databind for Jackson 3 -->
<!-- Note: jackson-databind-nullable is not yet available for Jackson 3 -->

<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,6 @@
</profiles>

<dependencies>

<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>

<!-- HTTP client: Spring RestTemplate -->
<dependency>
<groupId>org.springframework</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@
</build>

<dependencies>

<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>

<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>${springdoc.version}</version>
</dependency>
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<!-- XML processing: Jackson -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
Expand Down
Loading