openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[JAVA] Only add the JsonNullable import when the file actually contains a nullable property

Open FieteO opened this issue 3 years ago • 5 comments

Right now, the JsonNullable import is added to each model when the openApiNullable feature is set to true (which it is by default). With this PR, the import will only be added when the model actually contains a nullable property. Ultimately, this leads to less warnings about unused imports.

PR checklist

  • [x] Read the contribution guidelines.
  • [x] Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • [x] Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • [x] File the PR against the correct branch: master (6.1.0) (minor release - breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • [x] If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09)

FieteO avatar Oct 09 '22 20:10 FieteO

Is there anything left to do on my side @borsch? I see that the pipeline is failing, but I assume that it is for every PR right?

FieteO avatar Oct 12 '22 15:10 FieteO

Is there anything left to do on my side @borsch? I see that the pipeline is failing, but I assume that it is for every PR right?

It looks like it's failing on tests looking for the import of JsonNullable

welshm avatar Oct 12 '22 15:10 welshm

Wow, at least my test works :D

FieteO avatar Oct 12 '22 15:10 FieteO

Should look better now. There is still a CI failure related to JsonCreator imports that were added after running the generate-samples script, however ~I can't image how my changes would affect that.~ Edit: My local clone of the repo was messed up, even though the git history looked correct

FieteO avatar Oct 12 '22 16:10 FieteO

cc @OpenAPITools/generator-core-team as the change impacts default codegen

wing328 avatar Oct 15 '22 07:10 wing328