Skip to content

Commit 3f5db4d

Browse files
authored
fix(spring): update hasRestOption to exclude services with no rest-supported methods (#1343)
1 parent 26c2e12 commit 3f5db4d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main/java/com/google/api/generator/spring/composer/SpringAutoConfigClassComposer.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,17 @@ public GapicClass generate(GapicContext context, Service service) {
110110

111111
Expr thisExpr = ValueExpr.withValue(ThisObjectValue.withType(dynamicTypes.get(className)));
112112
Transport transport = context.transport();
113-
boolean hasRestOption = transport.equals(Transport.GRPC_REST);
113+
// TODO(emmwang): this condition is adapted from latest gapic-generator-java changes as part of
114+
// https://github.com/googleapis/gapic-generator-java/issues/1117, but should be updated to use
115+
// the gapic-implemented helpers once spring generator code is migrated.
116+
boolean hasRestSupportedMethod =
117+
service.methods().stream()
118+
.anyMatch(
119+
x ->
120+
x.httpBindings() != null
121+
&& x.stream() != Method.Stream.BIDI
122+
&& x.stream() != Method.Stream.CLIENT);
123+
boolean hasRestOption = transport.equals(Transport.GRPC_REST) && hasRestSupportedMethod;
114124
String serviceSettingsMethodName = JavaStyle.toLowerCamelCase(service.name()) + "Settings";
115125

116126
ClassDefinition classDef =

0 commit comments

Comments
 (0)