[BUG][JAVA] Generated code still missing many @Nullable annotations
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Java
- Estrelas
- 26.9k
- Forks
- 7.8k
- Merge médio
- 2d 10h
- PRs com merge (30d)
- 180
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Inclui um Dockerfile ou arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de OpenAPITools/openapi-generator
-
Issue: Bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
OpenAPITools/openapi-generator#25643 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
OpenAPITools/openapi-generator#25640 ·
Mantenedores costumam responder em até 1 dia
-
[BUG][JAVA] Deprecated properties only get @Deprecated on the getter (base, feign, native, microprofile)Talvez já em andamento @Inf1mum assumiu há 2 dias. AbertaIssue: Bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
OpenAPITools/openapi-generator#25567 ·
Mantenedores costumam responder em até 1 dia
-
[BUG][KOTLIN-SERVER] typeInfoAnnotation.mustache uses As.PROPERTY → discriminator property serialized twiceTalvez já em andamento @Inf1mum assumiu há 9 dias. AbertaIssue: Bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
OpenAPITools/openapi-generator#25524 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
[REQ][JAVA][resteasy] Support for Jackson 3 / useJackson3Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. AbertaEnhancement: Feature
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
OpenAPITools/openapi-generator#25364 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de OpenAPITools/openapi-generator
Issues semelhantes
-
bug emitter:client:csharp
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
microsoft/typespec#12572 · 1 comentário · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
Mantenedores costumam responder em até 1 dia
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationTalvez já em andamento @amalsaidov assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
needs-area-label
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 2 dias
-
area/ai area/backend component/zeebe kind/task
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia