@@ -1685,8 +1685,23 @@ private void readDirectQueryBindings(GenerationContext context, List<HttpBinding
1685
1685
String memberName = context .getSymbolProvider ().toMemberName (binding .getMember ());
1686
1686
writer .openBlock ("if (query['$L'] !== undefined) {" , "}" , binding .getLocationName (), () -> {
1687
1687
Shape target = context .getModel ().expectShape (binding .getMember ().getTarget ());
1688
- String queryValue = getOutputValue (context , binding .getLocation (),
1689
- "query['" + binding .getLocationName () + "'] as string" ,
1688
+ if (target instanceof CollectionShape ) {
1689
+ writer .write ("const decoded = Array.isArray(query['$1L']) ? (query['$1L'] as string[])"
1690
+ + ".map(e => decodeURIComponent(e)) : [decodeURIComponent(query['$1L'] as string)];" ,
1691
+ binding .getLocationName ());
1692
+ } else {
1693
+ writer .addImport ("SerializationException" ,
1694
+ "__SerializationException" ,
1695
+ "@aws-smithy/server-common" );
1696
+ writer .openBlock ("if (Array.isArray(query['$1L'])) {" , "}" ,
1697
+ binding .getLocationName (),
1698
+ () -> {
1699
+ writer .write ("throw new __SerializationException();" );
1700
+ });
1701
+ writer .write ("const decoded = decodeURIComponent(query['$1L'] as string);" ,
1702
+ binding .getLocationName ());
1703
+ }
1704
+ String queryValue = getOutputValue (context , binding .getLocation (), "decoded" ,
1690
1705
binding .getMember (), target );
1691
1706
writer .write ("contents.$L = $L;" , memberName , queryValue );
1692
1707
});
@@ -1703,10 +1718,23 @@ private void readMappedQueryBindings(GenerationContext context, HttpBinding mapp
1703
1718
valueType = "string[]" ;
1704
1719
}
1705
1720
writer .write ("let parsedQuery: { [key: string]: $L } = {}" , valueType );
1706
- String parsedValue = getOutputValue (context , mappedBinding .getLocation (), "value as string" ,
1707
- target .getValue (), valueShape );
1721
+ String parsedValue = getOutputValue (context , mappedBinding .getLocation (),
1722
+ "decoded" , target .getValue (), valueShape );
1708
1723
writer .openBlock ("for (const [key, value] of Object.entries(query)) {" , "}" , () -> {
1709
- writer .write ("parsedQuery[key] = $L;" , parsedValue );
1724
+ if (valueShape instanceof CollectionShape ) {
1725
+ writer .write ("const decoded = Array.isArray(value) ? (value as string[])"
1726
+ + ".map(e => decodeURIComponent(e)) : [decodeURIComponent(value as string)];" );
1727
+ } else {
1728
+ writer .addImport ("SerializationException" ,
1729
+ "__SerializationException" ,
1730
+ "@aws-smithy/server-common" );
1731
+ writer .openBlock ("if (Array.isArray(value)) {" , "}" ,
1732
+ () -> {
1733
+ writer .write ("throw new __SerializationException();" );
1734
+ });
1735
+ writer .write ("const decoded = decodeURIComponent(value as string);" );
1736
+ }
1737
+ writer .write ("parsedQuery[decodeURIComponent(key)] = $L;" , parsedValue );
1710
1738
});
1711
1739
String memberName = context .getSymbolProvider ().toMemberName (mappedBinding .getMember ());
1712
1740
writer .write ("contents.$L = parsedQuery;" , memberName );
@@ -1745,8 +1773,11 @@ private void readPath(
1745
1773
for (HttpBinding binding : pathBindings ) {
1746
1774
Shape target = context .getModel ().expectShape (binding .getMember ().getTarget ());
1747
1775
String memberName = context .getSymbolProvider ().toMemberName (binding .getMember ());
1776
+ // since this is in the path, we should decode early
1777
+ String dataSource = String .format ("decodeURIComponent(parsedPath.groups.%s)" ,
1778
+ binding .getLocationName ());
1748
1779
String labelValue = getOutputValue (context , binding .getLocation (),
1749
- "parsedPath.groups." + binding . getLocationName () , binding .getMember (), target );
1780
+ dataSource , binding .getMember (), target );
1750
1781
writer .write ("contents.$L = $L;" , memberName , labelValue );
1751
1782
}
1752
1783
});
@@ -2522,11 +2553,11 @@ private String getCollectionOutputParam(
2522
2553
switch (bindingType ) {
2523
2554
case QUERY_PARAMS :
2524
2555
case QUERY :
2525
- return String .format ("(Array.isArray( %1$s) ? (%1$s[]) : [%1$s]) .map(_entry => %2$s)" ,
2556
+ return String .format ("%1$s.map(_entry => %2$s)" ,
2526
2557
dataSource , collectionTargetValue );
2527
2558
case LABEL :
2528
2559
dataSource = "(" + dataSource + " || \" \" )" ;
2529
- // Split these values on commas .
2560
+ // Split these values on slashes .
2530
2561
outputParam = "" + dataSource + ".split('/')" ;
2531
2562
2532
2563
// Iterate over each entry and do deser work.
0 commit comments