[Java][Spring] Annotate deprecated fluent model setters with @Deprecated - #24705
Open
kalayciburak wants to merge 1 commit into
Open
[Java][Spring] Annotate deprecated fluent model setters with @Deprecated#24705kalayciburak wants to merge 1 commit into
kalayciburak wants to merge 1 commit into
Conversation
Fluent setters and collection helpers generated from deprecated schema properties now emit @deprecated, matching getters, setters, and nested builder methods. Fixes OpenAPITools#24704
Contributor
There was a problem hiding this comment.
1 issue found across 50 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache:158">
P3: The fluent setters and collection helpers get the `@Deprecated` annotation but, unlike the getter and regular setter for the same deprecated property, they emit no `/** @deprecated */` Javadoc block. Add a matching Javadoc deprecation tag for consistency so `@deprecated` HTML docs stay uniform across generated code.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
|
||
| {{! begin feature: fluent setter methods }} | ||
| {{#deprecated}} | ||
| @Deprecated |
Contributor
There was a problem hiding this comment.
P3: The fluent setters and collection helpers get the @Deprecated annotation but, unlike the getter and regular setter for the same deprecated property, they emit no /** @deprecated */ Javadoc block. Add a matching Javadoc deprecation tag for consistency so @deprecated HTML docs stay uniform across generated code.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache, line 158:
<comment>The fluent setters and collection helpers get the `@Deprecated` annotation but, unlike the getter and regular setter for the same deprecated property, they emit no `/** @deprecated */` Javadoc block. Add a matching Javadoc deprecation tag for consistency so `@deprecated` HTML docs stay uniform across generated code.</comment>
<file context>
@@ -154,6 +154,9 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}
{{! begin feature: fluent setter methods }}
+ {{#deprecated}}
+ @Deprecated
+ {{/deprecated}}
public {{classname}} {{name}}({{#useJspecify}}{{#lambda.jSpecifyNullable}}{{^required}}{{^useOptional}}@Nullable {{/useOptional}}{{#useOptional}}{{#optionalAcceptNullable}}@Nullable {{/optionalAcceptNullable}}{{/useOptional}}{{/required}}{{/lambda.jSpecifyNullable}}{{#lambda.jSpecifyDatatype}}{{{datatypeWithEnum}}}{{/lambda.jSpecifyDatatype}}{{/useJspecify}}{{^useJspecify}}{{>nullableAnnotation_default}}{{{datatypeWithEnum}}}{{/useJspecify}} {{name}}) {
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.mustacheso those methods emit@Deprecatedas well, including inherited fluent helpers.Fixes #24704
PR checklist
@Deprecatedon fluent setters and collection helpers for already-deprecated properties (for examplePet.status).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 GREENSummary by cubic
Annotates generated Java Spring model fluent setters and collection helpers for deprecated properties with @deprecated to align with existing annotations on fields/getters/setters/builder methods. Previously, these fluent methods were not annotated; now they are, including inherited helpers, to surface consistent deprecation warnings.
modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustachenow emits@Deprecatedon fluent setters (prop(value)),addXItem(...),putXItem(...), and their inherited equivalents when the schema property hasdeprecated: true.Written for commit bf615f6. Summary will update on new commits.