Fix codegen to ignore httpLabel on non-input shapes per Smithy spec#6789
Fix codegen to ignore httpLabel on non-input shapes per Smithy spec#6789
Conversation
dd6a8b4 to
cbb38f4
Compare
codegen/src/main/java/software/amazon/awssdk/codegen/AddShapes.java
Outdated
Show resolved
Hide resolved
codegen/src/main/java/software/amazon/awssdk/codegen/AddShapes.java
Outdated
Show resolved
Hide resolved
codegen/src/test/resources/software/amazon/awssdk/codegen/uri-on-non-input-shape-service.json
Show resolved
Hide resolved
codegen/src/main/java/software/amazon/awssdk/codegen/AddShapes.java
Outdated
Show resolved
Hide resolved
| MemberModel requiredMemberModel = requestShapeModel.findMemberModelByC2jName(queryParamName); | ||
|
|
||
| assertThat(requestShapeModel.getRequired()).contains(queryParamName); | ||
| assertThat(requiredMemberModel.getHttp().getLocation()).isEqualTo(Location.QUERY_STRING); |
There was a problem hiding this comment.
why are we removing this assertion ?
There was a problem hiding this comment.
Because it was asserting the buggy behavior. NestedQueryParameterOperation is not a direct operation input/output/errors.
I should have added an assert null instead (null would result in the default behavior of it being serialized to the payload instead)
| .getter(getter(NestedQueryParameterOperation::queryParamOne)) | ||
| .setter(setter(Builder::queryParamOne)) | ||
| .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("QueryParamOne").build(), | ||
| .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QueryParamOne").build(), |
There was a problem hiding this comment.
I see here the MarshallLocation of existing test case is getting changed , any reason on why the existing shape is getting changed ?
There was a problem hiding this comment.
Same reason as above, "location":"querystring" on a nested member that is not an input/output/errors should go in the payload.
| .anyMatch(o -> allC2jShapes.get(o.getOutput().getShape()).equals(shape)); | ||
| } | ||
|
|
||
| private boolean isDirectOperationShape(Shape shape, Map<String, Shape> allC2jShapes) { |
There was a problem hiding this comment.
Nit: Can we rename this to isDirectInputOutputOrErrorShape
There was a problem hiding this comment.
Or maybe just isTopLevelShape?
joviegas
left a comment
There was a problem hiding this comment.
For the changes you discussed offline
codegen/src/main/java/software/amazon/awssdk/codegen/AddShapes.java
Outdated
Show resolved
Hide resolved
codegen/src/main/java/software/amazon/awssdk/codegen/AddShapes.java
Outdated
Show resolved
Hide resolved
codegen/src/main/java/software/amazon/awssdk/codegen/AddShapes.java
Outdated
Show resolved
Hide resolved
| .anyMatch(o -> allC2jShapes.get(o.getOutput().getShape()).equals(shape)); | ||
| } | ||
|
|
||
| private boolean isDirectOperationShape(Shape shape, Map<String, Shape> allC2jShapes) { |
There was a problem hiding this comment.
Or maybe just isTopLevelShape?
| private boolean isDirectInputShape(Shape shape, Map<String, Shape> allC2jShapes) { | ||
| return builder.getService().getOperations().values().stream() | ||
| .filter(o -> o.getInput() != null) | ||
| .anyMatch(o -> allC2jShapes.get(o.getInput().getShape()).equals(shape)); |
There was a problem hiding this comment.
This probably isnt a big deal (but I ran into it in the Smithy POC...) - the equals method in shape is just a reference check. That is probably actually what we want here so its fine. But would be an issue if the shape itself was duplicated or something.
d7b62c3 to
67931ac
Compare
05c368a to
7929105
Compare
|



Context
Per the Smithy spec, httpLabel on non-input shapes "has no meaning and is simply ignored." However,
AddShapes.findRequestUri()was throwing aModelInvalidExceptionwhen it found a shape with a URI bound member that wasn't a direct operation input.When the shape isn't a direct operation input, it now returns empty instead of throwing (results in codegen ignoring this member). The existing validation for operations with a missing
requestUriis unchanged.Test coverage matrix
The following table shows whether a combination of location / shape has meaning in codegen or is ignored (member gets serialized in PAYLOAD):