Skip to content

Commit 0ab6a0f

Browse files
authored
feat: use array for SetShape (#1144)
1 parent c86b393 commit 0ab6a0f

File tree

9 files changed

+39
-47
lines changed

9 files changed

+39
-47
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@
2424
import software.amazon.smithy.model.Model;
2525
import software.amazon.smithy.model.shapes.CollectionShape;
2626
import software.amazon.smithy.model.shapes.DocumentShape;
27-
import software.amazon.smithy.model.shapes.ListShape;
2827
import software.amazon.smithy.model.shapes.MapShape;
2928
import software.amazon.smithy.model.shapes.MemberShape;
30-
import software.amazon.smithy.model.shapes.SetShape;
3129
import software.amazon.smithy.model.shapes.Shape;
3230
import software.amazon.smithy.model.shapes.StructureShape;
3331
import software.amazon.smithy.model.shapes.UnionShape;
@@ -191,10 +189,8 @@ void deserializeNamedMember(
191189
writer.openBlock("if ($L.$L === \"\") {", "}", inputLocation, locationName, () -> {
192190
if (target instanceof MapShape) {
193191
writer.write("contents.$L = {};", memberName);
194-
} else if (target instanceof ListShape) {
192+
} else if (target instanceof CollectionShape) {
195193
writer.write("contents.$L = [];", memberName);
196-
} else if (target instanceof SetShape) {
197-
writer.write("contents.$L = new Set([]);", memberName);
198194
}
199195
});
200196
}

protocol_tests/aws-ec2/models/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export interface XmlEnumsOutput {
243243
fooEnum3?: FooEnum | string;
244244
fooEnumList?: (FooEnum | string)[];
245245
fooEnumMap?: { [key: string]: FooEnum | string };
246-
fooEnumSet?: Set<FooEnum | string>;
246+
fooEnumSet?: (FooEnum | string)[];
247247
}
248248

249249
export namespace XmlEnumsOutput {
@@ -265,7 +265,7 @@ export interface XmlListsOutput {
265265

266266
renamedListMembers?: string[];
267267
stringList?: string[];
268-
stringSet?: Set<string>;
268+
stringSet?: string[];
269269
structureList?: StructureListMember[];
270270
timestampList?: Date[];
271271
}

protocol_tests/aws-ec2/protocols/Aws_ec2.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ const deserializeAws_ec2XmlEnumsOutput = (
17561756
);
17571757
}
17581758
if (output.fooEnumSet === "") {
1759-
contents.fooEnumSet = new Set([]);
1759+
contents.fooEnumSet = [];
17601760
}
17611761
if (
17621762
output["fooEnumSet"] !== undefined &&
@@ -1879,7 +1879,7 @@ const deserializeAws_ec2XmlListsOutput = (
18791879
);
18801880
}
18811881
if (output.stringSet === "") {
1882-
contents.stringSet = new Set([]);
1882+
contents.stringSet = [];
18831883
}
18841884
if (
18851885
output["stringSet"] !== undefined &&
@@ -2021,7 +2021,7 @@ const deserializeAws_ec2FooEnumMap = (
20212021
const deserializeAws_ec2FooEnumSet = (
20222022
output: any,
20232023
context: __SerdeContext
2024-
): Set<FooEnum | string> => {
2024+
): (FooEnum | string)[] => {
20252025
return (output || []).map((entry: any) => entry);
20262026
};
20272027

@@ -2054,7 +2054,7 @@ const deserializeAws_ec2StringList = (
20542054
const deserializeAws_ec2StringSet = (
20552055
output: any,
20562056
context: __SerdeContext
2057-
): Set<string> => {
2057+
): string[] => {
20582058
return (output || []).map((entry: any) => entry);
20592059
};
20602060

protocol_tests/aws-query/models/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export interface XmlEnumsOutput {
277277
fooEnum3?: FooEnum | string;
278278
fooEnumList?: (FooEnum | string)[];
279279
fooEnumMap?: { [key: string]: FooEnum | string };
280-
fooEnumSet?: Set<FooEnum | string>;
280+
fooEnumSet?: (FooEnum | string)[];
281281
}
282282

283283
export namespace XmlEnumsOutput {
@@ -299,7 +299,7 @@ export interface XmlListsOutput {
299299

300300
renamedListMembers?: string[];
301301
stringList?: string[];
302-
stringSet?: Set<string>;
302+
stringSet?: string[];
303303
structureList?: StructureListMember[];
304304
timestampList?: Date[];
305305
}

protocol_tests/aws-query/protocols/Aws_query.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,7 +2285,7 @@ const deserializeAws_queryXmlEnumsOutput = (
22852285
);
22862286
}
22872287
if (output.fooEnumSet === "") {
2288-
contents.fooEnumSet = new Set([]);
2288+
contents.fooEnumSet = [];
22892289
}
22902290
if (
22912291
output["fooEnumSet"] !== undefined &&
@@ -2408,7 +2408,7 @@ const deserializeAws_queryXmlListsOutput = (
24082408
);
24092409
}
24102410
if (output.stringSet === "") {
2411-
contents.stringSet = new Set([]);
2411+
contents.stringSet = [];
24122412
}
24132413
if (
24142414
output["stringSet"] !== undefined &&
@@ -2616,7 +2616,7 @@ const deserializeAws_queryFooEnumMap = (
26162616
const deserializeAws_queryFooEnumSet = (
26172617
output: any,
26182618
context: __SerdeContext
2619-
): Set<FooEnum | string> => {
2619+
): (FooEnum | string)[] => {
26202620
return (output || []).map((entry: any) => entry);
26212621
};
26222622

@@ -2663,7 +2663,7 @@ const deserializeAws_queryStringList = (
26632663
const deserializeAws_queryStringSet = (
26642664
output: any,
26652665
context: __SerdeContext
2666-
): Set<string> => {
2666+
): string[] => {
26672667
return (output || []).map((entry: any) => entry);
26682668
};
26692669

protocol_tests/aws-restjson/models/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ export interface AllQueryStringTypesInput {
1616
queryFloat?: number;
1717
queryInteger?: number;
1818
queryIntegerList?: number[];
19-
queryIntegerSet?: Set<number>;
19+
queryIntegerSet?: number[];
2020
queryLong?: number;
2121
queryShort?: number;
2222
queryString?: string;
2323
queryStringList?: string[];
24-
queryStringSet?: Set<string>;
24+
queryStringSet?: string[];
2525
queryTimestamp?: Date;
2626
queryTimestampList?: Date[];
2727
}
@@ -239,7 +239,7 @@ export interface InputAndOutputWithHeadersIO {
239239
headerShort?: number;
240240
headerString?: string;
241241
headerStringList?: string[];
242-
headerStringSet?: Set<string>;
242+
headerStringSet?: string[];
243243
headerTimestampList?: Date[];
244244
headerTrueBool?: boolean;
245245
}
@@ -280,7 +280,7 @@ export interface JsonEnumsInputOutput {
280280
fooEnum3?: FooEnum | string;
281281
fooEnumList?: (FooEnum | string)[];
282282
fooEnumMap?: { [key: string]: FooEnum | string };
283-
fooEnumSet?: Set<FooEnum | string>;
283+
fooEnumSet?: (FooEnum | string)[];
284284
}
285285

286286
export namespace JsonEnumsInputOutput {
@@ -299,7 +299,7 @@ export interface JsonListsInputOutput {
299299
nestedStringList?: string[][];
300300

301301
stringList?: string[];
302-
stringSet?: Set<string>;
302+
stringSet?: string[];
303303
structureList?: StructureListMember[];
304304
timestampList?: Date[];
305305
}

protocol_tests/aws-restjson/protocols/Aws_restJson1_1.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,11 +2113,9 @@ export const deserializeAws_restJson1_1InputAndOutputWithHeadersCommand = async
21132113
.map(_entry => _entry.trim());
21142114
}
21152115
if (output.headers["x-stringset"] !== undefined) {
2116-
contents.headerStringSet = new Set(
2117-
(output.headers["x-stringset"] || "")
2118-
.split(",")
2119-
.map(_entry => _entry.trim())
2120-
);
2116+
contents.headerStringSet = (output.headers["x-stringset"] || "")
2117+
.split(",")
2118+
.map(_entry => _entry.trim());
21212119
}
21222120
if (output.headers["x-timestamplist"] !== undefined) {
21232121
contents.headerTimestampList = __splitEvery(
@@ -3206,7 +3204,7 @@ const serializeAws_restJson1_1FooEnumMap = (
32063204
};
32073205

32083206
const serializeAws_restJson1_1FooEnumSet = (
3209-
input: Set<FooEnum | string>,
3207+
input: (FooEnum | string)[],
32103208
context: __SerdeContext
32113209
): any => {
32123210
const contents = [];
@@ -3261,7 +3259,7 @@ const serializeAws_restJson1_1StringList = (
32613259
};
32623260

32633261
const serializeAws_restJson1_1StringSet = (
3264-
input: Set<string>,
3262+
input: string[],
32653263
context: __SerdeContext
32663264
): any => {
32673265
const contents = [];
@@ -3420,7 +3418,7 @@ const deserializeAws_restJson1_1FooEnumMap = (
34203418
const deserializeAws_restJson1_1FooEnumSet = (
34213419
output: any,
34223420
context: __SerdeContext
3423-
): Set<FooEnum | string> => {
3421+
): (FooEnum | string)[] => {
34243422
return (output || []).map((entry: any) => entry);
34253423
};
34263424

@@ -3464,7 +3462,7 @@ const deserializeAws_restJson1_1StringList = (
34643462
const deserializeAws_restJson1_1StringSet = (
34653463
output: any,
34663464
context: __SerdeContext
3467-
): Set<string> => {
3465+
): string[] => {
34683466
return (output || []).map((entry: any) => entry);
34693467
};
34703468

protocol_tests/aws-restxml/models/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ export interface AllQueryStringTypesInput {
1616
queryFloat?: number;
1717
queryInteger?: number;
1818
queryIntegerList?: number[];
19-
queryIntegerSet?: Set<number>;
19+
queryIntegerSet?: number[];
2020
queryLong?: number;
2121
queryShort?: number;
2222
queryString?: string;
2323
queryStringList?: string[];
24-
queryStringSet?: Set<string>;
24+
queryStringSet?: string[];
2525
queryTimestamp?: Date;
2626
queryTimestampList?: Date[];
2727
}
@@ -278,7 +278,7 @@ export interface InputAndOutputWithHeadersIO {
278278
headerShort?: number;
279279
headerString?: string;
280280
headerStringList?: string[];
281-
headerStringSet?: Set<string>;
281+
headerStringSet?: string[];
282282
headerTimestampList?: Date[];
283283
headerTrueBool?: boolean;
284284
}
@@ -500,7 +500,7 @@ export interface XmlEnumsInputOutput {
500500
fooEnum3?: FooEnum | string;
501501
fooEnumList?: (FooEnum | string)[];
502502
fooEnumMap?: { [key: string]: FooEnum | string };
503-
fooEnumSet?: Set<FooEnum | string>;
503+
fooEnumSet?: (FooEnum | string)[];
504504
}
505505

506506
export namespace XmlEnumsInputOutput {
@@ -522,7 +522,7 @@ export interface XmlListsInputOutput {
522522

523523
renamedListMembers?: string[];
524524
stringList?: string[];
525-
stringSet?: Set<string>;
525+
stringSet?: string[];
526526
structureList?: StructureListMember[];
527527
timestampList?: Date[];
528528
}

protocol_tests/aws-restxml/protocols/Aws_restXml.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2835,11 +2835,9 @@ export const deserializeAws_restXmlInputAndOutputWithHeadersCommand = async (
28352835
.map(_entry => _entry.trim());
28362836
}
28372837
if (output.headers["x-stringset"] !== undefined) {
2838-
contents.headerStringSet = new Set(
2839-
(output.headers["x-stringset"] || "")
2840-
.split(",")
2841-
.map(_entry => _entry.trim())
2842-
);
2838+
contents.headerStringSet = (output.headers["x-stringset"] || "")
2839+
.split(",")
2840+
.map(_entry => _entry.trim());
28432841
}
28442842
if (output.headers["x-timestamplist"] !== undefined) {
28452843
contents.headerTimestampList = __splitEvery(
@@ -3622,7 +3620,7 @@ export const deserializeAws_restXmlXmlEnumsCommand = async (
36223620
);
36233621
}
36243622
if (data.fooEnumSet === "") {
3625-
contents.fooEnumSet = new Set([]);
3623+
contents.fooEnumSet = [];
36263624
}
36273625
if (
36283626
data["fooEnumSet"] !== undefined &&
@@ -3777,7 +3775,7 @@ export const deserializeAws_restXmlXmlListsCommand = async (
37773775
);
37783776
}
37793777
if (data.stringSet === "") {
3780-
contents.stringSet = new Set([]);
3778+
contents.stringSet = [];
37813779
}
37823780
if (
37833781
data["stringSet"] !== undefined &&
@@ -4418,7 +4416,7 @@ const serializeAws_restXmlFooEnumMap = (
44184416
};
44194417

44204418
const serializeAws_restXmlFooEnumSet = (
4421-
input: Set<FooEnum | string>,
4419+
input: (FooEnum | string)[],
44224420
context: __SerdeContext
44234421
): any => {
44244422
const collectedNodes: any = [];
@@ -4487,7 +4485,7 @@ const serializeAws_restXmlStringList = (
44874485
};
44884486

44894487
const serializeAws_restXmlStringSet = (
4490-
input: Set<string>,
4488+
input: string[],
44914489
context: __SerdeContext
44924490
): any => {
44934491
const collectedNodes: any = [];
@@ -4777,7 +4775,7 @@ const deserializeAws_restXmlFooEnumMap = (
47774775
const deserializeAws_restXmlFooEnumSet = (
47784776
output: any,
47794777
context: __SerdeContext
4780-
): Set<FooEnum | string> => {
4778+
): (FooEnum | string)[] => {
47814779
return (output || []).map((entry: any) => entry);
47824780
};
47834781

@@ -4824,7 +4822,7 @@ const deserializeAws_restXmlStringList = (
48244822
const deserializeAws_restXmlStringSet = (
48254823
output: any,
48264824
context: __SerdeContext
4827-
): Set<string> => {
4825+
): string[] => {
48284826
return (output || []).map((entry: any) => entry);
48294827
};
48304828

0 commit comments

Comments
 (0)