From 11b9cd96717714c18a5380149719d926f48c05a1 Mon Sep 17 00:00:00 2001 From: George Fu <kuhe@users.noreply.github.com> Date: Mon, 15 Jul 2024 16:25:14 -0400 Subject: [PATCH] fix: exclude CustomEndpoints plugin from Endpoints 2.0 services (#1337) * fix: exclude CustomEndpoints plugin from Endpoints 2.0 services * linting --- .../typescript/codegen/integration/AddBuiltinPlugins.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddBuiltinPlugins.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddBuiltinPlugins.java index 3f3ce13f1d7..efc424395a6 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddBuiltinPlugins.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddBuiltinPlugins.java @@ -9,6 +9,8 @@ import static software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin.Convention.HAS_MIDDLEWARE; import java.util.List; +import software.amazon.smithy.model.shapes.ServiceShape; +import software.amazon.smithy.rulesengine.traits.EndpointRuleSetTrait; import software.amazon.smithy.typescript.codegen.TypeScriptDependency; import software.amazon.smithy.utils.SmithyInternalApi; @@ -25,6 +27,7 @@ public List<RuntimeClientPlugin> getClientPlugins() { RuntimeClientPlugin.builder() .withConventions( TypeScriptDependency.CONFIG_RESOLVER.dependency, "CustomEndpoints", HAS_CONFIG) + .servicePredicate((m, s) -> !isEndpointsV2Service(s)) .build(), RuntimeClientPlugin.builder() .withConventions(TypeScriptDependency.MIDDLEWARE_RETRY.dependency, "Retry") @@ -34,4 +37,8 @@ public List<RuntimeClientPlugin> getClientPlugins() { HAS_MIDDLEWARE) .build()); } + + private static boolean isEndpointsV2Service(ServiceShape serviceShape) { + return serviceShape.hasTrait(EndpointRuleSetTrait.class); + } }