[BUG][JAVA] Generated code still missing many @Nullable annotations
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Java
- Stelle
- 26.9k
- Fork
- 7.8k
- Merge medio
- 2g 10h
- PR unite (30g)
- 180
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di OpenAPITools/openapi-generator
-
Issue: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
OpenAPITools/openapi-generator#25643 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
OpenAPITools/openapi-generator#25640 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG][JAVA] Deprecated properties only get @Deprecated on the getter (base, feign, native, microprofile)Forse già presa @Inf1mum l’ha presa 2 giorni fa. ApertaIssue: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
OpenAPITools/openapi-generator#25567 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG][KOTLIN-SERVER] typeInfoAnnotation.mustache uses As.PROPERTY → discriminator property serialized twiceForse già presa @Inf1mum l’ha presa 9 giorni fa. ApertaIssue: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
OpenAPITools/openapi-generator#25524 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[REQ][JAVA][resteasy] Support for Jackson 3 / useJackson3Forse già presa Una pull request collegata a questa issue è aperta o già unita. ApertaEnhancement: Feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
OpenAPITools/openapi-generator#25364 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di OpenAPITools/openapi-generator
Issue simili
-
bug emitter:client:csharp
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
microsoft/typespec#12572 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationForse già presa @amalsaidov l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
needs-area-label
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
area/ai area/backend component/zeebe kind/task
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno