Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codegen/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
smithyVersion=1.61.0
smithyVersion=1.62.0
smithyGradleVersion=1.2.0
smithyPluginVersion=0.6.0
org.gradle.jvmargs=-Xmx4096M
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,50 @@ it("AwsJson10FooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", as
fail("Expected an exception to be thrown from response");
});

/**
* Some services serialize errors using __type, and if the response includes additional shapes that belong to a different namespace there'll be a nested __type property that must not be considered when determining which error to be surfaced.
*
* For an example service see Amazon DynamoDB.
*/
it("AwsJson10FooErrorWithNestedTypeProperty:Error:GreetingWithErrors", async () => {
const client = new JSONRPC10Client({
...clientParams,
requestHandler: new ResponseDeserializationTestHandler(
false,
500,
{
"content-type": "application/x-amz-json-1.0",
},
`{
"__type": "aws.protocoltests.json10#FooError",
"ErrorDetails": [
{
"__type": "com.amazon.internal#ErrorDetails",
"reason": "Some reason"
}
]
}`
),
});

const params: any = {};
const command = new GreetingWithErrorsCommand(params);

try {
await client.send(command);
} catch (err) {
if (err.name !== "FooError") {
console.log(err);
fail(`Expected a FooError to be thrown, got ${err.name} instead`);
return;
}
const r: any = err;
expect(r["$metadata"].httpStatusCode).toBe(500);
return;
}
fail("Expected an exception to be thrown from response");
});

/**
* Custom endpoints supplied by users can have paths
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,50 @@ it("AwsJson10FooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", as
fail("Expected an exception to be thrown from response");
});

/**
* Some services serialize errors using __type, and if the response includes additional shapes that belong to a different namespace there'll be a nested __type property that must not be considered when determining which error to be surfaced.
*
* For an example service see Amazon DynamoDB.
*/
it("AwsJson10FooErrorWithNestedTypeProperty:Error:GreetingWithErrors", async () => {
const client = new JSONRPC10Client({
...clientParams,
requestHandler: new ResponseDeserializationTestHandler(
false,
500,
{
"content-type": "application/x-amz-json-1.0",
},
`{
"__type": "aws.protocoltests.json10#FooError",
"ErrorDetails": [
{
"__type": "com.amazon.internal#ErrorDetails",
"reason": "Some reason"
}
]
}`
),
});

const params: any = {};
const command = new GreetingWithErrorsCommand(params);

try {
await client.send(command);
} catch (err) {
if (err.name !== "FooError") {
console.log(err);
fail(`Expected a FooError to be thrown, got ${err.name} instead`);
return;
}
const r: any = err;
expect(r["$metadata"].httpStatusCode).toBe(500);
return;
}
fail("Expected an exception to be thrown from response");
});

/**
* Custom endpoints supplied by users can have paths
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,50 @@ it("AwsJson11FooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", as
fail("Expected an exception to be thrown from response");
});

/**
* Some services serialize errors using __type, and if the response includes additional shapes that belong to a different namespace there'll be a nested __type property that must not be considered when determining which error to be surfaced.
*
* For an example service see Amazon DynamoDB.
*/
it("AwsJson11FooErrorWithNestedTypeProperty:Error:GreetingWithErrors", async () => {
const client = new JsonProtocolClient({
...clientParams,
requestHandler: new ResponseDeserializationTestHandler(
false,
500,
{
"content-type": "application/x-amz-json-1.1",
},
`{
"__type": "aws.protocoltests.restjson#FooError",
"ErrorDetails": [
{
"__type": "com.amazon.internal#ErrorDetails",
"reason": "Some reason"
}
]
}`
),
});

const params: any = {};
const command = new GreetingWithErrorsCommand(params);

try {
await client.send(command);
} catch (err) {
if (err.name !== "FooError") {
console.log(err);
fail(`Expected a FooError to be thrown, got ${err.name} instead`);
return;
}
const r: any = err;
expect(r["$metadata"].httpStatusCode).toBe(500);
return;
}
fail("Expected an exception to be thrown from response");
});

/**
* Custom endpoints supplied by users can have paths
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,50 @@ it("AwsJson11FooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", as
fail("Expected an exception to be thrown from response");
});

/**
* Some services serialize errors using __type, and if the response includes additional shapes that belong to a different namespace there'll be a nested __type property that must not be considered when determining which error to be surfaced.
*
* For an example service see Amazon DynamoDB.
*/
it("AwsJson11FooErrorWithNestedTypeProperty:Error:GreetingWithErrors", async () => {
const client = new JsonProtocolClient({
...clientParams,
requestHandler: new ResponseDeserializationTestHandler(
false,
500,
{
"content-type": "application/x-amz-json-1.1",
},
`{
"__type": "aws.protocoltests.restjson#FooError",
"ErrorDetails": [
{
"__type": "com.amazon.internal#ErrorDetails",
"reason": "Some reason"
}
]
}`
),
});

const params: any = {};
const command = new GreetingWithErrorsCommand(params);

try {
await client.send(command);
} catch (err) {
if (err.name !== "FooError") {
console.log(err);
fail(`Expected a FooError to be thrown, got ${err.name} instead`);
return;
}
const r: any = err;
expect(r["$metadata"].httpStatusCode).toBe(500);
return;
}
fail("Expected an exception to be thrown from response");
});

/**
* Custom endpoints supplied by users can have paths
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2240,6 +2240,50 @@ it("RestJsonFooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", asy
fail("Expected an exception to be thrown from response");
});

/**
* Some services serialize errors using __type, and if the response includes additional shapes that belong to a different namespace there'll be a nested __type property that must not be considered when determining which error to be surfaced.
*
* For an example service see Amazon DynamoDB.
*/
it("RestJsonFooErrorWithNestedTypeProperty:Error:GreetingWithErrors", async () => {
const client = new RestJsonProtocolClient({
...clientParams,
requestHandler: new ResponseDeserializationTestHandler(
false,
500,
{
"content-type": "application/json",
},
`{
"__type": "aws.protocoltests.restjson#FooError",
"ErrorDetails": [
{
"__type": "com.amazon.internal#ErrorDetails",
"reason": "Some reason"
}
]
}`
),
});

const params: any = {};
const command = new GreetingWithErrorsCommand(params);

try {
await client.send(command);
} catch (err) {
if (err.name !== "FooError") {
console.log(err);
fail(`Expected a FooError to be thrown, got ${err.name} instead`);
return;
}
const r: any = err;
expect(r["$metadata"].httpStatusCode).toBe(500);
return;
}
fail("Expected an exception to be thrown from response");
});

/**
* Custom endpoints supplied by users can have paths
*/
Expand Down Expand Up @@ -3577,7 +3621,7 @@ it("RestJsonIgnoreQueryParamsInResponse:Response", async () => {
{
"content-type": "application/json",
},
`{}`
`{"baz":"bam"}`
),
});

Expand All @@ -3592,30 +3636,18 @@ it("RestJsonIgnoreQueryParamsInResponse:Response", async () => {
return;
}
expect(r["$metadata"].httpStatusCode).toBe(200);
});

/**
* This test is similar to RestJsonIgnoreQueryParamsInResponse,
* but it ensures that clients gracefully handle responses from
* the server that do not serialize an empty JSON object.
*/
it("RestJsonIgnoreQueryParamsInResponseNoPayload:Response", async () => {
const client = new RestJsonProtocolClient({
...clientParams,
requestHandler: new ResponseDeserializationTestHandler(true, 200, undefined, ``),
const paramsToValidate: any = [
{
baz: "bam",
},
][0];
Object.keys(paramsToValidate).forEach((param) => {
expect(
r[param],
`The output field ${param} should have been defined in ${JSON.stringify(r, null, 2)}`
).toBeDefined();
expect(equivalentContents(paramsToValidate[param], r[param])).toBe(true);
});

const params: any = {};
const command = new IgnoreQueryParamsInResponseCommand(params);

let r: any;
try {
r = await client.send(command);
} catch (err) {
fail("Expected a valid response to be returned, got " + err);
return;
}
expect(r["$metadata"].httpStatusCode).toBe(200);
});

/**
Expand Down
Loading
Loading