fix(java-spring): add @Deprecated annotation to fluent setters for deprecated properties - #24762
Open
ANUSH2510 wants to merge 1 commit into
Open
fix(java-spring): add @Deprecated annotation to fluent setters for deprecated properties#24762ANUSH2510 wants to merge 1 commit into
ANUSH2510 wants to merge 1 commit into
Conversation
…precated properties Fixes OpenAPITools#24704 - fluent setter methods (both for own properties and inherited properties, including array/map item adders) were missing the @deprecated annotation that the getter and standard setter already carried for properties marked deprecated: true.
Member
|
thanks for the PR is this the same as #24705 ? |
Contributor
There was a problem hiding this comment.
1 issue found across 3 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/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java">
<violation number="1" location="modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java:5852">
P2: This regression test only covers the single fluent setter of the own enum property `status`. The fix claims to cover inherited-property fluent setters and the `addXxxItem`/`putXxxItem` variants, none of which this test exercises (Pet is not a child schema and `status` is not a container). Extend the test to cover those variants so a regression in the rest of the fix is detected.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| new DefaultGenerator().opts(configurator.toClientOptInput()).generate(); | ||
|
|
||
| JavaFileAssert.assertThat(tempDir.resolve("src/main/java/org/openapitools/model/Pet.java")) | ||
| .assertMethod("status", "StatusEnum").hasAnnotation("Deprecated"); |
Contributor
There was a problem hiding this comment.
P2: This regression test only covers the single fluent setter of the own enum property status. The fix claims to cover inherited-property fluent setters and the addXxxItem/putXxxItem variants, none of which this test exercises (Pet is not a child schema and status is not a container). Extend the test to cover those variants so a regression in the rest of the fix is detected.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java, line 5852:
<comment>This regression test only covers the single fluent setter of the own enum property `status`. The fix claims to cover inherited-property fluent setters and the `addXxxItem`/`putXxxItem` variants, none of which this test exercises (Pet is not a child schema and `status` is not a container). Extend the test to cover those variants so a regression in the rest of the fix is detected.</comment>
<file context>
@@ -5833,6 +5833,24 @@ public void shouldGenerateSingleDeprecatedAnnotation() {
+ new DefaultGenerator().opts(configurator.toClientOptInput()).generate();
+
+ JavaFileAssert.assertThat(tempDir.resolve("src/main/java/org/openapitools/model/Pet.java"))
+ .assertMethod("status", "StatusEnum").hasAnnotation("Deprecated");
+ }
</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.
Description
Fixes #24704
The
@Deprecatedannotation was correctly generated on getters and standard setters for properties markeddeprecated: true, but was missing on the corresponding fluent setter methods — for both a class's own properties and properties inherited from a parent schema (including the array/map item-adder variants:addXxxItem,putXxxItem).Changes
pojo.mustacheto wrap all fluent setter variants (single, array-item, map-item; both own and inherited) with the same{{#deprecated}}@Deprecated{{/deprecated}}block already used for the standard setter.shouldGenerateDeprecatedAnnotationOnFluentSetterinSpringCodegenTest.spring-cloud-deprecated) to reflect the fix.Testing
SpringCodegenTestsuite passes (328/328).allOfinheritance +deprecated: true.Summary by cubic
Annotates all fluent setters for deprecated properties with @deprecated in the Java Spring generator, matching the existing getters and standard setters. Previously, fluent setters (including inherited and array/map item adders) lacked the annotation; now compilers/IDEs will warn when they are used.
JavaSpring/pojo.mustacheto apply @deprecated to fluent setters for own and inherited properties, includingaddXxxItemandputXxxItem, when the property hasdeprecated: true.shouldGenerateDeprecatedAnnotationOnFluentSetterand regenerated thespring-cloud-deprecatedsample.Written for commit 12e4ce1. Summary will update on new commits.