[BUG][JAVA] Generated code still missing many @Nullable annotations
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Start by generating a Java model with the useJspecify option enabled, using a spec like the one in #23656, and compare the output with the snippet in the issue. The fix belongs in the Java model templates that emit @NullMarked code, which you can locate by searching for the useJspecify flag. Done means the listed members (the additionalProperties field and getter, getAdditionalProperty, equals, toIndentedString) carry @Nullable where they can be null, and a nullability checker reports no new errors.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When generating a Java model with useJspecify, the package is @NullMarked but many @Nullable annotations are missing.
private Map<String, Object> additionalProperties; // <-- both Map and possibly Object should be @Nullable
@JsonAnySetter
public TestModel putAdditionalProperty(String key, Object value) {
if (this.additionalProperties == null) { // <-- it handles the Map being null here
this.additionalProperties = new HashMap<String, Object>();
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() { // <-- matching annotation needed here
return additionalProperties; // <-- as it could return null
}
public Object getAdditionalProperty(String key) { // <-- missing @Nullable
if (this.additionalProperties == null) {
return null; // <-- for this return
}
return this.additionalProperties.get(key); // <-- and possibly here if values can be null
}
@Override
public boolean equals(Object o) { // <-- should be @Nullable
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) { // <-- as per Object.equals spec, it handles nulls
return false;
}
// ...
}
private String toIndentedString(Object o) { // <-- ditto
return o == null ? "null" : o.toString().replace("\n", "\n ");
}
openapi-generator version
7.27.0
OpenAPI declaration file content or url
See #23656
Generation Details
See #23656
Steps to reproduce
See #23656
Related issues/PRs
#23656
Suggest a fix
Add @Nullable in the correct places in the templates.
Scan all generated code with a nullability checker that can find further instances of this error.
- Vorherrschende Sprache
- Java
- Sterne
- 26.9k
- Forks
- 7.8k
- Ø Merge
- 2 T. 10 Std.
- Gemergte PRs (30 T.)
- 180
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus OpenAPITools/openapi-generator
-
Issue: Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
OpenAPITools/openapi-generator#25643 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
OpenAPITools/openapi-generator#25640 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG][JAVA] Deprecated properties only get @Deprecated on the getter (base, feign, native, microprofile)Evtl. vergeben @Inf1mum hat das vor 2 Tagen übernommen. OffenIssue: Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
OpenAPITools/openapi-generator#25567 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG][KOTLIN-SERVER] typeInfoAnnotation.mustache uses As.PROPERTY → discriminator property serialized twiceEvtl. vergeben @Inf1mum hat das vor 9 Tagen übernommen. OffenIssue: Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
OpenAPITools/openapi-generator#25524 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
[REQ][JAVA][resteasy] Support for Jackson 3 / useJackson3Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. OffenEnhancement: Feature
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
OpenAPITools/openapi-generator#25364 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in OpenAPITools/openapi-generator
Ähnliche Issues
-
bug emitter:client:csharp
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
microsoft/typespec#12572 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 73/100
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationEvtl. vergeben @amalsaidov hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
needs-area-label
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 2 Tagen
-
area/ai area/backend component/zeebe kind/task
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag