Skip to content

Commit 0644a83

Browse files
authored
chore(codegen): pin smithy to 1.8.x (#2499)
1 parent 6ef34b5 commit 0644a83

File tree

6 files changed

+189
-10
lines changed

6 files changed

+189
-10
lines changed

Diff for: codegen/protocol-test-codegen/build.gradle.kts

+1-1
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.7.0, 1.8.0[")
23+
implementation("software.amazon.smithy:smithy-aws-protocol-tests:[1.8.0, 1.9.0[")
2424
compile(project(":smithy-aws-typescript-codegen"))
2525
}
2626

Diff for: codegen/smithy-aws-typescript-codegen/build.gradle.kts

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ extra["displayName"] = "Smithy :: AWS :: Typescript :: Codegen"
1818
extra["moduleName"] = "software.amazon.smithy.aws.typescript.codegen"
1919

2020
dependencies {
21-
api("software.amazon.smithy:smithy-aws-cloudformation-traits:[1.7.0, 1.8.0[")
22-
api("software.amazon.smithy:smithy-aws-traits:[1.7.0, 1.8.0[")
23-
api("software.amazon.smithy:smithy-waiters:[1.7.0, 1.8.0[")
24-
api("software.amazon.smithy:smithy-aws-iam-traits:[1.7.0, 1.8.0[")
21+
api("software.amazon.smithy:smithy-aws-cloudformation-traits:[1.8.0, 1.9.0[")
22+
api("software.amazon.smithy:smithy-aws-traits:[1.8.0, 1.9.0[")
23+
api("software.amazon.smithy:smithy-waiters:[1.8.0, 1.9.0[")
24+
api("software.amazon.smithy:smithy-aws-iam-traits:[1.8.0, 1.9.0[")
2525
api("software.amazon.smithy.typescript:smithy-typescript-codegen:0.3.0")
2626
}

Diff for: protocol_tests/aws-query/models/models_0.ts

+15
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,21 @@ export namespace ComplexError {
115115
});
116116
}
117117

118+
export interface CustomCodeError extends __SmithyException, $MetadataBearer {
119+
name: "CustomCodeError";
120+
$fault: "client";
121+
Message?: string;
122+
}
123+
124+
export namespace CustomCodeError {
125+
/**
126+
* @internal
127+
*/
128+
export const filterSensitiveLog = (obj: CustomCodeError): any => ({
129+
...obj,
130+
});
131+
}
132+
118133
export interface GreetingWithErrorsOutput {
119134
greeting?: string;
120135
}

Diff for: protocol_tests/aws-query/protocols/Aws_query.ts

+34
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import { XmlTimestampsCommandInput, XmlTimestampsCommandOutput } from "../comman
5050
import {
5151
ComplexError,
5252
ComplexNestedErrorData,
53+
CustomCodeError,
5354
EmptyInputAndEmptyOutputInput,
5455
EmptyInputAndEmptyOutputOutput,
5556
FlattenedXmlMapOutput,
@@ -843,6 +844,14 @@ const deserializeAws_queryGreetingWithErrorsCommandError = async (
843844
$metadata: deserializeMetadata(output),
844845
};
845846
break;
847+
case "CustomCodeError":
848+
case "aws.protocoltests.query#CustomCodeError":
849+
response = {
850+
...(await deserializeAws_queryCustomCodeErrorResponse(parsedOutput, context)),
851+
name: errorCode,
852+
$metadata: deserializeMetadata(output),
853+
};
854+
break;
846855
case "InvalidGreeting":
847856
case "aws.protocoltests.query#InvalidGreeting":
848857
response = {
@@ -1825,6 +1834,21 @@ const deserializeAws_queryComplexErrorResponse = async (
18251834
return contents;
18261835
};
18271836

1837+
const deserializeAws_queryCustomCodeErrorResponse = async (
1838+
parsedOutput: any,
1839+
context: __SerdeContext
1840+
): Promise<CustomCodeError> => {
1841+
const body = parsedOutput.body;
1842+
const deserialized: any = deserializeAws_queryCustomCodeError(body.Error, context);
1843+
const contents: CustomCodeError = {
1844+
name: "CustomCodeError",
1845+
$fault: "client",
1846+
$metadata: deserializeMetadata(parsedOutput),
1847+
...deserialized,
1848+
};
1849+
return contents;
1850+
};
1851+
18281852
const deserializeAws_queryInvalidGreetingResponse = async (
18291853
parsedOutput: any,
18301854
context: __SerdeContext
@@ -2171,6 +2195,16 @@ const deserializeAws_queryComplexNestedErrorData = (output: any, context: __Serd
21712195
return contents;
21722196
};
21732197

2198+
const deserializeAws_queryCustomCodeError = (output: any, context: __SerdeContext): CustomCodeError => {
2199+
let contents: any = {
2200+
Message: undefined,
2201+
};
2202+
if (output["Message"] !== undefined) {
2203+
contents.Message = output["Message"];
2204+
}
2205+
return contents;
2206+
};
2207+
21742208
const deserializeAws_queryEmptyInputAndEmptyOutputOutput = (
21752209
output: any,
21762210
context: __SerdeContext

Diff for: protocol_tests/aws-query/tests/functional/awsquery.spec.ts

+56-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { XmlMapsCommand } from "../../commands/XmlMapsCommand";
2727
import { XmlMapsXmlNameCommand } from "../../commands/XmlMapsXmlNameCommand";
2828
import { XmlNamespacesCommand } from "../../commands/XmlNamespacesCommand";
2929
import { XmlTimestampsCommand } from "../../commands/XmlTimestampsCommand";
30-
import { ComplexError, InvalidGreeting } from "../../models/models_0";
30+
import { ComplexError, CustomCodeError, InvalidGreeting } from "../../models/models_0";
3131
import { HttpHandlerOptions, HeaderBag } from "@aws-sdk/types";
3232
import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
3333
import { Readable } from "stream";
@@ -545,6 +545,59 @@ it("QueryInvalidGreetingError:Error:GreetingWithErrors", async () => {
545545
fail("Expected an exception to be thrown from response");
546546
});
547547

548+
/**
549+
* Parses customized XML errors
550+
*/
551+
// Manually skipping to unblock smithy-1.8.x update.
552+
// TODO: Consume AWSQueryError trait as a follow-up.
553+
it.skip("QueryCustomizedError:Error:GreetingWithErrors", async () => {
554+
const client = new QueryProtocolClient({
555+
...clientParams,
556+
requestHandler: new ResponseDeserializationTestHandler(
557+
false,
558+
402,
559+
{
560+
"content-type": "text/xml",
561+
},
562+
`<ErrorResponse>
563+
<Error>
564+
<Type>Sender</Type>
565+
<Code>Customized</Code>
566+
<Message>Hi</Message>
567+
</Error>
568+
<RequestId>foo-id</RequestId>
569+
</ErrorResponse>
570+
`
571+
),
572+
});
573+
574+
const params: any = {};
575+
const command = new GreetingWithErrorsCommand(params);
576+
577+
try {
578+
await client.send(command);
579+
} catch (err) {
580+
if (err.name !== "CustomCodeError") {
581+
console.log(err);
582+
fail(`Expected a CustomCodeError to be thrown, got ${err.name} instead`);
583+
return;
584+
}
585+
const r: any = err;
586+
expect(r["$metadata"].httpStatusCode).toBe(402);
587+
const paramsToValidate: any = [
588+
{
589+
message: "Hi",
590+
},
591+
][0];
592+
Object.keys(paramsToValidate).forEach((param) => {
593+
expect(r[param]).toBeDefined();
594+
expect(equivalentContents(r[param], paramsToValidate[param])).toBe(true);
595+
});
596+
return;
597+
}
598+
fail("Expected an exception to be thrown from response");
599+
});
600+
548601
it("QueryComplexError:Error:GreetingWithErrors", async () => {
549602
const client = new QueryProtocolClient({
550603
...clientParams,
@@ -613,7 +666,7 @@ it("QueryIgnoresWrappingXmlName:Response", async () => {
613666
{
614667
"content-type": "text/xml",
615668
},
616-
`<IgnoresWrappingXmlNameResponse xmlns="http://foo.com" xmlns="https://example.com/">
669+
`<IgnoresWrappingXmlNameResponse xmlns="https://example.com/">
617670
<IgnoresWrappingXmlNameResult>
618671
<foo>bar</foo>
619672
</IgnoresWrappingXmlNameResult>
@@ -2528,7 +2581,7 @@ it("QueryXmlNamespaces:Response", async () => {
25282581
{
25292582
"content-type": "text/xml",
25302583
},
2531-
`<XmlNamespacesResponse xmlns="http://foo.com" xmlns="https://example.com/">
2584+
`<XmlNamespacesResponse xmlns="https://example.com/">
25322585
<XmlNamespacesResult>
25332586
<nested>
25342587
<foo xmlns:baz="http://baz.com">Foo</foo>

Diff for: protocol_tests/aws-restjson/tests/functional/restjson1.spec.ts

+79-2
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,38 @@ it("RestJsonQueryStringMap:Request", async () => {
329329
}
330330
});
331331

332+
/**
333+
* Handles escaping all required characters in the query string.
334+
*/
335+
it("RestJsonQueryStringEscaping:Request", async () => {
336+
const client = new RestJsonProtocolClient({
337+
...clientParams,
338+
requestHandler: new RequestSerializationTestHandler(),
339+
});
340+
341+
const command = new AllQueryStringTypesCommand({
342+
queryString: "%:/?#[]@!$&'()*+,;=😹",
343+
} as any);
344+
try {
345+
await client.send(command);
346+
fail("Expected an EXPECTED_REQUEST_SERIALIZATION_ERROR to be thrown");
347+
return;
348+
} catch (err) {
349+
if (!(err instanceof EXPECTED_REQUEST_SERIALIZATION_ERROR)) {
350+
fail(err);
351+
return;
352+
}
353+
const r = err.request;
354+
expect(r.method).toBe("GET");
355+
expect(r.path).toBe("/AllQueryStringTypesInput");
356+
357+
const queryString = buildQueryString(r.query);
358+
expect(queryString).toContain("String=%25%3A%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D%F0%9F%98%B9");
359+
360+
expect(r.body).toBeFalsy();
361+
}
362+
});
363+
332364
/**
333365
* Mixes constant and variable query string parameters
334366
*/
@@ -1649,7 +1681,7 @@ it("RestJsonHttpRequestWithGreedyLabelInPath:Request", async () => {
16491681
});
16501682

16511683
const command = new HttpRequestWithGreedyLabelInPathCommand({
1652-
foo: "hello",
1684+
foo: "hello/escape",
16531685

16541686
baz: "there/guy",
16551687
} as any);
@@ -1664,7 +1696,7 @@ it("RestJsonHttpRequestWithGreedyLabelInPath:Request", async () => {
16641696
}
16651697
const r = err.request;
16661698
expect(r.method).toBe("GET");
1667-
expect(r.path).toBe("/HttpRequestWithGreedyLabelInPath/foo/hello/baz/there/guy");
1699+
expect(r.path).toBe("/HttpRequestWithGreedyLabelInPath/foo/hello%2Fescape/baz/there/guy");
16681700

16691701
expect(r.body).toBeFalsy();
16701702
}
@@ -1713,6 +1745,51 @@ it("RestJsonInputWithHeadersAndAllParams:Request", async () => {
17131745
}
17141746
});
17151747

1748+
/**
1749+
* Sends a GET request that uses URI label bindings
1750+
*/
1751+
it("RestJsonHttpRequestLabelEscaping:Request", async () => {
1752+
const client = new RestJsonProtocolClient({
1753+
...clientParams,
1754+
requestHandler: new RequestSerializationTestHandler(),
1755+
});
1756+
1757+
const command = new HttpRequestWithLabelsCommand({
1758+
string: "%:/?#[]@!$&'()*+,;=😹",
1759+
1760+
short: 1,
1761+
1762+
integer: 2,
1763+
1764+
long: 3,
1765+
1766+
float: 4.1,
1767+
1768+
double: 5.1,
1769+
1770+
boolean: true,
1771+
1772+
timestamp: new Date(1576540098000),
1773+
} as any);
1774+
try {
1775+
await client.send(command);
1776+
fail("Expected an EXPECTED_REQUEST_SERIALIZATION_ERROR to be thrown");
1777+
return;
1778+
} catch (err) {
1779+
if (!(err instanceof EXPECTED_REQUEST_SERIALIZATION_ERROR)) {
1780+
fail(err);
1781+
return;
1782+
}
1783+
const r = err.request;
1784+
expect(r.method).toBe("GET");
1785+
expect(r.path).toBe(
1786+
"/HttpRequestWithLabels/%25%3A%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D%F0%9F%98%B9/1/2/3/4.1/5.1/true/2019-12-16T23%3A48%3A18Z"
1787+
);
1788+
1789+
expect(r.body).toBeFalsy();
1790+
}
1791+
});
1792+
17161793
/**
17171794
* Serializes different timestamp formats in URI labels
17181795
*/

0 commit comments

Comments
 (0)