From 3f5db4df197aa9dda211519c98acbaa5e65a0244 Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Thu, 9 Feb 2023 14:36:01 -0500 Subject: [PATCH] fix(spring): update hasRestOption to exclude services with no rest-supported methods (#1343) --- .../composer/SpringAutoConfigClassComposer.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/api/generator/spring/composer/SpringAutoConfigClassComposer.java b/src/main/java/com/google/api/generator/spring/composer/SpringAutoConfigClassComposer.java index 56694f33ac..1c83dd02d5 100644 --- a/src/main/java/com/google/api/generator/spring/composer/SpringAutoConfigClassComposer.java +++ b/src/main/java/com/google/api/generator/spring/composer/SpringAutoConfigClassComposer.java @@ -110,7 +110,17 @@ public GapicClass generate(GapicContext context, Service service) { Expr thisExpr = ValueExpr.withValue(ThisObjectValue.withType(dynamicTypes.get(className))); Transport transport = context.transport(); - boolean hasRestOption = transport.equals(Transport.GRPC_REST); + // TODO(emmwang): this condition is adapted from latest gapic-generator-java changes as part of + // https://github.com/googleapis/gapic-generator-java/issues/1117, but should be updated to use + // the gapic-implemented helpers once spring generator code is migrated. + boolean hasRestSupportedMethod = + service.methods().stream() + .anyMatch( + x -> + x.httpBindings() != null + && x.stream() != Method.Stream.BIDI + && x.stream() != Method.Stream.CLIENT); + boolean hasRestOption = transport.equals(Transport.GRPC_REST) && hasRestSupportedMethod; String serviceSettingsMethodName = JavaStyle.toLowerCamelCase(service.name()) + "Settings"; ClassDefinition classDef =