@@ -311,19 +311,19 @@ private ParameterHttpMapping generateParameterHttpMapping(Shape parentShape,
311311
312312 ParameterHttpMapping mapping = new ParameterHttpMapping ();
313313
314- // Per the Smithy spec, HTTP binding traits are only honored on specific shape types.
315- // When a trait is ignored, its locationName is also ignored so the member name is used as the wire name.
316- // https://smithy.io/2.0/spec/http-bindings.html
317- Location location = resolveLocation (parentShape , member , allC2jShapes );
318- boolean locationIgnored = member .getLocation () != null && location == null ;
314+ // Per the Smithy spec, HTTP binding traits are only honored on top-level shapes (direct operation
315+ // input/output/error). When a location trait is ignored, its locationName is also ignored so the member
316+ // name is used as the wire name. https://smithy.io/2.0/spec/http-bindings.html
317+ Location resolvedLocation = resolveLocation (parentShape , member , allC2jShapes );
318+ boolean locationIgnored = member .getLocation () != null && resolvedLocation == null ;
319319
320320 Shape memberShape = allC2jShapes .get (member .getShape ());
321321 String marshallLocationName = locationIgnored
322322 ? memberName : deriveMarshallerLocationName (memberShape , memberName , member , protocol );
323323 String unmarshallLocationName = locationIgnored
324324 ? memberName : deriveUnmarshallerLocationName (memberShape , memberName , member );
325325
326- mapping .withLocation (location )
326+ mapping .withLocation (resolvedLocation )
327327 .withPayload (member .isPayload ()).withStreaming (member .isStreaming ())
328328 .withFlattened (isFlattened (member , memberShape ))
329329 .withUnmarshallLocationName (unmarshallLocationName )
@@ -344,7 +344,7 @@ private Location resolveLocation(Shape parentShape, Member member, Map<String, S
344344 return isDirectInputShape (parentShape , allC2jShapes ) ? location : null ;
345345 case HEADER :
346346 case HEADERS :
347- return isDirectOperationShape (parentShape , allC2jShapes ) ? location : null ;
347+ return isTopLevelShape (parentShape , allC2jShapes ) ? location : null ;
348348 case STATUS_CODE :
349349 return isDirectOutputShape (parentShape , allC2jShapes ) ? location : null ;
350350 default :
@@ -364,7 +364,7 @@ private boolean isDirectOutputShape(Shape shape, Map<String, Shape> allC2jShapes
364364 .anyMatch (o -> allC2jShapes .get (o .getOutput ().getShape ()).equals (shape ));
365365 }
366366
367- private boolean isDirectOperationShape (Shape shape , Map <String , Shape > allC2jShapes ) {
367+ private boolean isTopLevelShape (Shape shape , Map <String , Shape > allC2jShapes ) {
368368 return builder .getService ().getOperations ().values ().stream ()
369369 .anyMatch (o -> (o .getInput () != null && allC2jShapes .get (o .getInput ().getShape ()).equals (shape ))
370370 || (o .getOutput () != null && allC2jShapes .get (o .getOutput ().getShape ()).equals (shape ))
0 commit comments