Skip to content

Commit 7d8f3ca

Browse files
committed
chore: not to import auth config when not required at all
1 parent 5ec9314 commit 7d8f3ca

File tree

1 file changed

+12
-0
lines changed
  • codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen

1 file changed

+12
-0
lines changed

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddBuiltinPlugins.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public List<RuntimeClientPlugin> getClientPlugins() {
5454
.build(),
5555
RuntimeClientPlugin.builder()
5656
.withConventions(AwsDependency.MIDDLEWARE_SIGNING.dependency, "AwsAuth", HAS_CONFIG)
57+
.servicePredicate((m, s) -> !isAllOptionalAuthOperation(m, s))
5758
.build(),
5859
RuntimeClientPlugin.builder()
5960
.withConventions(AwsDependency.MIDDLEWARE_SIGNING.dependency, "AwsAuth", HAS_MIDDLEWARE)
@@ -175,4 +176,15 @@ private static boolean hasOptionalAuthOperation(Model model, ServiceShape servic
175176
}
176177
return false;
177178
}
179+
180+
private static boolean isAllOptionalAuthOperation(Model model, ServiceShape service) {
181+
TopDownIndex topDownIndex = TopDownIndex.of(model);
182+
Set<OperationShape> operations = topDownIndex.getContainedOperations(service);
183+
for (OperationShape operation : operations) {
184+
if (!operation.getTrait(OptionalAuthTrait.class).isPresent()) {
185+
return false;
186+
}
187+
}
188+
return true;
189+
}
178190
}

0 commit comments

Comments
 (0)