Skip to content

Commit 1106124

Browse files
committed
fix(s3ControlClient): removing host prefix
1 parent 66fdd56 commit 1106124

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin.Convention.HAS_CONFIG;
2020
import static software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin.Convention.HAS_MIDDLEWARE;
2121

22+
import java.util.ArrayList;
2223
import java.util.Collections;
2324
import java.util.HashSet;
2425
import java.util.List;
@@ -79,6 +80,25 @@ public final class AddS3Config implements TypeScriptIntegration {
7980
+ " you need to install the \"@aws-sdk/signature-v4-crt\" package to your project dependencies. \n"
8081
+ "For more information, please go to https://github.com/aws/aws-sdk-js-v3#known-issues</p>";
8182

83+
/**
84+
* This removes the host prefix from the endpoint traits of the model.
85+
*
86+
*/
87+
public static Model removeHostPrefixTrait(Model model, TypeScriptSettings settings) {
88+
boolean checkEndPointRuleSet = model.hasTrait(EndpointRuleSetTrait.class)
89+
Set<Shape> shapesWithTraits = model.getShapesWithTrait(EndpointTrait.class);
90+
Model.Builder mb = model.toBuilder();
91+
for(Shape shape: shapesWithTraits) {
92+
OperationShape.Builder ob = OperationShape.shapeToBuilder(shape.asOperationShape().get());
93+
ob.removeTrait(EndpointTrait.ID);
94+
OperationShape operation = ob.build();
95+
mb.removeShape(operation.getId());
96+
mb.addShape(operation);
97+
}
98+
return mb.build();
99+
100+
}
101+
82102
@Override
83103
public List<String> runAfter() {
84104
return List.of(
@@ -94,6 +114,7 @@ public Model preprocessModel(Model model, TypeScriptSettings settings) {
94114
if (!isS3(serviceShape)) {
95115
return model;
96116
}
117+
removeHostPrefixTrait(model, settings);
97118

98119
Model.Builder modelBuilder = model.toBuilder();
99120

@@ -433,4 +454,5 @@ private static boolean containsExpiresOutput(
433454
private static boolean isS3(Shape serviceShape) {
434455
return serviceShape.getTrait(ServiceTrait.class).map(ServiceTrait::getSdkId).orElse("").equals("S3");
435456
}
457+
436458
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public Model preprocessModel(Model model, TypeScriptSettings settings) {
9090
if (!isS3Control(settings.getService(model))) {
9191
return model;
9292
}
93+
model = AddS3Config.removeHostPrefixTrait(model, settings);
9394
ServiceShape serviceShape = model.expectShape(settings.getService(), ServiceShape.class);
9495
return ModelTransformer.create().mapShapes(model, shape -> {
9596
Optional<MemberShape> modified = shape.asMemberShape()

0 commit comments

Comments
 (0)