Skip to content

Commit 122b16e

Browse files
authored
Smithy 1.9 Support (#1335)
* Smithy 1.9 Support * Regenerated Clients
1 parent efb96c5 commit 122b16e

File tree

1,004 files changed

+53769
-26476
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,004 files changed

+53769
-26476
lines changed

codegen/protocol-test-codegen/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ plugins {
2020
}
2121

2222
dependencies {
23-
implementation("software.amazon.smithy:smithy-aws-protocol-tests:[1.6.0, 1.9.0[")
23+
implementation("software.amazon.smithy:smithy-aws-protocol-tests:[1.6.0,1.10.0[")
2424
compile(project(":smithy-aws-go-codegen"))
2525
}
2626

codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/AwsProtocolUtils.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ static void generateHttpProtocolTests(GenerationContext context) {
195195
.service(ShapeId.from("aws.protocoltests.restjson#RestJson"))
196196
.operation(ShapeId.from("aws.protocoltests.restjson#InlineDocumentAsPayload"))
197197
.build(),
198+
HttpProtocolUnitTestGenerator.SkipTest.builder()
199+
.service(ShapeId.from("aws.protocoltests.restjson#RestJson"))
200+
.operation(ShapeId.from("aws.protocoltests.restjson#DocumentType"))
201+
.build(),
202+
HttpProtocolUnitTestGenerator.SkipTest.builder()
203+
.service(ShapeId.from("aws.protocoltests.restjson#RestJson"))
204+
.operation(ShapeId.from("aws.protocoltests.restjson#DocumentTypeAsPayload"))
205+
.build(),
198206

199207
// Null lists/maps without sparse tag
200208
HttpProtocolUnitTestGenerator.SkipTest.builder()
@@ -226,9 +234,16 @@ static void generateHttpProtocolTests(GenerationContext context) {
226234
.operation(ShapeId.from("aws.protocoltests.json10#EmptyInputAndEmptyOutput"))
227235
.addTestName("AwsJson10EmptyInputAndEmptyOutput")
228236
.build()
229-
));
237+
));
230238

231239
Set<HttpProtocolUnitTestGenerator.SkipTest> outputSkipTests = new TreeSet<>(SetUtils.of(
240+
// REST-JSON optional (SHOULD) test cases
241+
HttpProtocolUnitTestGenerator.SkipTest.builder()
242+
.service(ShapeId.from("aws.protocoltests.restjson#RestJson"))
243+
.operation(ShapeId.from("aws.protocoltests.restjson#JsonMaps"))
244+
.addTestName("RestJsonDeserializesDenseSetMapAndSkipsNull")
245+
.build(),
246+
232247
// REST-XML opinionated test - prefix headers as empty vs nil map
233248
HttpProtocolUnitTestGenerator.SkipTest.builder()
234249
.service(ShapeId.from("aws.protocoltests.restxml#RestXml"))

codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/DocumentMemberSerVisitor.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,36 @@ public Void longShape(LongShape shape) {
121121
@Override
122122
public Void floatShape(FloatShape shape) {
123123
String source = CodegenUtils.getAsValueIfDereferencable(pointableIndex, member, dataSource);
124-
context.getWriter().write("$L.Float($L)", dataDest, source);
124+
GoWriter writer = context.getWriter();
125+
handleDecimal(writer, dataDest, "float64(" + source + ")",
126+
() -> writer.write("$L.Float($L)", dataDest, source));
125127
return null;
126128
}
127129

128130
@Override
129131
public Void doubleShape(DoubleShape shape) {
130132
String source = CodegenUtils.getAsValueIfDereferencable(pointableIndex, member, dataSource);
131-
context.getWriter().write("$L.Double($L)", dataDest, source);
133+
GoWriter writer = context.getWriter();
134+
handleDecimal(writer, dataDest, source, () -> writer.write("$L.Double($L)", dataDest, source));
132135
return null;
133136
}
134137

138+
private void handleDecimal(GoWriter writer, String dataDest, String source, Runnable defaultCase) {
139+
writer.addUseImports(SmithyGoDependency.MATH);
140+
writer.openBlock("switch {", "}", () -> {
141+
writer.openBlock("case math.IsNaN($L):", "", source, () -> {
142+
writer.write("$L.String(\"NaN\")", dataDest);
143+
});
144+
writer.openBlock("case math.IsInf($L, 1):", "", source, () -> {
145+
writer.write("$L.String(\"Infinity\")", dataDest);
146+
});
147+
writer.openBlock("case math.IsInf($L, -1):", "", source, () -> {
148+
writer.write("$L.String(\"-Infinity\")", dataDest);
149+
});
150+
writer.openBlock("default:", "", defaultCase);
151+
});
152+
}
153+
135154
@Override
136155
public Void timestampShape(TimestampShape shape) {
137156
String source = CodegenUtils.getAsValueIfDereferencable(pointableIndex, member, dataSource);

codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/JsonMemberDeserVisitor.java

Lines changed: 73 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ public class JsonMemberDeserVisitor implements ShapeVisitor<Void> {
6262
private final Format timestampFormat;
6363
private final GoPointableIndex pointableIndex;
6464

65-
public JsonMemberDeserVisitor(GenerationContext context, MemberShape member, String dataDest, Format timestampFormat) {
65+
public JsonMemberDeserVisitor(
66+
GenerationContext context, MemberShape member, String dataDest, Format timestampFormat
67+
) {
6668
this.context = context;
6769
this.member = member;
6870
this.dataDest = dataDest;
@@ -147,11 +149,11 @@ public Void longShape(LongShape shape) {
147149

148150
/**
149151
* Deserializes a number without a fractional value.
150-
*
152+
* <p>
151153
* The 64-bit integer representation of the number is stored in the variable {@code i64}.
152154
*
153155
* @param shape The shape being deserialized.
154-
* @param cast A wrapping of {@code i64} to cast it to the proper type.
156+
* @param cast A wrapping of {@code i64} to cast it to the proper type.
155157
*/
156158
private void handleInteger(Shape shape, String cast) {
157159
GoWriter writer = context.getWriter();
@@ -164,11 +166,11 @@ private void handleInteger(Shape shape, String cast) {
164166

165167
/**
166168
* Deserializes a json number into a json token.
167-
*
169+
* <p>
168170
* The number token is stored under the variable {@code jtv}.
169171
*
170172
* @param shape The shape being deserialized.
171-
* @param r A runnable that runs after the value has been parsed, before the scope closes.
173+
* @param r A runnable that runs after the value has been parsed, before the scope closes.
172174
*/
173175
private void handleNumber(Shape shape, Runnable r) {
174176
GoWriter writer = context.getWriter();
@@ -185,35 +187,91 @@ private void handleNumber(Shape shape, Runnable r) {
185187
});
186188
}
187189

190+
/**
191+
* Deserializes a json arbitrary precision number into a json token.
192+
* <p>
193+
* The number token is stored under the variable {@code jtv}.
194+
*
195+
* @param shape The shape being deserialized.
196+
* @param jsonNumber A runnable that runs after the value has been parsed to a json.Number, before the scope closes.
197+
* @param jsonString A runnable that runs after the value has been parsed to a string, before the scope closes.
198+
*/
199+
private void handleDecimal(Shape shape, Runnable jsonNumber, Runnable jsonString) {
200+
GoWriter writer = context.getWriter();
201+
ServiceShape service = context.getService();
202+
203+
writer.addUseImports(SmithyGoDependency.FMT);
204+
writer.openBlock("if value != nil {", "}", () -> {
205+
writer.openBlock("switch jtv := value.(type) {", "}", () -> {
206+
writer.openBlock("case json.Number:", "", jsonNumber);
207+
if (jsonString != null) {
208+
writer.openBlock("case string:", "", jsonString);
209+
}
210+
writer.openBlock("default:", "", () -> {
211+
writer.write("return fmt.Errorf(\"expected $L to be a JSON Number, got %T instead\", value)",
212+
shape.getId().getName(service));
213+
});
214+
});
215+
});
216+
}
217+
188218
@Override
189219
public Void floatShape(FloatShape shape) {
190220
handleFloat(shape, CodegenUtils.getAsPointerIfPointable(context.getModel(), context.getWriter(),
191-
pointableIndex, member, "float32(f64)"));
221+
pointableIndex, member, "float32(f64)"), true);
192222
return null;
193223
}
194224

195225
@Override
196226
public Void doubleShape(DoubleShape shape) {
197227
handleFloat(shape, CodegenUtils.getAsPointerIfPointable(context.getModel(), context.getWriter(),
198-
pointableIndex, member, "f64"));
228+
pointableIndex, member, "f64"), true);
199229
return null;
200230
}
201231

202232
/**
203233
* Deserializes a number with a fractional value.
204-
*
234+
* <p>
205235
* The 64-bit float representation of the number is stored in the variable {@code f64}.
206236
*
207237
* @param shape The shape being deserialized.
208-
* @param cast A wrapping of {@code f64} to cast it to the proper type.
238+
* @param cast A wrapping of {@code f64} to cast it to the proper type.
209239
*/
210-
private void handleFloat(Shape shape, String cast) {
240+
private void handleFloat(Shape shape, String cast, boolean handleNonNumbers) {
211241
GoWriter writer = context.getWriter();
212-
handleNumber(shape, () -> {
242+
243+
Runnable jsonString = null;
244+
245+
if (handleNonNumbers) {
246+
jsonString = () -> {
247+
writer.addUseImports(SmithyGoDependency.STRINGS);
248+
writer.addUseImports(SmithyGoDependency.MATH);
249+
250+
writer.write("var f64 float64");
251+
writer.openBlock("switch {", "}", () -> {
252+
writer.openBlock("case strings.EqualFold(jtv, \"NaN\"):", "", () -> {
253+
writer.write("f64 = math.NaN()");
254+
});
255+
writer.openBlock("case strings.EqualFold(jtv, \"Infinity\"):", "", () -> {
256+
writer.write("f64 = math.Inf(1)");
257+
});
258+
writer.openBlock("case strings.EqualFold(jtv, \"-Infinity\"):", "", () -> {
259+
writer.write("f64 = math.Inf(-1)");
260+
});
261+
writer.openBlock("default:", "", () -> {
262+
writer.addUseImports(SmithyGoDependency.FMT);
263+
writer.write("return fmt.Errorf(\"unknown JSON number value: %s\", jtv)");
264+
});
265+
});
266+
writer.write("$L = $L", dataDest, cast);
267+
};
268+
}
269+
270+
handleDecimal(shape, () -> {
213271
writer.write("f64, err := jtv.Float64()");
214272
writer.write("if err != nil { return err }");
215273
writer.write("$L = $L", dataDest, cast);
216-
});
274+
}, jsonString);
217275
}
218276

219277
@Override
@@ -233,11 +291,11 @@ public Void stringShape(StringShape shape) {
233291

234292
/**
235293
* Deserializes a json string into a json token.
236-
*
294+
* <p>
237295
* The number token is stored under the variable {@code jtv}.
238296
*
239297
* @param shape The shape being deserialized.
240-
* @param r A runnable that runs after the value has been parsed, before the scope closes.
298+
* @param r A runnable that runs after the value has been parsed, before the scope closes.
241299
*/
242300
private void handleString(Shape shape, Runnable r) {
243301
GoWriter writer = context.getWriter();
@@ -279,7 +337,7 @@ public Void timestampShape(TimestampShape shape) {
279337
case EPOCH_SECONDS:
280338
writer.addUseImports(SmithyGoDependency.SMITHY_PTR);
281339
handleFloat(shape, CodegenUtils.getAsPointerIfPointable(context.getModel(), context.getWriter(),
282-
pointableIndex, member, "smithytime.ParseEpochSeconds(f64)"));
340+
pointableIndex, member, "smithytime.ParseEpochSeconds(f64)"), false);
283341
break;
284342
default:
285343
throw new CodegenException(String.format("Unknown timestamp format %s", timestampFormat));

config/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ require (
99
github.com/aws/aws-sdk-go-v2/internal/ini v1.1.0
1010
github.com/aws/aws-sdk-go-v2/service/sso v1.3.0
1111
github.com/aws/aws-sdk-go-v2/service/sts v1.5.0
12-
github.com/aws/smithy-go v1.5.0
13-
github.com/google/go-cmp v0.5.4
12+
github.com/aws/smithy-go v1.5.1-0.20210713172319-36596d2cf389
13+
github.com/google/go-cmp v0.5.6
1414
)
1515

1616
replace github.com/aws/aws-sdk-go-v2 => ../

config/go.sum

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
github.com/aws/smithy-go v1.5.0 h1:2grDq7LxZlo8BZUDeqRfQnQWLZpInmh2TLPPkJku3YM=
2-
github.com/aws/smithy-go v1.5.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
1+
github.com/aws/smithy-go v1.5.1-0.20210713172319-36596d2cf389 h1:Cf9DBozvg4VNPK9IDi8tTaXY27GVqQV2oYgh5jYxkAE=
2+
github.com/aws/smithy-go v1.5.1-0.20210713172319-36596d2cf389/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
33
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
54
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
5+
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
6+
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
67
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
78
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
89
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=

credentials/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ require (
77
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.2.0
88
github.com/aws/aws-sdk-go-v2/service/sso v1.3.0
99
github.com/aws/aws-sdk-go-v2/service/sts v1.5.0
10-
github.com/aws/smithy-go v1.5.0
11-
github.com/google/go-cmp v0.5.4
10+
github.com/aws/smithy-go v1.5.1-0.20210713172319-36596d2cf389
11+
github.com/google/go-cmp v0.5.6
1212
)
1313

1414
replace github.com/aws/aws-sdk-go-v2 => ../

credentials/go.sum

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
github.com/aws/smithy-go v1.5.0 h1:2grDq7LxZlo8BZUDeqRfQnQWLZpInmh2TLPPkJku3YM=
2-
github.com/aws/smithy-go v1.5.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
1+
github.com/aws/smithy-go v1.5.1-0.20210713172319-36596d2cf389 h1:Cf9DBozvg4VNPK9IDi8tTaXY27GVqQV2oYgh5jYxkAE=
2+
github.com/aws/smithy-go v1.5.1-0.20210713172319-36596d2cf389/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
33
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
54
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
5+
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
6+
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
67
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
78
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
89
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=

example/service/s3/listObjects/go.sum

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
github.com/aws/smithy-go v1.5.0 h1:2grDq7LxZlo8BZUDeqRfQnQWLZpInmh2TLPPkJku3YM=
2-
github.com/aws/smithy-go v1.5.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
1+
github.com/aws/smithy-go v1.5.1-0.20210713172319-36596d2cf389 h1:Cf9DBozvg4VNPK9IDi8tTaXY27GVqQV2oYgh5jYxkAE=
2+
github.com/aws/smithy-go v1.5.1-0.20210713172319-36596d2cf389/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
33
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
54
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
5+
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
6+
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
67
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
78
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
89
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=

example/service/s3/usingPrivateLink/go.sum

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
github.com/aws/smithy-go v1.5.0 h1:2grDq7LxZlo8BZUDeqRfQnQWLZpInmh2TLPPkJku3YM=
2-
github.com/aws/smithy-go v1.5.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
1+
github.com/aws/smithy-go v1.5.1-0.20210713172319-36596d2cf389 h1:Cf9DBozvg4VNPK9IDi8tTaXY27GVqQV2oYgh5jYxkAE=
2+
github.com/aws/smithy-go v1.5.1-0.20210713172319-36596d2cf389/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
33
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
54
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
5+
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
6+
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
67
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
78
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
89
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=

0 commit comments

Comments
 (0)