Skip to content

fixes(spring) Fixes @Nullable annotation#23397

Open
antechrestos wants to merge 1 commit intoOpenAPITools:masterfrom
antechrestos:fixes/spring-deprecated-annotations
Open

fixes(spring) Fixes @Nullable annotation#23397
antechrestos wants to merge 1 commit intoOpenAPITools:masterfrom
antechrestos:fixes/spring-deprecated-annotations

Conversation

@antechrestos
Copy link
Copy Markdown
Contributor

@antechrestos antechrestos commented Mar 30, 2026

  • remove findbug dependency as spring generator set its import to org.springframework.lang.Nullable
  • for springboot 4, use org.jspecify.annotations.Nullable as spring one is Deprecated(see java doc)

PR checklist

  • Read the contribution guidelines.
  • 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.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    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*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Fixes @nullable handling in Spring generators: use org.jspecify.annotations.Nullable for Spring Boot 4 and org.springframework.lang.Nullable otherwise. Removes jsr305 from generated POMs to avoid deprecated annotations and keep builds clean.

  • Bug Fixes

    • Import Nullable based on Spring Boot version (SB4 -> org.jspecify.annotations.Nullable, else org.springframework.lang.Nullable).
    • Added tests to ensure correct imports for array-type models under Spring Boot 4.
  • Dependencies

    • Removed com.google.code.findbugs:jsr305 from Spring Boot, Spring Cloud, and HTTP Interface templates; updated samples to match.

Written for commit b2b3076. Summary will update on new commits.

* remove findbug dependency as spring generator set its import to 'org.springframework.lang.Nullable'
* for springboot 4, use 'org.jspecify.annotations.Nullable' as spring one is Deprecated
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 135 files

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.

@antechrestos
Copy link
Copy Markdown
Contributor Author

@cachescrubber @wing328 I need you memory on this subject.

I would like to use @Nullable annotation from jspecify instead of springboot (the spring boot one is deprecated in springboot 7), yet there is a potential issue.

As jspecify Nullable annotation is a TYPE_USE annotation, it should be written org.springframework.core.io.@Nullable Resource instead of @Nullable org.springframework.core.io.Resource.

I though that a good workaround could be to add an importMapping of org.springframework.core.io.Resource and just use the type Resource in fields, getters and setters.

Yet I looked at the history and ended on your modification @cachescrubber .

As I do not understand very well reason why this revert, and, whether it is needed todays, I am asking your help to understand that before pushing a bug.

Thank you by advance

@jpfinne
Copy link
Copy Markdown
Contributor

jpfinne commented Mar 31, 2026

@antechrestos @wing328 org.springframework.core.io.Resource is just one example of Fully Qualified Class Name.
It can also occur with SchemaMappings as described in #23206

#23256 fixes it ([java] [Spring] useJspecify for java clients and spring generator). It works except for an issue with github workflows. An access Denied that I don't know how to fix. Please help on that.
Removing findbugs can be a minor improvement.

@antechrestos
Copy link
Copy Markdown
Contributor Author

@jpfinne I think I found your right issue on your PR. Please take a look at my comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants