Skip to content

Commit 5b0a9c6

Browse files
Chase CoalwellAllanZhengYP
authored andcommitted
Feat: update and apply S3 middleware (aws#478)
* feat: migrate s3 middleware * feat: apply validate-bucket-name plugin
1 parent b831fe8 commit 5b0a9c6

File tree

9 files changed

+26
-254
lines changed

9 files changed

+26
-254
lines changed

codegen/config/checkstyle/suppressions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
2020
<suppressions>
2121
<suppress checks="TypeName"
22-
files="/Aws.*\d_\d.java$"/>
22+
files="AwsRestJson1_1.java|AwsRestJson1_0.java"/>
2323
</suppressions>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public class AddProtocols implements TypeScriptIntegration {
2727

2828
@Override
2929
public List<ProtocolGenerator> getProtocolGenerators() {
30-
return ListUtils.of(new AwsRestJson1_0(), new AwsRestJson1_1(),
31-
new AwsJsonRpc1_0(), new AwsJsonRpc1_1());
30+
return ListUtils.of(new AwsRestJson1_0(), new AwsRestJson1_1());
3231
}
3332
}

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

Lines changed: 0 additions & 36 deletions
This file was deleted.

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

Lines changed: 0 additions & 36 deletions
This file was deleted.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
public final class AwsRestJson1_0 extends RestJsonProtocolGenerator {
2626

2727
@Override
28-
protected String getDocumentContentType() {
29-
return "application/x-amz-json-1.0";
28+
public String getName() {
29+
return "aws.rest-json-1.0";
3030
}
3131

3232
@Override
33-
public String getName() {
34-
return "aws.rest-json-1.0";
33+
protected String getDocumentContentType() {
34+
return "application/x-amz-json-1.0";
3535
}
3636
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
public final class AwsRestJson1_1 extends RestJsonProtocolGenerator {
2626

2727
@Override
28-
protected String getDocumentContentType() {
29-
return "application/x-amz-json-1.1";
28+
public String getName() {
29+
return "aws.rest-json-1.1";
3030
}
3131

3232
@Override
33-
public String getName() {
34-
return "aws.rest-json-1.1";
33+
protected String getDocumentContentType() {
34+
return "application/x-amz-json-1.1";
3535
}
3636
}

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

Lines changed: 0 additions & 51 deletions
This file was deleted.

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

Lines changed: 0 additions & 118 deletions
This file was deleted.

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* @see JsonShapeSerVisitor
4545
* @see JsonShapeDeserVisitor
4646
* @see JsonMemberSerVisitor
47-
* @see JsonMemberDeserVisitor
47+
* @see DocumentMemberDeserVisitor
4848
* @see <a href="https://awslabs.github.io/smithy/spec/http.html">Smithy HTTP protocol bindings.</a>
4949
*/
5050
abstract class RestJsonProtocolGenerator extends HttpBindingProtocolGenerator {
@@ -75,7 +75,21 @@ private void generateDocumentShapeSerde(GenerationContext context, Set<Shape> sh
7575
@Override
7676
public void generateSharedComponents(GenerationContext context) {
7777
super.generateSharedComponents(context);
78-
JsonProtocolUtils.generateParseBody(context);
78+
TypeScriptWriter writer = context.getWriter();
79+
80+
// Include a JSON body parser used to deserialize documents from HTTP responses.
81+
writer.addImport("SerdeContext", "SerdeContext", "@aws-sdk/types");
82+
writer.openBlock("const parseBody = (streamBody: any, context: SerdeContext): any => {", "};", () -> {
83+
writer.openBlock("return context.streamCollector(streamBody).then((body: any) => {", "});", () -> {
84+
writer.write("const encoded = context.utf8Encoder(body);");
85+
writer.openBlock("if (encoded.length) {", "}", () -> {
86+
writer.write("return JSON.parse(encoded);");
87+
});
88+
writer.write("return {};");
89+
});
90+
});
91+
92+
writer.write("");
7993
}
8094

8195
@Override

0 commit comments

Comments
 (0)