Skip to content
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

Add deprecated forRemoval attribute to server-side code #2222

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,15 @@ private MethodSpec generateServiceMethod(
.build());
}

endpointDef
.getDeprecated()
.ifPresent(
deprecatedDocsValue -> methodBuilder.addAnnotation(ClassName.get("java.lang", "Deprecated")));
endpointDef.getDeprecated().ifPresent(_deprecatedValue -> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is now duplicated in 3 places - undertow, jersey, and dialogue. Happy to add it to a util class if we want.

if (endpointDef.getTags().contains("deprecated-for-removal")) {
methodBuilder.addAnnotation(AnnotationSpec.builder(Deprecated.class)
.addMember("forRemoval", "true")
.build());
} else {
methodBuilder.addAnnotation(Deprecated.class);
}
});

methodBuilder.addAnnotations(ConjureAnnotations.getClientEndpointAnnotations(endpointDef));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,18 @@ private TypeSpec generateEndpointHandler(
.addCode(endpointInvocation(
endpointDefinition, typeDefinitions, typeMapper, returnTypeMapper, safetyEvaluator));

endpointDefinition
.getDeprecated()
.ifPresent(deprecatedDocsValue ->
handleMethodBuilder.addAnnotation(AnnotationSpec.builder(SuppressWarnings.class)
.addMember("value", "$S", "deprecation")
.build()));
endpointDefinition.getDeprecated().ifPresent(_deprecatedValue -> {
if (endpointDefinition.getTags().contains("deprecated-for-removal")) {
handleMethodBuilder.addAnnotation(AnnotationSpec.builder(SuppressWarnings.class)
.addMember("value", "$S", "deprecation")
.addMember("value", "$S", "removal")
.build());
} else {
handleMethodBuilder.addAnnotation(AnnotationSpec.builder(SuppressWarnings.class)
.addMember("value", "$S", "deprecation")
.build());
}
});

MethodSpec.Builder ctorBuilder = MethodSpec.constructorBuilder()
.addParameter(UndertowRuntime.class, RUNTIME_VAR_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.palantir.conjure.spec.ServiceDefinition;
import com.palantir.tokens.auth.AuthHeader;
import com.palantir.tokens.auth.BearerToken;
import com.squareup.javapoet.AnnotationSpec;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
Expand Down Expand Up @@ -94,7 +95,15 @@ private MethodSpec generateServiceInterfaceMethod(
.addParameters(createServiceMethodParameters(endpointDef, safetyEvaluator, typeMapper))
.addAnnotations(ConjureAnnotations.incubating(endpointDef));

endpointDef.getDeprecated().ifPresent(deprecatedDocsValue -> methodBuilder.addAnnotation(Deprecated.class));
endpointDef.getDeprecated().ifPresent(_deprecatedValue -> {
if (endpointDef.getTags().contains("deprecated-for-removal")) {
methodBuilder.addAnnotation(AnnotationSpec.builder(Deprecated.class)
.addMember("forRemoval", "true")
.build());
} else {
methodBuilder.addAnnotation(Deprecated.class);
}
});

methodBuilder.addJavadoc("$L", ServiceGenerators.getJavaDocWithRequestLine(endpointDef));

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.