Skip to content

Commit

Permalink
fix: exclude CustomEndpoints plugin from Endpoints 2.0 services (smit…
Browse files Browse the repository at this point in the history
…hy-lang#1337)

* fix: exclude CustomEndpoints plugin from Endpoints 2.0 services

* linting
  • Loading branch information
kuhe authored Jul 15, 2024
1 parent 53cd7ac commit 11b9cd9
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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")
Expand All @@ -34,4 +37,8 @@ public List<RuntimeClientPlugin> getClientPlugins() {
HAS_MIDDLEWARE)
.build());
}

private static boolean isEndpointsV2Service(ServiceShape serviceShape) {
return serviceShape.hasTrait(EndpointRuleSetTrait.class);
}
}

0 comments on commit 11b9cd9

Please sign in to comment.