-
Notifications
You must be signed in to change notification settings - Fork 910
Adding @Deprecated annotation when API is marked as deprecated #2991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Andrew! 👋🏽
@@ -160,6 +160,7 @@ public final String serviceName() { | |||
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS | |||
* API Documentation</a> | |||
*/ | |||
@Deprecated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's a deprecatedMessage
field. Can we add it in the Javadocs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably update this utility class to support operation models as well:
Lines 34 to 50 in a8ec3f8
/** | |
* If a given member is modeled as deprecated, add the {@link Deprecated} annotation to the method and, if the method | |
* already has existing Javadoc, append a section with the {@code @deprecated} tag. | |
*/ | |
public static MethodSpec checkDeprecated(MemberModel member, MethodSpec method) { | |
if (!member.isDeprecated() || method.annotations.contains(DEPRECATED)) { | |
return method; | |
} | |
MethodSpec.Builder builder = method.toBuilder().addAnnotation(DEPRECATED); | |
if (!method.javadoc.isEmpty()) { | |
builder.addJavadoc(LF + "@deprecated"); | |
if (StringUtils.isNotBlank(member.getDeprecatedMessage())) { | |
builder.addJavadoc(" $L", member.getDeprecatedMessage()); | |
} | |
} | |
return builder.build(); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nice @Bennett-Lynch this looks perfect, will make some tweaks to use that.
@zoewangg sure thing! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added those changes. Let me know what you think!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Kudos, SonarCloud Quality Gate passed! |
…2ad13ede2 Pull request: release <- staging/bcc21d3e-5a23-4397-8f24-ecc2ad13ede2
This change generates the @deprecated annotation for all APIs marked as deprecated in the C2J model.
Motivation and Context
This adds clear guidance for deprecated APIs in the IDE.
N/A
Modifications
Modifies the code generator to add the @deprecated annotation to client/interface methods that correspond to a deprecated API.
Testing
Added deprecated trait to one of the existing poet test models and modified expected generation files.
Screenshots (if appropriate)
Types of changes
Checklist
mvn install
succeedsscripts/new-change
script and following the instructions. Commit the new file created by the script in.changes/next-release
with your changes.License