Skip to content

Commit 23a1c60

Browse files
committed
fix(codegen): limit the Bucket param dedupe to S3 service
1 parent 60094d9 commit 23a1c60

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.function.Consumer;
3131
import java.util.logging.Logger;
3232
import java.util.stream.Collectors;
33+
import software.amazon.smithy.aws.traits.ServiceTrait;
3334
import software.amazon.smithy.codegen.core.CodegenException;
3435
import software.amazon.smithy.codegen.core.Symbol;
3536
import software.amazon.smithy.codegen.core.SymbolProvider;
@@ -96,9 +97,12 @@ public abstract class HttpBindingProtocolGenerator implements ProtocolGenerator
9697
private final boolean isErrorCodeInBody;
9798
private final EventStreamGenerator eventStreamGenerator = new EventStreamGenerator();
9899
private final LinkedHashMap<String, String> headerBuffer = new LinkedHashMap<>();
99-
private final Set<String> contextParamDeduplicationControlSet = SetUtils.of(
100+
private final Set<String> contextParamDeduplicationParamControlSet = SetUtils.of(
100101
"Bucket"
101102
);
103+
private final Set<String> contextParamDeduplicationServiceControlSet = SetUtils.of(
104+
"S3"
105+
);
102106

103107
/**
104108
* Creates a Http binding protocol generator.
@@ -735,6 +739,11 @@ private void writeResolvedPath(
735739
.getContextParams(context.getModel().getShape(operation.getInputShape()).get())
736740
: Collections.emptyMap();
737741

742+
String serviceId = context.getService()
743+
.getTrait(ServiceTrait.class)
744+
.map(ServiceTrait::getSdkId)
745+
.orElse("");
746+
738747
// Always write the bound path, but only the actual segments.
739748
writer.write("let resolvedPath = `$L` + $S;",
740749
"${basePath?.endsWith('/') ? basePath.slice(0, -1) : (basePath || '')}",
@@ -751,8 +760,9 @@ private void writeResolvedPath(
751760
// do not want to include it in the operation URI to be resolved.
752761
// We use this logic plus a temporary control-list, since it is not yet known
753762
// how many services and param names will have this issue.
754-
755-
return !(isContextParam && contextParamDeduplicationControlSet.contains(content));
763+
return !(isContextParam
764+
&& contextParamDeduplicationParamControlSet.contains(content)
765+
&& contextParamDeduplicationServiceControlSet.contains(serviceId));
756766
})
757767
.map(Segment::toString)
758768
.collect(Collectors.joining("/"))

0 commit comments

Comments
 (0)