Skip to content

[SPRING] Improve jspecify Nullable for all args constructor and fluent setters - #24563

Draft
jpfinne wants to merge 15 commits into
OpenAPITools:masterfrom
jpfinne:feature/jspecifyChainSetter
Draft

[SPRING] Improve jspecify Nullable for all args constructor and fluent setters#24563
jpfinne wants to merge 15 commits into
OpenAPITools:masterfrom
jpfinne:feature/jspecifyChainSetter

Conversation

@jpfinne

@jpfinne jpfinne commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

PR checklist

  • Read the contribution guidelines.
  • 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.
  • 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

Improved JSpecify @Nullable handling in Spring generators: we now annotate all-args constructor params and fluent setters, and place annotations correctly inside qualified types and generics. This fixes issues with enums, lists, and Spring Resource, and updates samples/tests; Spring Boot 4 output now uses java.time.Instant where configured.

  • New Features

    • When useJspecify=true, generate @Nullable on all-args constructor parameters and fluent chain setters in Spring POJOs.
    • Added nullableArgumentWithEnum.mustache to support enum datatypes in constructor/setter arguments.
  • Bug Fixes

    • Correct placement of @Nullable within qualified types and generics by improving jSpecifyDatatype (e.g., java.time.@Nullable Instant, @Nullable List<java.time.Instant>).
    • Updated spring-boot-4-jspecify.yaml type mappings: OffsetDateTime -> java.time.Instant, BigDecimal -> java.math.BigDecimal; expanded tests and regenerated samples.

Written for commit 9fdd676. Summary will update on new commits.

Review in cubic

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.

1 participant