Skip to content

Commit 57727c5

Browse files
trivikrsrchase
authored andcommitted
Use array for SetShape (smithy-lang#172)
1 parent e5cad3b commit 57727c5

File tree

6 files changed

+3
-17
lines changed

6 files changed

+3
-17
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,12 +457,6 @@ public Void arrayNode(ArrayNode node) {
457457
String openElement = "[";
458458
String closeElement = "]";
459459

460-
// Handle sets needing to use the Set typing instead of standard array syntax.
461-
if (workingShape.isSetShape()) {
462-
openElement = "new Set(" + openElement;
463-
closeElement = closeElement + ")";
464-
}
465-
466460
// Write the value out directly.
467461
writer.openBlock("$L\n", closeElement + ",\n", openElement, () -> {
468462
Shape wrapperShape = this.workingShape;

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/SymbolVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public Symbol listShape(ListShape shape) {
132132
@Override
133133
public Symbol setShape(SetShape shape) {
134134
Symbol reference = toSymbol(shape.getMember());
135-
return createSymbolBuilder(shape, format("Set<%s>", reference.getName()), null)
135+
return createSymbolBuilder(shape, format("(%s)[]", reference.getName()), null)
136136
.addReference(reference)
137137
.build();
138138
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ public final Void mapShape(MapShape shape) {
442442
* const deserializeAws_restJson1_1ParameterSet = (
443443
* output: any,
444444
* context: SerdeContext
445-
* ): Set<Parameter> => {
445+
* ): Parameter[] => {
446446
* return (output || []).map((entry: any) =>
447447
* deserializeAws_restJson1_1Parameter(entry, context)
448448
* );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ public final Void mapShape(MapShape shape) {
437437
*
438438
* <pre>{@code
439439
* const serializeAws_restJson1_1ParametersSet = (
440-
* input: Set<Parameter>,
440+
* input: Parameter[],
441441
* context: SerdeContext
442442
* ): any => {
443443
* return (input || []).map(entry =>

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,10 +1397,6 @@ private String getCollectionOutputParam(
13971397
// Iterate over each entry and do deser work.
13981398
outputParam += ".map(_entry => " + collectionTargetValue + ")";
13991399

1400-
// Make sets when necessary.
1401-
if (target.isSetShape()) {
1402-
outputParam = "new Set(" + outputParam + ")";
1403-
}
14041400
return outputParam;
14051401
default:
14061402
throw new CodegenException("Unexpected collection binding location `" + bindingType + "`");

smithy-typescript-codegen/src/main/resources/software/amazon/smithy/typescript/codegen/protocol-test-stub.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ const compareParts = (expectedParts: comparableParts, generatedParts: comparable
100100
*/
101101
const equivalentContents = (expected: any, generated: any): boolean => {
102102
let localExpected = expected;
103-
// Handle comparing sets to arrays properly.
104-
if (expected instanceof Set) {
105-
localExpected = Array.from(expected);
106-
}
107103

108104
// Short circuit on equality.
109105
if (localExpected == generated) {

0 commit comments

Comments
 (0)