[Spring-http-interface] JSpecify: fix api argument with default value
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:
(For Windows users, please run the script in WSL)./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
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
Fixes spring-http-interface JSpecify handling so API arguments with default values or required=false nullable schemas are marked @Nullable, matching Spring's actual injection behavior.
- Introduces
nullableAnnotation_apiArgument.mustacheplus aspring-http-interfaceoverride, and switches body, query, header, cookie, and path templates to use it;nullableAnnotation.mustachestays for models only. - Simplifies
nullableAnnotation_jspecify.mustacheto remove the redundant guard, preventing duplicate@Nullable. - Updates the JSpecify test spec to cover defaulted and nullable query/header parameters and regenerates samples.
Migration
- If you enable JSpecify, ensure
org.jspecify:jspecifyis on the classpath.