fix(jaxrs-spec): generate @Deprecated annotations (fixes #18941)#23651
Open
anna-megalou wants to merge 2 commits intoOpenAPITools:masterfrom
Open
fix(jaxrs-spec): generate @Deprecated annotations (fixes #18941)#23651anna-megalou wants to merge 2 commits intoOpenAPITools:masterfrom
anna-megalou wants to merge 2 commits intoOpenAPITools:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
1 issue found across 13 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/JavaJaxRS/spec/apiMethod.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/JavaJaxRS/spec/apiMethod.mustache:8">
P1: `@ApiOperation` in Swagger 1.x does not support a `deprecated` attribute, so this newly generated argument can cause compile errors with supported/sample swagger-annotations versions.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Contributor
There was a problem hiding this comment.
1 issue found across 5 files (changes from recent commits).
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/jaxrs/JavaJAXRSSpecServerCodegenTest.java">
<violation number="1" location="modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJAXRSSpecServerCodegenTest.java:1341">
P2: The test no longer verifies the generated API annotation still includes `deprecated = true`, so a regression in the actual `@Operation` output would pass unnoticed.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| Path petApi = output.toPath().resolve("src/gen/java/org/openapitools/api/PetApi.java"); | ||
| JavaFileAssert.assertThat(petApi).assertMethod("findPetsByTags", "List<String>").hasAnnotation("Deprecated"); | ||
| JavaFileAssert.assertThat(petApi).fileContains("* @deprecated", "findPetsByTags"); |
Contributor
There was a problem hiding this comment.
P2: The test no longer verifies the generated API annotation still includes deprecated = true, so a regression in the actual @Operation output would pass unnoticed.
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/jaxrs/JavaJAXRSSpecServerCodegenTest.java, line 1341:
<comment>The test no longer verifies the generated API annotation still includes `deprecated = true`, so a regression in the actual `@Operation` output would pass unnoticed.</comment>
<file context>
@@ -1338,7 +1338,7 @@ public void generatesDeprecatedAnnotationsForModelsOperationsAndParameters_issue
Path petApi = output.toPath().resolve("src/gen/java/org/openapitools/api/PetApi.java");
JavaFileAssert.assertThat(petApi).assertMethod("findPetsByTags", "List<String>").hasAnnotation("Deprecated");
- JavaFileAssert.assertThat(petApi).fileContains("@ApiOperation", "deprecated = true", "findPetsByTags");
+ JavaFileAssert.assertThat(petApi).fileContains("* @deprecated", "findPetsByTags");
JavaFileAssert.assertThat(petApi).fileContains("findPetsByStatus", "@Deprecated", "@QueryParam(\"status\")");
}
</file context>
Suggested change
| JavaFileAssert.assertThat(petApi).fileContains("* @deprecated", "findPetsByTags"); | |
| JavaFileAssert.assertThat(petApi).fileContains("@Operation", "deprecated = true", "findPetsByTags"); |
Member
|
thanks for the pr please follow step 3 to update the samples |
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.
Summary
Adds support for OpenAPI
deprecated: truein thejaxrs-specJava generator.This PR adds generated Java deprecation annotations where applicable, including:
@Deprecated/** @deprecated */deprecated = truein API documentation annotationsIt also adds a test for deprecated operations and parameters.
Why
Fixes #18941.
The generated Java code should reflect deprecated operations and parameters from the OpenAPI specification.
How to test