Skip to content

[Java][Spring] useRecords: no @NotNull on records without bean validation - #25265

Merged
wing328 merged 1 commit into
OpenAPITools:masterfrom
Sekator778:spring-records-notnull
Oct 15, 2026
Merged

wing328 merged 1 commit into
OpenAPITools:masterfrom
Sekator778:spring-records-notnull

Conversation

@Sekator778

@Sekator778 Sekator778 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

#25131 removed @NotNull and its import from classes when useBeanValidation is off. The record template from #25200 still printed the annotation, so with useRecords and useBeanValidation=false a record with a required property stopped compiling. Records now follow classes there. With bean validation on, or useRecords off, the output is unchanged.

@cachescrubber @welshm @MelleD @atextor @manedev79 @javisst @borsch @banlevente @Zomzog @martin-mfg @KannaKim

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

Fixes the Java Spring record template emitting @NotNull on required fields when useBeanValidation is off, which produced records that did not compile because the annotation import was missing. Records now match the classes behavior and emit no bean validation annotations when validation is disabled. Output is unchanged when bean validation is on or useRecords is off.

Adds regression tests covering record generation with and without bean validation.

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

View guided diff

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

View guided diff | Re-trigger cubic

@wing328
wing328 merged commit 7ad0fe0 into OpenAPITools:master Oct 15, 2026
15 checks passed
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