Skip to content

Commit

Permalink
fix(codegen): limit the Bucket param dedupe to S3 service (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe authored Nov 1, 2022
1 parent 60094d9 commit 20949f2
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -96,9 +97,7 @@ public abstract class HttpBindingProtocolGenerator implements ProtocolGenerator
private final boolean isErrorCodeInBody;
private final EventStreamGenerator eventStreamGenerator = new EventStreamGenerator();
private final LinkedHashMap<String, String> headerBuffer = new LinkedHashMap<>();
private final Set<String> contextParamDeduplicationControlSet = SetUtils.of(
"Bucket"
);
private Set<String> contextParamDeduplicationParamControlSet = new HashSet<>();

/**
* Creates a Http binding protocol generator.
Expand All @@ -110,6 +109,14 @@ public HttpBindingProtocolGenerator(boolean isErrorCodeInBody) {
this.isErrorCodeInBody = isErrorCodeInBody;
}

/**
* Indicate that param names in the set should be de-duplicated when appearing in
* both contextParams (endpoint ruleset related) and HTTP URI segments / labels.
*/
public void setContextParamDeduplicationParamControlSet(Set<String> contextParamDeduplicationParamControlSet) {
this.contextParamDeduplicationParamControlSet = contextParamDeduplicationParamControlSet;
}

@Override
public final ApplicationProtocol getApplicationProtocol() {
return APPLICATION_PROTOCOL;
Expand Down Expand Up @@ -751,8 +758,8 @@ private void writeResolvedPath(
// do not want to include it in the operation URI to be resolved.
// We use this logic plus a temporary control-list, since it is not yet known
// how many services and param names will have this issue.

return !(isContextParam && contextParamDeduplicationControlSet.contains(content));
return !(isContextParam
&& contextParamDeduplicationParamControlSet.contains(content));
})
.map(Segment::toString)
.collect(Collectors.joining("/"))
Expand Down

0 comments on commit 20949f2

Please sign in to comment.