[Java][Spring] Annotate deprecated fluent model setters with @Deprecated
The Java Spring generator already annotates fields, getters, regular setters, and nested builder methods for properties marked deprecated: true. Fluent model setters and collection helpers (addXItem / putXItem) were missing @Deprecated.
This updates JavaSpring/pojo.mustache so those methods emit @Deprecated as well, including inherited fluent helpers.
Fixes #24704
PR checklist
- Read the contribution guidelines.
- Ran the following to build the project and update samples:
Regenerated Spring samples only. The sample delta is./mvnw -pl modules/openapi-generator-cli -am package -DskipTests=true -Dmaven.javadoc.skip=true -Djacoco.skip=true ./bin/generate-samples.sh ./bin/configs/spring*.yaml@Deprecatedon fluent setters and collection helpers for already-deprecated properties (for examplePet.status). - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Java Spring @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)
Tests
Executed:
./mvnw -pl modules/openapi-generator -am test -Dtest=SpringCodegenTest#contractWithDeprecatedPropertiesAnnotatesFluentSettersAndCollectionHelpersRED then GREEN./mvnw -pl modules/openapi-generator -am test -Dtest=SpringCodegenTest#contractWithDeprecatedEnumGeneratesDeprecatedAnnotation,SpringCodegenTest#contractWithDeprecatedPropertiesAnnotatesFluentSettersAndCollectionHelpers,SpringCodegenTest#shouldGenerateSingleDeprecatedAnnotation3/3 GREEN
Summary by cubic
Annotates Spring-generated fluent setters and collection helpers for deprecated properties. Old: no markers on fluent methods and some @deprecated Javadoc tags were empty. New: fluent and inherited helpers emit @Deprecated and @deprecated deprecated; regular setters’ Javadoc tag now includes text to avoid Javadoc warnings.
- Template: updates
modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustacheto add@Deprecatedand@deprecated deprecatedon fluent setters (prop(value)),addXItem(...),putXItem(...), and inherited equivalents when the schema property is deprecated; also updates existing setter Javadoc to@deprecated deprecated. - Tests/samples: adds
src/test/resources/3_0/spring/issue_24704.yaml; extendsSpringCodegenTestto assert annotations/Javadoc on fluent, collection helper, and builder methods; regenerates Spring samples. - Impact: No runtime change. IDE/compiler/Javadoc may now warn on deprecated fluent calls. No migration required.