Skip to content

[Spring-http-interface] JSpecify: fix api argument with default value - #24740

Open
jpfinne wants to merge 32 commits into
OpenAPITools:masterfrom
jpfinne:bugfix_24737
Open

[Spring-http-interface] JSpecify: fix api argument with default value#24740
jpfinne wants to merge 32 commits into
OpenAPITools:masterfrom
jpfinne:bugfix_24737

Conversation

@jpfinne

@jpfinne jpfinne commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

fix #24737

For spring-http-interface only: the api arguments with default value are annotated with @Nullable.
Spring will inject the specified default value if null is provided.

Small refactoring of the spring templates:
nullableAnnotation.mustache is kept for model only
nullableAnnotation_apiArgument.mustache is introduced for all api arguments (queryParams, pathParams, headerParams)

This make it easier to redefine nullableAnnotation_apiArgument for spring-http-interface to handle the default parameters.

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.

@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) @martin-mfg (2023/08) @KannaKim (2026/07)


Summary by cubic

Marks spring-http-interface API parameters with a default value as @Nullable and fixes JSpecify handling to avoid duplicate @Nullable. Previously, defaulted @RequestParam/@RequestHeader were not nullable; now they are for spring-http-interface only. No runtime change—Spring still injects the default when null is provided.

  • Introduces nullableAnnotation_apiArgument.mustache plus a spring-http-interface override, and switches body, query, header, cookie, and path templates to use it.
  • Simplifies nullableAnnotation.mustache to pick JSpecify cleanly and updates nullableAnnotation_jspecify.mustache to prevent double @Nullable and handle default vs non-default cases.
  • Updates tests to assert the change is scoped to spring-http-interface and regenerates samples.

Migration

  • If you enable JSpecify, ensure org.jspecify:jspecify is on the classpath.

Written for commit 4e821b1. Summary will update on new commits.

Review in cubic

@anthonyvdotbe

Copy link
Copy Markdown
Contributor

@jpfinne is this ready for review? If not, what remains to be done? I'd like to get this fixed ASAP, so if needed I can create a PR myself

@jpfinne jpfinne changed the title Fix 24737 [Spring-http-interface] Jspecify: fix api argument with default value Aug 20, 2026
@jpfinne jpfinne changed the title [Spring-http-interface] Jspecify: fix api argument with default value [Spring-http-interface] JSpecify: fix api argument with default value Aug 20, 2026
@jpfinne
jpfinne marked this pull request as ready for review August 20, 2026 17:21
@jpfinne

jpfinne commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

@jpfinne is this ready for review? If not, what remains to be done? I'd like to get this fixed ASAP, so if needed I can create a PR myself

@anthonyvdotbe I've simplified the nullable annotations to easily distinguish between model and api.
Can you validate and approve the PR?

We are close to the release date... Contact wing328 to accelerate the merge

@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.

All reported issues were addressed across 17 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@anthonyvdotbe

Copy link
Copy Markdown
Contributor

@anthonyvdotbe I've simplified the nullable annotations to easily distinguish between model and api. Can you validate and approve the PR?

@jpfinne I see the AI bot suggested changes, so I'll let you resolve those first

@jpfinne

jpfinne commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

@anthonyvdotbe I've simplified the nullable annotations to easily distinguish between model and api. Can you validate and approve the PR?

@jpfinne I see the AI bot suggested changes, so I'll let you resolve those first

@anthonyvdotbe done

@anthonyvdotbe anthonyvdotbe 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.

In general, I'd prefer a more focused PR that just fixes this particular issue and leaves the refactoring for another PR.

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.

[BUG][Spring] Wrong nullability of method parameters with spring-http-interface library

2 participants