Skip to content

Commit

Permalink
Hardcoding unwrap()s for now
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-aws committed Sep 19, 2024
1 parent 75ecb60 commit da16064
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import software.amazon.smithy.model.traits.BoxTrait;
import software.amazon.smithy.model.traits.DefaultTrait;
import software.amazon.smithy.model.traits.EnumTrait;
import software.amazon.smithy.model.traits.RequiredTrait;
import software.amazon.smithy.model.traits.UnitTypeTrait;

import java.nio.file.Path;
Expand Down Expand Up @@ -419,6 +420,7 @@ protected TokenTree operationRequestFromDafnyFunction(
"fluentMemberSetters",
fluentMemberSettersForStructure(inputShape).toString()
);
variables.put("unwrapIfNecessary", ".unwrap()");

return TokenTree.of(
evalTemplate(
Expand All @@ -432,7 +434,7 @@ pub fn from_dafny(
$sdkCrate:L::operation::$snakeCaseOperationName:L::$sdkOperationInputStruct:L::builder()
$fluentMemberSetters:L
.build()
.unwrap()
$unwrapIfNecessary:L
}
""",
variables
Expand Down Expand Up @@ -512,6 +514,9 @@ protected TokenTree operationResponseFromDafnyFunction(
"fluentMemberSetters",
fluentMemberSettersForStructure(outputShape).toString()
);
variables.put("unwrapIfNecessary",
// TODO: Can't figure out why this one is fallible but not other similar output structures
outputShape.getId().equals(ShapeId.from("com.amazonaws.dynamodb#DescribeEndpointsResponse")) ? ".unwrap()" : "");

return TokenTree.of(
evalTemplate(
Expand All @@ -525,6 +530,8 @@ pub fn from_dafny(
$sdkCrate:L::operation::$snakeCaseOperationName:L::$sdkOperationOutputStruct:L::builder()
$fluentMemberSetters:L
.build()
$unwrapIfNecessary:L
}
""",
variables
Expand Down

0 comments on commit da16064

Please sign in to comment.