@@ -1105,7 +1105,6 @@ private void generateOperationRequestDeserializer(
1105
1105
+ " output: $T,\n "
1106
1106
+ " context: $L\n "
1107
1107
+ "): Promise<$T> => {" , "}" , methodName , requestType , contextType , inputType , () -> {
1108
- // TODO: deserialize path
1109
1108
// TODO: deserialize endpoint
1110
1109
// Start deserializing the response.
1111
1110
writer .openBlock ("const contents: $T = {" , "};" , inputType , () -> {
@@ -1119,6 +1118,7 @@ private void generateOperationRequestDeserializer(
1119
1118
});
1120
1119
});
1121
1120
readQueryString (context , operation , bindingIndex );
1121
+ readPath (context , operation , bindingIndex , trait );
1122
1122
readRequestHeaders (context , operation , bindingIndex , "output" );
1123
1123
List <HttpBinding > documentBindings = readRequestBody (context , operation , bindingIndex );
1124
1124
// Track all shapes bound to the document so their deserializers may be generated.
@@ -1155,6 +1155,38 @@ private void readQueryString(
1155
1155
});
1156
1156
}
1157
1157
1158
+ private void readPath (
1159
+ GenerationContext context ,
1160
+ OperationShape operation ,
1161
+ HttpBindingIndex bindingIndex ,
1162
+ HttpTrait trait
1163
+ ) {
1164
+ TypeScriptWriter writer = context .getWriter ();
1165
+ List <HttpBinding > pathBindings = bindingIndex .getRequestBindings (operation , Location .LABEL );
1166
+ if (pathBindings .isEmpty ()) {
1167
+ return ;
1168
+ }
1169
+ StringBuilder pathRegexBuilder = new StringBuilder ("/" );
1170
+ for (Segment segment : trait .getUri ().getSegments ()) {
1171
+ if (segment .isLabel ()) {
1172
+ // Create a named capture group for the segment so we can grab it later without regard to order.
1173
+ pathRegexBuilder .append (String .format ("(?<%s>.*)" , segment .getContent ()));
1174
+ } else {
1175
+ pathRegexBuilder .append (segment .getContent ());
1176
+ }
1177
+ pathRegexBuilder .append ("/" );
1178
+ }
1179
+ writer .write ("const pathRegex = new RegExp($S);" , pathRegexBuilder .toString ());
1180
+ writer .write ("const parsedPath: RegExpMatchArray = output.endpoint.path.match(pathRegex);" );
1181
+ for (HttpBinding binding : pathBindings ) {
1182
+ Shape target = context .getModel ().expectShape (binding .getMember ().getTarget ());
1183
+ String memberName = context .getSymbolProvider ().toMemberName (binding .getMember ());
1184
+ String labelValue = getOutputValue (context , binding .getLocation (),
1185
+ "parsedPath.groups." + binding .getLocationName (), binding .getMember (), target );
1186
+ writer .write ("contents.$L = $L;" , memberName , labelValue );
1187
+ }
1188
+ }
1189
+
1158
1190
private void generateOperationResponseDeserializer (
1159
1191
GenerationContext context ,
1160
1192
OperationShape operation ,
0 commit comments