Skip to content

Commit 4a5f3a7

Browse files
authored
[java] honor useJspecify in restclient/webclient ApiClient support class (#24055)
The restclient and webclient ApiClient support classes hardcoded 'import {javaxPackage}.annotation.Nullable;' regardless of useJspecify, so generated clients used org.jspecify everywhere except ApiClient, which kept jakarta/javax. Guard the import on useJspecify; @nullable is used as a simple name so only the import changes. Regenerated the two affected jspecify samples.
1 parent 782dd0c commit 4a5f3a7

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

  • modules/openapi-generator/src/main/resources/Java/libraries
  • samples/client/petstore/java
    • restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client
    • webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client

‎modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ import java.util.Map.Entry;
7979
import java.util.TimeZone;
8080
import java.util.function.Supplier;
8181

82+
{{#useJspecify}}
83+
import org.jspecify.annotations.Nullable;
84+
{{/useJspecify}}
85+
{{^useJspecify}}
8286
import {{javaxPackage}}.annotation.Nullable;
87+
{{/useJspecify}}
8388

8489
{{#jsr310}}
8590
import java.time.OffsetDateTime;

‎modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ import java.util.Map;
8282
import java.util.Map.Entry;
8383
import java.util.TimeZone;
8484

85+
{{#useJspecify}}
86+
import org.jspecify.annotations.Nullable;
87+
{{/useJspecify}}
88+
{{^useJspecify}}
8589
import {{javaxPackage}}.annotation.Nullable;
90+
{{/useJspecify}}
8691

8792
{{#jsr310}}
8893
import java.time.OffsetDateTime;

‎samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/ApiClient.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
import java.util.TimeZone;
5454
import java.util.function.Supplier;
5555

56-
import jakarta.annotation.Nullable;
56+
import org.jspecify.annotations.Nullable;
5757

5858
import java.time.OffsetDateTime;
5959

‎samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/ApiClient.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
import java.util.Map.Entry;
7171
import java.util.TimeZone;
7272

73-
import jakarta.annotation.Nullable;
73+
import org.jspecify.annotations.Nullable;
7474

7575
import java.time.OffsetDateTime;
7676

0 commit comments

Comments
 (0)