From c6a8cf7e62aaa9a7b8f45199aa7ab48eed5718d2 Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Fri, 1 May 2020 19:26:46 +0000 Subject: [PATCH 1/4] Use array for SetShape --- .../amazon/smithy/typescript/codegen/SymbolVisitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/SymbolVisitor.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/SymbolVisitor.java index 415d2abdbf6..ac0446967f4 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/SymbolVisitor.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/SymbolVisitor.java @@ -132,7 +132,7 @@ public Symbol listShape(ListShape shape) { @Override public Symbol setShape(SetShape shape) { Symbol reference = toSymbol(shape.getMember()); - return createSymbolBuilder(shape, format("Set<%s>", reference.getName()), null) + return createSymbolBuilder(shape, format("(%s)[]", reference.getName()), null) .addReference(reference) .build(); } From 24e69a7d9385f716ca1c5b1112953a1be3117f90 Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Fri, 1 May 2020 21:02:52 +0000 Subject: [PATCH 2/4] Update documentation --- .../codegen/integration/DocumentShapeDeserVisitor.java | 2 +- .../typescript/codegen/integration/DocumentShapeSerVisitor.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentShapeDeserVisitor.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentShapeDeserVisitor.java index 472d2da7938..7a644ea9057 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentShapeDeserVisitor.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentShapeDeserVisitor.java @@ -442,7 +442,7 @@ public final Void mapShape(MapShape shape) { * const deserializeAws_restJson1_1ParameterSet = ( * output: any, * context: SerdeContext - * ): Set => { + * ): Parameter[] => { * return (output || []).map((entry: any) => * deserializeAws_restJson1_1Parameter(entry, context) * ); diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentShapeSerVisitor.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentShapeSerVisitor.java index 003b463b4bf..7b9e83d1f87 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentShapeSerVisitor.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentShapeSerVisitor.java @@ -437,7 +437,7 @@ public final Void mapShape(MapShape shape) { * *
{@code
      * const serializeAws_restJson1_1ParametersSet = (
-     *   input: Set,
+     *   input: Parameter[],
      *   context: SerdeContext
      * ): any => {
      *   return (input || []).map(entry =>

From 50b3f51d7b27ef770e28116721ff4eb043d7325d Mon Sep 17 00:00:00 2001
From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Date: Mon, 4 May 2020 20:28:13 +0000
Subject: [PATCH 3/4] chore: remove new Set from ProtocolTestGenerator

---
 .../typescript/codegen/HttpProtocolTestGenerator.java       | 6 ------
 .../codegen/integration/HttpBindingProtocolGenerator.java   | 4 ----
 2 files changed, 10 deletions(-)

diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java
index 6589546dd6c..0f6f027b95b 100644
--- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java
+++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java
@@ -457,12 +457,6 @@ public Void arrayNode(ArrayNode node) {
             String openElement = "[";
             String closeElement = "]";
 
-            // Handle sets needing to use the Set typing instead of standard array syntax.
-            if (workingShape.isSetShape()) {
-                openElement = "new Set(" + openElement;
-                closeElement = closeElement + ")";
-            }
-
             // Write the value out directly.
             writer.openBlock("$L\n", closeElement + ",\n", openElement, () -> {
                 Shape wrapperShape = this.workingShape;
diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java
index f302818344a..58d0f9f499d 100644
--- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java
+++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java
@@ -1397,10 +1397,6 @@ private String getCollectionOutputParam(
                 // Iterate over each entry and do deser work.
                 outputParam += ".map(_entry => " + collectionTargetValue + ")";
 
-                // Make sets when necessary.
-                if (target.isSetShape()) {
-                    outputParam = "new Set(" + outputParam + ")";
-                }
                 return outputParam;
             default:
                 throw new CodegenException("Unexpected collection binding location `" + bindingType + "`");

From e9894d603d76035f7f8ee5fa09ab29c281a4640b Mon Sep 17 00:00:00 2001
From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Date: Fri, 8 May 2020 02:38:02 +0000
Subject: [PATCH 4/4] Remove instanceof Set check

---
 .../amazon/smithy/typescript/codegen/protocol-test-stub.ts    | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/smithy-typescript-codegen/src/main/resources/software/amazon/smithy/typescript/codegen/protocol-test-stub.ts b/smithy-typescript-codegen/src/main/resources/software/amazon/smithy/typescript/codegen/protocol-test-stub.ts
index 235506f7200..2d1a10b4c49 100644
--- a/smithy-typescript-codegen/src/main/resources/software/amazon/smithy/typescript/codegen/protocol-test-stub.ts
+++ b/smithy-typescript-codegen/src/main/resources/software/amazon/smithy/typescript/codegen/protocol-test-stub.ts
@@ -100,10 +100,6 @@ const compareParts = (expectedParts: comparableParts, generatedParts: comparable
  */
 const equivalentContents = (expected: any, generated: any): boolean => {
   let localExpected = expected;
-  // Handle comparing sets to arrays properly.
-  if (expected instanceof Set) {
-    localExpected = Array.from(expected);
-  }
 
   // Short circuit on equality.
   if (localExpected == generated) {