diff --git a/clients/client-dataexchange/src/protocols/Aws_restJson1.ts b/clients/client-dataexchange/src/protocols/Aws_restJson1.ts index 14a7e436104a..6fab189424ed 100644 --- a/clients/client-dataexchange/src/protocols/Aws_restJson1.ts +++ b/clients/client-dataexchange/src/protocols/Aws_restJson1.ts @@ -686,17 +686,17 @@ export const se_SendApiAssetCommand = async ( ): Promise<__HttpRequest> => { const b = rb(input, context); const headers: any = map({}, isSerializableHeaderValue, { + ...(input.RequestHeaders !== undefined && + Object.keys(input.RequestHeaders).reduce((acc: any, suffix: string) => { + acc[`x-amzn-dataexchange-header-${suffix.toLowerCase()}`] = input.RequestHeaders![suffix]; + return acc; + }, {})), "content-type": "text/plain", [_xadai]: input[_AI]!, [_xaddsi]: input[_DSI]!, [_xadhm]: input[_M]!, [_xadp]: input[_P]!, [_xadri]: input[_RI]!, - ...(input.RequestHeaders !== undefined && - Object.keys(input.RequestHeaders).reduce((acc: any, suffix: string) => { - acc[`x-amzn-dataexchange-header-${suffix.toLowerCase()}`] = input.RequestHeaders![suffix]; - return acc; - }, {})), }); b.bp("/v1"); const query: any = map({ diff --git a/clients/client-s3-control/src/models/models_1.ts b/clients/client-s3-control/src/models/models_1.ts index a184635cc63d..ee7e74374bf9 100644 --- a/clients/client-s3-control/src/models/models_1.ts +++ b/clients/client-s3-control/src/models/models_1.ts @@ -19,6 +19,7 @@ import { StorageLensTag, Tag, } from "./models_0"; + import { S3ControlServiceException as __BaseException } from "./S3ControlServiceException"; /** diff --git a/clients/client-s3/src/protocols/Aws_restXml.ts b/clients/client-s3/src/protocols/Aws_restXml.ts index 9a33665cc28c..b970d7333187 100644 --- a/clients/client-s3/src/protocols/Aws_restXml.ts +++ b/clients/client-s3/src/protocols/Aws_restXml.ts @@ -547,6 +547,11 @@ export const se_CopyObjectCommand = async ( ): Promise<__HttpRequest> => { const b = rb(input, context); const headers: any = map({}, isSerializableHeaderValue, { + ...(input.Metadata !== undefined && + Object.keys(input.Metadata).reduce((acc: any, suffix: string) => { + acc[`x-amz-meta-${suffix.toLowerCase()}`] = input.Metadata![suffix]; + return acc; + }, {})), [_xaa]: input[_ACL]!, [_cc]: input[_CC]!, [_xaca]: input[_CA]!, @@ -585,11 +590,6 @@ export const se_CopyObjectCommand = async ( [_xaollh]: input[_OLLHS]!, [_xaebo]: input[_EBO]!, [_xasebo]: input[_ESBO]!, - ...(input.Metadata !== undefined && - Object.keys(input.Metadata).reduce((acc: any, suffix: string) => { - acc[`x-amz-meta-${suffix.toLowerCase()}`] = input.Metadata![suffix]; - return acc; - }, {})), }); b.bp("/{Key+}"); b.p("Bucket", () => input.Bucket!, "{Bucket}", false); @@ -675,6 +675,11 @@ export const se_CreateMultipartUploadCommand = async ( ): Promise<__HttpRequest> => { const b = rb(input, context); const headers: any = map({}, isSerializableHeaderValue, { + ...(input.Metadata !== undefined && + Object.keys(input.Metadata).reduce((acc: any, suffix: string) => { + acc[`x-amz-meta-${suffix.toLowerCase()}`] = input.Metadata![suffix]; + return acc; + }, {})), [_xaa]: input[_ACL]!, [_cc]: input[_CC]!, [_cd]: input[_CD]!, @@ -703,11 +708,6 @@ export const se_CreateMultipartUploadCommand = async ( [_xaebo]: input[_EBO]!, [_xaca]: input[_CA]!, [_xact]: input[_CT]!, - ...(input.Metadata !== undefined && - Object.keys(input.Metadata).reduce((acc: any, suffix: string) => { - acc[`x-amz-meta-${suffix.toLowerCase()}`] = input.Metadata![suffix]; - return acc; - }, {})), }); b.bp("/{Key+}"); b.p("Bucket", () => input.Bucket!, "{Bucket}", false); @@ -2722,6 +2722,11 @@ export const se_PutObjectCommand = async ( ): Promise<__HttpRequest> => { const b = rb(input, context); const headers: any = map({}, isSerializableHeaderValue, { + ...(input.Metadata !== undefined && + Object.keys(input.Metadata).reduce((acc: any, suffix: string) => { + acc[`x-amz-meta-${suffix.toLowerCase()}`] = input.Metadata![suffix]; + return acc; + }, {})), [_ct]: input[_CTo] || "application/octet-stream", [_xaa]: input[_ACL]!, [_cc]: input[_CC]!, @@ -2759,11 +2764,6 @@ export const se_PutObjectCommand = async ( [_xaolrud]: [() => isSerializableHeaderValue(input[_OLRUD]), () => __serializeDateTime(input[_OLRUD]!).toString()], [_xaollh]: input[_OLLHS]!, [_xaebo]: input[_EBO]!, - ...(input.Metadata !== undefined && - Object.keys(input.Metadata).reduce((acc: any, suffix: string) => { - acc[`x-amz-meta-${suffix.toLowerCase()}`] = input.Metadata![suffix]; - return acc; - }, {})), }); b.bp("/{Key+}"); b.p("Bucket", () => input.Bucket!, "{Bucket}", false); @@ -3158,6 +3158,11 @@ export const se_WriteGetObjectResponseCommand = async ( const b = rb(input, context); const headers: any = map({}, isSerializableHeaderValue, { "x-amz-content-sha256": "UNSIGNED-PAYLOAD", + ...(input.Metadata !== undefined && + Object.keys(input.Metadata).reduce((acc: any, suffix: string) => { + acc[`x-amz-meta-${suffix.toLowerCase()}`] = input.Metadata![suffix]; + return acc; + }, {})), "content-type": "application/octet-stream", [_xarr]: input[_RR]!, [_xart]: input[_RT]!, @@ -3201,11 +3206,6 @@ export const se_WriteGetObjectResponseCommand = async ( [_xafhxatc]: [() => isSerializableHeaderValue(input[_TC]), () => input[_TC]!.toString()], [_xafhxavi]: input[_VI]!, [_xafhxassebke]: [() => isSerializableHeaderValue(input[_BKE]), () => input[_BKE]!.toString()], - ...(input.Metadata !== undefined && - Object.keys(input.Metadata).reduce((acc: any, suffix: string) => { - acc[`x-amz-meta-${suffix.toLowerCase()}`] = input.Metadata![suffix]; - return acc; - }, {})), }); b.bp("/WriteGetObjectResponse"); let body: any; diff --git a/codegen/gradle.properties b/codegen/gradle.properties index f316154569c5..784cbf54f8b2 100644 --- a/codegen/gradle.properties +++ b/codegen/gradle.properties @@ -1,3 +1,3 @@ -smithyVersion=1.55.0 +smithyVersion=1.56.0 smithyGradleVersion=1.2.0 smithyPluginVersion=0.6.0 \ No newline at end of file diff --git a/private/aws-protocoltests-ec2/README.md b/private/aws-protocoltests-ec2/README.md index 841f34598a71..ba0337f4b9fd 100644 --- a/private/aws-protocoltests-ec2/README.md +++ b/private/aws-protocoltests-ec2/README.md @@ -1058,6 +1058,14 @@ HttpChecksumRequired [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ec2-protocol/command/HttpChecksumRequiredCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ec2-protocol/Interface/HttpChecksumRequiredCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ec2-protocol/Interface/HttpChecksumRequiredCommandOutput/) + +
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ec2-protocol/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ec2-protocol/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ec2-protocol/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
@@ -1986,6 +1994,14 @@ GreetingWithErrors [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ec2-protocol/command/GreetingWithErrorsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ec2-protocol/Interface/GreetingWithErrorsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ec2-protocol/Interface/GreetingWithErrorsCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ec2-protocol/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ec2-protocol/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ec2-protocol/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
diff --git a/private/aws-protocoltests-json-10/README.md b/private/aws-protocoltests-json-10/README.md index 4874e1b28230..439a30694f48 100644 --- a/private/aws-protocoltests-json-10/README.md +++ b/private/aws-protocoltests-json-10/README.md @@ -1056,6 +1056,14 @@ HttpChecksumRequired [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/json-rpc-10/command/HttpChecksumRequiredCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-rpc-10/Interface/HttpChecksumRequiredCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-rpc-10/Interface/HttpChecksumRequiredCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/json-rpc-10/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-rpc-10/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-rpc-10/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
@@ -1984,6 +1992,14 @@ GreetingWithErrors [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/json-rpc-10/command/GreetingWithErrorsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-rpc-10/Interface/GreetingWithErrorsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-rpc-10/Interface/GreetingWithErrorsCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/json-rpc-10/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-rpc-10/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-rpc-10/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
diff --git a/private/aws-protocoltests-json-10/src/commands/GreetingWithErrorsCommand.ts b/private/aws-protocoltests-json-10/src/commands/GreetingWithErrorsCommand.ts index 124a48d84802..dfdace8d9dce 100644 --- a/private/aws-protocoltests-json-10/src/commands/GreetingWithErrorsCommand.ts +++ b/private/aws-protocoltests-json-10/src/commands/GreetingWithErrorsCommand.ts @@ -60,13 +60,13 @@ export interface GreetingWithErrorsCommandOutput extends GreetingWithErrorsOutpu * @throws {@link InvalidGreeting} (client fault) * This error is thrown when an invalid greeting value is provided. * + * @throws {@link ComplexError} (client fault) + * This error is thrown when a request is invalid. + * * @throws {@link FooError} (server fault) * This error has test cases that test some of the dark corners of Amazon service * framework history. It should only be implemented by clients. * - * @throws {@link ComplexError} (client fault) - * This error is thrown when a request is invalid. - * * @throws {@link JSONRPC10ServiceException} *

Base exception class for all service exceptions from JSONRPC10 service.

* diff --git a/private/aws-protocoltests-json-10/test/functional/awsjson1_0.spec.ts b/private/aws-protocoltests-json-10/test/functional/awsjson1_0.spec.ts index fb3628f1094a..1fe493823bc8 100644 --- a/private/aws-protocoltests-json-10/test/functional/awsjson1_0.spec.ts +++ b/private/aws-protocoltests-json-10/test/functional/awsjson1_0.spec.ts @@ -401,6 +401,97 @@ it("AwsJson10InvalidGreetingError:Error:GreetingWithErrors", async () => { fail("Expected an exception to be thrown from response"); }); +/** + * Parses a complex error with no message member + */ +it("AwsJson10ComplexError:Error:GreetingWithErrors", async () => { + const client = new JSONRPC10Client({ + ...clientParams, + requestHandler: new ResponseDeserializationTestHandler( + false, + 400, + { + "content-type": "application/x-amz-json-1.0", + }, + `{ + "__type": "aws.protocoltests.json10#ComplexError", + "TopLevel": "Top level", + "Nested": { + "Foo": "bar" + } + }` + ), + }); + + const params: any = {}; + const command = new GreetingWithErrorsCommand(params); + + try { + await client.send(command); + } catch (err) { + if (err.name !== "ComplexError") { + console.log(err); + fail(`Expected a ComplexError to be thrown, got ${err.name} instead`); + return; + } + const r: any = err; + expect(r["$metadata"].httpStatusCode).toBe(400); + const paramsToValidate: any = [ + { + TopLevel: "Top level", + Nested: { + Foo: "bar", + }, + }, + ][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); + }); + return; + } + fail("Expected an exception to be thrown from response"); +}); + +/** + * Parses a complex error with an empty body + */ +it("AwsJson10EmptyComplexError:Error:GreetingWithErrors", async () => { + const client = new JSONRPC10Client({ + ...clientParams, + requestHandler: new ResponseDeserializationTestHandler( + false, + 400, + { + "content-type": "application/x-amz-json-1.0", + }, + `{ + "__type": "aws.protocoltests.json10#ComplexError" + }` + ), + }); + + const params: any = {}; + const command = new GreetingWithErrorsCommand(params); + + try { + await client.send(command); + } catch (err) { + if (err.name !== "ComplexError") { + console.log(err); + fail(`Expected a ComplexError to be thrown, got ${err.name} instead`); + return; + } + const r: any = err; + expect(r["$metadata"].httpStatusCode).toBe(400); + return; + } + fail("Expected an exception to be thrown from response"); +}); + /** * Serializes the X-Amzn-ErrorType header. For an example service, see Amazon EKS. */ @@ -710,97 +801,6 @@ it("AwsJson10FooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", as fail("Expected an exception to be thrown from response"); }); -/** - * Parses a complex error with no message member - */ -it("AwsJson10ComplexError:Error:GreetingWithErrors", async () => { - const client = new JSONRPC10Client({ - ...clientParams, - requestHandler: new ResponseDeserializationTestHandler( - false, - 400, - { - "content-type": "application/x-amz-json-1.0", - }, - `{ - "__type": "aws.protocoltests.json10#ComplexError", - "TopLevel": "Top level", - "Nested": { - "Foo": "bar" - } - }` - ), - }); - - const params: any = {}; - const command = new GreetingWithErrorsCommand(params); - - try { - await client.send(command); - } catch (err) { - if (err.name !== "ComplexError") { - console.log(err); - fail(`Expected a ComplexError to be thrown, got ${err.name} instead`); - return; - } - const r: any = err; - expect(r["$metadata"].httpStatusCode).toBe(400); - const paramsToValidate: any = [ - { - TopLevel: "Top level", - Nested: { - Foo: "bar", - }, - }, - ][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); - }); - return; - } - fail("Expected an exception to be thrown from response"); -}); - -/** - * Parses a complex error with an empty body - */ -it("AwsJson10EmptyComplexError:Error:GreetingWithErrors", async () => { - const client = new JSONRPC10Client({ - ...clientParams, - requestHandler: new ResponseDeserializationTestHandler( - false, - 400, - { - "content-type": "application/x-amz-json-1.0", - }, - `{ - "__type": "aws.protocoltests.json10#ComplexError" - }` - ), - }); - - const params: any = {}; - const command = new GreetingWithErrorsCommand(params); - - try { - await client.send(command); - } catch (err) { - if (err.name !== "ComplexError") { - console.log(err); - fail(`Expected a ComplexError to be thrown, got ${err.name} instead`); - return; - } - const r: any = err; - expect(r["$metadata"].httpStatusCode).toBe(400); - return; - } - fail("Expected an exception to be thrown from response"); -}); - /** * Custom endpoints supplied by users can have paths */ diff --git a/private/aws-protocoltests-json-machinelearning/README.md b/private/aws-protocoltests-json-machinelearning/README.md index 773412afd67c..ab11dd454bce 100644 --- a/private/aws-protocoltests-json-machinelearning/README.md +++ b/private/aws-protocoltests-json-machinelearning/README.md @@ -1056,6 +1056,14 @@ HttpChecksumRequired [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/machine-learning/command/HttpChecksumRequiredCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-machine-learning/Interface/HttpChecksumRequiredCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-machine-learning/Interface/HttpChecksumRequiredCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/machine-learning/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-machine-learning/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-machine-learning/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
@@ -1984,6 +1992,14 @@ GreetingWithErrors [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/machine-learning/command/GreetingWithErrorsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-machine-learning/Interface/GreetingWithErrorsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-machine-learning/Interface/GreetingWithErrorsCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/machine-learning/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-machine-learning/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-machine-learning/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
diff --git a/private/aws-protocoltests-json-machinelearning/src/commands/PredictCommand.ts b/private/aws-protocoltests-json-machinelearning/src/commands/PredictCommand.ts index fb9b1d9e1fe6..10badf089440 100644 --- a/private/aws-protocoltests-json-machinelearning/src/commands/PredictCommand.ts +++ b/private/aws-protocoltests-json-machinelearning/src/commands/PredictCommand.ts @@ -65,15 +65,15 @@ export interface PredictCommandOutput extends PredictOutput, __MetadataBearer {} * @see {@link PredictCommandOutput} for command's `response` shape. * @see {@link MachineLearningClientResolvedConfig | config} for MachineLearningClient's `config` shape. * - * @throws {@link ResourceNotFoundException} (client fault) - * * @throws {@link InternalServerException} (server fault) * + * @throws {@link InvalidInputException} (client fault) + * * @throws {@link LimitExceededException} (client fault) * * @throws {@link PredictorNotMountedException} (client fault) * - * @throws {@link InvalidInputException} (client fault) + * @throws {@link ResourceNotFoundException} (client fault) * * @throws {@link MachineLearningServiceException} *

Base exception class for all service exceptions from MachineLearning service.

diff --git a/private/aws-protocoltests-json/README.md b/private/aws-protocoltests-json/README.md index 644b1b26febf..652224082973 100644 --- a/private/aws-protocoltests-json/README.md +++ b/private/aws-protocoltests-json/README.md @@ -1056,6 +1056,14 @@ HttpChecksumRequired [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/json-protocol/command/HttpChecksumRequiredCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-protocol/Interface/HttpChecksumRequiredCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-protocol/Interface/HttpChecksumRequiredCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/json-protocol/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-protocol/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-protocol/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
@@ -1984,6 +1992,14 @@ GreetingWithErrors [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/json-protocol/command/GreetingWithErrorsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-protocol/Interface/GreetingWithErrorsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-protocol/Interface/GreetingWithErrorsCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/json-protocol/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-protocol/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-json-protocol/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
diff --git a/private/aws-protocoltests-json/src/commands/KitchenSinkOperationCommand.ts b/private/aws-protocoltests-json/src/commands/KitchenSinkOperationCommand.ts index 72c4c261a654..0342d0974545 100644 --- a/private/aws-protocoltests-json/src/commands/KitchenSinkOperationCommand.ts +++ b/private/aws-protocoltests-json/src/commands/KitchenSinkOperationCommand.ts @@ -267,10 +267,10 @@ export interface KitchenSinkOperationCommandOutput extends KitchenSink, __Metada * @see {@link KitchenSinkOperationCommandOutput} for command's `response` shape. * @see {@link JsonProtocolClientResolvedConfig | config} for JsonProtocolClient's `config` shape. * - * @throws {@link ErrorWithoutMembers} (server fault) - * * @throws {@link ErrorWithMembers} (client fault) * + * @throws {@link ErrorWithoutMembers} (server fault) + * * @throws {@link JsonProtocolServiceException} *

Base exception class for all service exceptions from JsonProtocol service.

* diff --git a/private/aws-protocoltests-query/README.md b/private/aws-protocoltests-query/README.md index 4ca387b9c72c..35f23c1086a9 100644 --- a/private/aws-protocoltests-query/README.md +++ b/private/aws-protocoltests-query/README.md @@ -1058,6 +1058,14 @@ HttpChecksumRequired [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/query-protocol/command/HttpChecksumRequiredCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-query-protocol/Interface/HttpChecksumRequiredCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-query-protocol/Interface/HttpChecksumRequiredCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/query-protocol/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-query-protocol/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-query-protocol/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
@@ -1986,6 +1994,14 @@ GreetingWithErrors [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/query-protocol/command/GreetingWithErrorsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-query-protocol/Interface/GreetingWithErrorsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-query-protocol/Interface/GreetingWithErrorsCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/query-protocol/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-query-protocol/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-query-protocol/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
diff --git a/private/aws-protocoltests-query/src/commands/GreetingWithErrorsCommand.ts b/private/aws-protocoltests-query/src/commands/GreetingWithErrorsCommand.ts index 54ddce35ff97..fc8ee08265b6 100644 --- a/private/aws-protocoltests-query/src/commands/GreetingWithErrorsCommand.ts +++ b/private/aws-protocoltests-query/src/commands/GreetingWithErrorsCommand.ts @@ -55,11 +55,11 @@ export interface GreetingWithErrorsCommandOutput extends GreetingWithErrorsOutpu * @throws {@link InvalidGreeting} (client fault) * This error is thrown when an invalid greeting value is provided. * - * @throws {@link CustomCodeError} (client fault) - * * @throws {@link ComplexError} (client fault) * This error is thrown when a request is invalid. * + * @throws {@link CustomCodeError} (client fault) + * * @throws {@link QueryProtocolServiceException} *

Base exception class for all service exceptions from QueryProtocol service.

* diff --git a/private/aws-protocoltests-query/test/functional/awsquery.spec.ts b/private/aws-protocoltests-query/test/functional/awsquery.spec.ts index 68fd9e03672b..f7976d68cd58 100644 --- a/private/aws-protocoltests-query/test/functional/awsquery.spec.ts +++ b/private/aws-protocoltests-query/test/functional/awsquery.spec.ts @@ -770,23 +770,23 @@ it("QueryInvalidGreetingError:Error:GreetingWithErrors", async () => { fail("Expected an exception to be thrown from response"); }); -/** - * Parses customized XML errors - */ -it("QueryCustomizedError:Error:GreetingWithErrors", async () => { +it("QueryComplexError:Error:GreetingWithErrors", async () => { const client = new QueryProtocolClient({ ...clientParams, requestHandler: new ResponseDeserializationTestHandler( false, - 402, + 400, { "content-type": "text/xml", }, ` Sender - Customized - Hi + ComplexError + Top level + + bar + foo-id @@ -800,16 +800,19 @@ it("QueryCustomizedError:Error:GreetingWithErrors", async () => { try { await client.send(command); } catch (err) { - if (err.name !== "CustomCodeError") { + if (err.name !== "ComplexError") { console.log(err); - fail(`Expected a CustomCodeError to be thrown, got ${err.name} instead`); + fail(`Expected a ComplexError to be thrown, got ${err.name} instead`); return; } const r: any = err; - expect(r["$metadata"].httpStatusCode).toBe(402); + expect(r["$metadata"].httpStatusCode).toBe(400); const paramsToValidate: any = [ { - message: "Hi", + TopLevel: "Top level", + Nested: { + Foo: "bar", + }, }, ][0]; Object.keys(paramsToValidate).forEach((param) => { @@ -824,23 +827,23 @@ it("QueryCustomizedError:Error:GreetingWithErrors", async () => { fail("Expected an exception to be thrown from response"); }); -it("QueryComplexError:Error:GreetingWithErrors", async () => { +/** + * Parses customized XML errors + */ +it("QueryCustomizedError:Error:GreetingWithErrors", async () => { const client = new QueryProtocolClient({ ...clientParams, requestHandler: new ResponseDeserializationTestHandler( false, - 400, + 402, { "content-type": "text/xml", }, ` Sender - ComplexError - Top level - - bar - + Customized + Hi foo-id @@ -854,19 +857,16 @@ it("QueryComplexError:Error:GreetingWithErrors", async () => { try { await client.send(command); } catch (err) { - if (err.name !== "ComplexError") { + if (err.name !== "CustomCodeError") { console.log(err); - fail(`Expected a ComplexError to be thrown, got ${err.name} instead`); + fail(`Expected a CustomCodeError to be thrown, got ${err.name} instead`); return; } const r: any = err; - expect(r["$metadata"].httpStatusCode).toBe(400); + expect(r["$metadata"].httpStatusCode).toBe(402); const paramsToValidate: any = [ { - TopLevel: "Top level", - Nested: { - Foo: "bar", - }, + message: "Hi", }, ][0]; Object.keys(paramsToValidate).forEach((param) => { diff --git a/private/aws-protocoltests-restjson-apigateway/README.md b/private/aws-protocoltests-restjson-apigateway/README.md index 1ff8ac66fef5..58724b2a10b3 100644 --- a/private/aws-protocoltests-restjson-apigateway/README.md +++ b/private/aws-protocoltests-restjson-apigateway/README.md @@ -1056,6 +1056,14 @@ HttpChecksumRequired [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/api-gateway/command/HttpChecksumRequiredCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-api-gateway/Interface/HttpChecksumRequiredCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-api-gateway/Interface/HttpChecksumRequiredCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/api-gateway/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-api-gateway/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-api-gateway/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
@@ -1984,6 +1992,14 @@ GreetingWithErrors [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/api-gateway/command/GreetingWithErrorsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-api-gateway/Interface/GreetingWithErrorsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-api-gateway/Interface/GreetingWithErrorsCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/api-gateway/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-api-gateway/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-api-gateway/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
diff --git a/private/aws-protocoltests-restjson-apigateway/src/commands/GetRestApisCommand.ts b/private/aws-protocoltests-restjson-apigateway/src/commands/GetRestApisCommand.ts index 03b7e5478b80..1b70fcc70dc2 100644 --- a/private/aws-protocoltests-restjson-apigateway/src/commands/GetRestApisCommand.ts +++ b/private/aws-protocoltests-restjson-apigateway/src/commands/GetRestApisCommand.ts @@ -82,12 +82,12 @@ export interface GetRestApisCommandOutput extends RestApis, __MetadataBearer {} * @see {@link GetRestApisCommandOutput} for command's `response` shape. * @see {@link APIGatewayClientResolvedConfig | config} for APIGatewayClient's `config` shape. * + * @throws {@link BadRequestException} (client fault) + * * @throws {@link TooManyRequestsException} (client fault) * * @throws {@link UnauthorizedException} (client fault) * - * @throws {@link BadRequestException} (client fault) - * * @throws {@link APIGatewayServiceException} *

Base exception class for all service exceptions from APIGateway service.

* diff --git a/private/aws-protocoltests-restjson-glacier/README.md b/private/aws-protocoltests-restjson-glacier/README.md index 809483bae145..748e7d62c926 100644 --- a/private/aws-protocoltests-restjson-glacier/README.md +++ b/private/aws-protocoltests-restjson-glacier/README.md @@ -1056,6 +1056,14 @@ HttpChecksumRequired [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/glacier/command/HttpChecksumRequiredCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-glacier/Interface/HttpChecksumRequiredCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-glacier/Interface/HttpChecksumRequiredCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/glacier/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-glacier/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-glacier/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
@@ -1984,6 +1992,14 @@ GreetingWithErrors [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/glacier/command/GreetingWithErrorsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-glacier/Interface/GreetingWithErrorsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-glacier/Interface/GreetingWithErrorsCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/glacier/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-glacier/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-glacier/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
diff --git a/private/aws-protocoltests-restjson-glacier/src/commands/UploadArchiveCommand.ts b/private/aws-protocoltests-restjson-glacier/src/commands/UploadArchiveCommand.ts index e09be7669df0..afd5eb79c7a9 100644 --- a/private/aws-protocoltests-restjson-glacier/src/commands/UploadArchiveCommand.ts +++ b/private/aws-protocoltests-restjson-glacier/src/commands/UploadArchiveCommand.ts @@ -60,12 +60,12 @@ export interface UploadArchiveCommandOutput extends ArchiveCreationOutput, __Met * @see {@link UploadArchiveCommandOutput} for command's `response` shape. * @see {@link GlacierClientResolvedConfig | config} for GlacierClient's `config` shape. * + * @throws {@link InvalidParameterValueException} (client fault) + * * @throws {@link MissingParameterValueException} (client fault) * * @throws {@link RequestTimeoutException} (client fault) * - * @throws {@link InvalidParameterValueException} (client fault) - * * @throws {@link ResourceNotFoundException} (client fault) * * @throws {@link ServiceUnavailableException} (server fault) diff --git a/private/aws-protocoltests-restjson-glacier/src/commands/UploadMultipartPartCommand.ts b/private/aws-protocoltests-restjson-glacier/src/commands/UploadMultipartPartCommand.ts index 8d2d76a0ee7f..8022f8a6fc48 100644 --- a/private/aws-protocoltests-restjson-glacier/src/commands/UploadMultipartPartCommand.ts +++ b/private/aws-protocoltests-restjson-glacier/src/commands/UploadMultipartPartCommand.ts @@ -63,12 +63,12 @@ export interface UploadMultipartPartCommandOutput extends UploadMultipartPartOut * @see {@link UploadMultipartPartCommandOutput} for command's `response` shape. * @see {@link GlacierClientResolvedConfig | config} for GlacierClient's `config` shape. * + * @throws {@link InvalidParameterValueException} (client fault) + * * @throws {@link MissingParameterValueException} (client fault) * * @throws {@link RequestTimeoutException} (client fault) * - * @throws {@link InvalidParameterValueException} (client fault) - * * @throws {@link ResourceNotFoundException} (client fault) * * @throws {@link ServiceUnavailableException} (server fault) diff --git a/private/aws-protocoltests-restjson/README.md b/private/aws-protocoltests-restjson/README.md index 0ea9096f28d5..fba7d32113b5 100644 --- a/private/aws-protocoltests-restjson/README.md +++ b/private/aws-protocoltests-restjson/README.md @@ -1058,6 +1058,14 @@ HttpChecksumRequired [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/rest-json-protocol/command/HttpChecksumRequiredCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-json-protocol/Interface/HttpChecksumRequiredCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-json-protocol/Interface/HttpChecksumRequiredCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/rest-json-protocol/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-json-protocol/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-json-protocol/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
@@ -1986,6 +1994,14 @@ GreetingWithErrors [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/rest-json-protocol/command/GreetingWithErrorsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-json-protocol/Interface/GreetingWithErrorsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-json-protocol/Interface/GreetingWithErrorsCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/rest-json-protocol/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-json-protocol/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-json-protocol/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
diff --git a/private/aws-protocoltests-restjson/src/RestJsonProtocol.ts b/private/aws-protocoltests-restjson/src/RestJsonProtocol.ts index 9ca86dc27491..09c418beedef 100644 --- a/private/aws-protocoltests-restjson/src/RestJsonProtocol.ts +++ b/private/aws-protocoltests-restjson/src/RestJsonProtocol.ts @@ -77,6 +77,11 @@ import { HttpChecksumRequiredCommandInput, HttpChecksumRequiredCommandOutput, } from "./commands/HttpChecksumRequiredCommand"; +import { + HttpEmptyPrefixHeadersCommand, + HttpEmptyPrefixHeadersCommandInput, + HttpEmptyPrefixHeadersCommandOutput, +} from "./commands/HttpEmptyPrefixHeadersCommand"; import { HttpEnumPayloadCommand, HttpEnumPayloadCommandInput, @@ -520,6 +525,7 @@ const commands = { GreetingWithErrorsCommand, HostWithPathOperationCommand, HttpChecksumRequiredCommand, + HttpEmptyPrefixHeadersCommand, HttpEnumPayloadCommand, HttpPayloadTraitsCommand, HttpPayloadTraitsWithMediaTypeCommand, @@ -871,6 +877,24 @@ export interface RestJsonProtocol { cb: (err: any, data?: HttpChecksumRequiredCommandOutput) => void ): void; + /** + * @see {@link HttpEmptyPrefixHeadersCommand} + */ + httpEmptyPrefixHeaders(): Promise; + httpEmptyPrefixHeaders( + args: HttpEmptyPrefixHeadersCommandInput, + options?: __HttpHandlerOptions + ): Promise; + httpEmptyPrefixHeaders( + args: HttpEmptyPrefixHeadersCommandInput, + cb: (err: any, data?: HttpEmptyPrefixHeadersCommandOutput) => void + ): void; + httpEmptyPrefixHeaders( + args: HttpEmptyPrefixHeadersCommandInput, + options: __HttpHandlerOptions, + cb: (err: any, data?: HttpEmptyPrefixHeadersCommandOutput) => void + ): void; + /** * @see {@link HttpEnumPayloadCommand} */ diff --git a/private/aws-protocoltests-restjson/src/RestJsonProtocolClient.ts b/private/aws-protocoltests-restjson/src/RestJsonProtocolClient.ts index 56e96a0f94e9..5310b45e7ddc 100644 --- a/private/aws-protocoltests-restjson/src/RestJsonProtocolClient.ts +++ b/private/aws-protocoltests-restjson/src/RestJsonProtocolClient.ts @@ -109,6 +109,10 @@ import { HttpChecksumRequiredCommandInput, HttpChecksumRequiredCommandOutput, } from "./commands/HttpChecksumRequiredCommand"; +import { + HttpEmptyPrefixHeadersCommandInput, + HttpEmptyPrefixHeadersCommandOutput, +} from "./commands/HttpEmptyPrefixHeadersCommand"; import { HttpEnumPayloadCommandInput, HttpEnumPayloadCommandOutput } from "./commands/HttpEnumPayloadCommand"; import { HttpPayloadTraitsCommandInput, HttpPayloadTraitsCommandOutput } from "./commands/HttpPayloadTraitsCommand"; import { @@ -375,6 +379,7 @@ export type ServiceInputTypes = | GreetingWithErrorsCommandInput | HostWithPathOperationCommandInput | HttpChecksumRequiredCommandInput + | HttpEmptyPrefixHeadersCommandInput | HttpEnumPayloadCommandInput | HttpPayloadTraitsCommandInput | HttpPayloadTraitsWithMediaTypeCommandInput @@ -484,6 +489,7 @@ export type ServiceOutputTypes = | GreetingWithErrorsCommandOutput | HostWithPathOperationCommandOutput | HttpChecksumRequiredCommandOutput + | HttpEmptyPrefixHeadersCommandOutput | HttpEnumPayloadCommandOutput | HttpPayloadTraitsCommandOutput | HttpPayloadTraitsWithMediaTypeCommandOutput diff --git a/private/aws-protocoltests-restjson/src/commands/GreetingWithErrorsCommand.ts b/private/aws-protocoltests-restjson/src/commands/GreetingWithErrorsCommand.ts index 508e82674200..0b0a5f8d4230 100644 --- a/private/aws-protocoltests-restjson/src/commands/GreetingWithErrorsCommand.ts +++ b/private/aws-protocoltests-restjson/src/commands/GreetingWithErrorsCommand.ts @@ -57,15 +57,15 @@ export interface GreetingWithErrorsCommandOutput extends GreetingWithErrorsOutpu * @see {@link GreetingWithErrorsCommandOutput} for command's `response` shape. * @see {@link RestJsonProtocolClientResolvedConfig | config} for RestJsonProtocolClient's `config` shape. * - * @throws {@link FooError} (server fault) - * This error has test cases that test some of the dark corners of Amazon service - * framework history. It should only be implemented by clients. + * @throws {@link InvalidGreeting} (client fault) + * This error is thrown when an invalid greeting value is provided. * * @throws {@link ComplexError} (client fault) * This error is thrown when a request is invalid. * - * @throws {@link InvalidGreeting} (client fault) - * This error is thrown when an invalid greeting value is provided. + * @throws {@link FooError} (server fault) + * This error has test cases that test some of the dark corners of Amazon service + * framework history. It should only be implemented by clients. * * @throws {@link RestJsonProtocolServiceException} *

Base exception class for all service exceptions from RestJsonProtocol service.

diff --git a/private/aws-protocoltests-restjson/src/commands/HttpEmptyPrefixHeadersCommand.ts b/private/aws-protocoltests-restjson/src/commands/HttpEmptyPrefixHeadersCommand.ts new file mode 100644 index 000000000000..397fe143295d --- /dev/null +++ b/private/aws-protocoltests-restjson/src/commands/HttpEmptyPrefixHeadersCommand.ts @@ -0,0 +1,93 @@ +// smithy-typescript generated code +import { getSerdePlugin } from "@smithy/middleware-serde"; +import { Command as $Command } from "@smithy/smithy-client"; +import { MetadataBearer as __MetadataBearer } from "@smithy/types"; + +import { HttpEmptyPrefixHeadersInput, HttpEmptyPrefixHeadersOutput } from "../models/models_0"; +import { de_HttpEmptyPrefixHeadersCommand, se_HttpEmptyPrefixHeadersCommand } from "../protocols/Aws_restJson1"; +import { RestJsonProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RestJsonProtocolClient"; + +/** + * @public + */ +export type { __MetadataBearer }; +export { $Command }; +/** + * @public + * + * The input for {@link HttpEmptyPrefixHeadersCommand}. + */ +export interface HttpEmptyPrefixHeadersCommandInput extends HttpEmptyPrefixHeadersInput {} +/** + * @public + * + * The output of {@link HttpEmptyPrefixHeadersCommand}. + */ +export interface HttpEmptyPrefixHeadersCommandOutput extends HttpEmptyPrefixHeadersOutput, __MetadataBearer {} + +/** + * Clients that perform this test extract all headers from the response. + * @example + * Use a bare-bones client and the command you need to make an API call. + * ```javascript + * import { RestJsonProtocolClient, HttpEmptyPrefixHeadersCommand } from "@aws-sdk/aws-protocoltests-restjson"; // ES Modules import + * // const { RestJsonProtocolClient, HttpEmptyPrefixHeadersCommand } = require("@aws-sdk/aws-protocoltests-restjson"); // CommonJS import + * const client = new RestJsonProtocolClient(config); + * const input = { // HttpEmptyPrefixHeadersInput + * prefixHeaders: { // StringMap + * "": "STRING_VALUE", + * }, + * specificHeader: "STRING_VALUE", + * }; + * const command = new HttpEmptyPrefixHeadersCommand(input); + * const response = await client.send(command); + * // { // HttpEmptyPrefixHeadersOutput + * // prefixHeaders: { // StringMap + * // "": "STRING_VALUE", + * // }, + * // specificHeader: "STRING_VALUE", + * // }; + * + * ``` + * + * @param HttpEmptyPrefixHeadersCommandInput - {@link HttpEmptyPrefixHeadersCommandInput} + * @returns {@link HttpEmptyPrefixHeadersCommandOutput} + * @see {@link HttpEmptyPrefixHeadersCommandInput} for command's `input` shape. + * @see {@link HttpEmptyPrefixHeadersCommandOutput} for command's `response` shape. + * @see {@link RestJsonProtocolClientResolvedConfig | config} for RestJsonProtocolClient's `config` shape. + * + * @throws {@link RestJsonProtocolServiceException} + *

Base exception class for all service exceptions from RestJsonProtocol service.

+ * + * + * @public + */ +export class HttpEmptyPrefixHeadersCommand extends $Command + .classBuilder< + HttpEmptyPrefixHeadersCommandInput, + HttpEmptyPrefixHeadersCommandOutput, + RestJsonProtocolClientResolvedConfig, + ServiceInputTypes, + ServiceOutputTypes + >() + .m(function (this: any, Command: any, cs: any, config: RestJsonProtocolClientResolvedConfig, o: any) { + return [getSerdePlugin(config, this.serialize, this.deserialize)]; + }) + .s("RestJson", "HttpEmptyPrefixHeaders", {}) + .n("RestJsonProtocolClient", "HttpEmptyPrefixHeadersCommand") + .f(void 0, void 0) + .ser(se_HttpEmptyPrefixHeadersCommand) + .de(de_HttpEmptyPrefixHeadersCommand) + .build() { + /** @internal type navigation helper, not in runtime. */ + protected declare static __types: { + api: { + input: HttpEmptyPrefixHeadersInput; + output: HttpEmptyPrefixHeadersOutput; + }; + sdk: { + input: HttpEmptyPrefixHeadersCommandInput; + output: HttpEmptyPrefixHeadersCommandOutput; + }; + }; +} diff --git a/private/aws-protocoltests-restjson/src/commands/index.ts b/private/aws-protocoltests-restjson/src/commands/index.ts index 6623b538bd7e..f7eda1900482 100644 --- a/private/aws-protocoltests-restjson/src/commands/index.ts +++ b/private/aws-protocoltests-restjson/src/commands/index.ts @@ -14,6 +14,7 @@ export * from "./FractionalSecondsCommand"; export * from "./GreetingWithErrorsCommand"; export * from "./HostWithPathOperationCommand"; export * from "./HttpChecksumRequiredCommand"; +export * from "./HttpEmptyPrefixHeadersCommand"; export * from "./HttpEnumPayloadCommand"; export * from "./HttpPayloadTraitsCommand"; export * from "./HttpPayloadTraitsWithMediaTypeCommand"; diff --git a/private/aws-protocoltests-restjson/src/models/models_0.ts b/private/aws-protocoltests-restjson/src/models/models_0.ts index b6c85cff7236..fd6778ad51ae 100644 --- a/private/aws-protocoltests-restjson/src/models/models_0.ts +++ b/private/aws-protocoltests-restjson/src/models/models_0.ts @@ -328,6 +328,22 @@ export interface HttpChecksumRequiredInputOutput { foo?: string | undefined; } +/** + * @public + */ +export interface HttpEmptyPrefixHeadersInput { + prefixHeaders?: Record | undefined; + specificHeader?: string | undefined; +} + +/** + * @public + */ +export interface HttpEmptyPrefixHeadersOutput { + prefixHeaders?: Record | undefined; + specificHeader?: string | undefined; +} + /** * @public */ diff --git a/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts b/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts index 86463ad43a99..8e2842a902f6 100644 --- a/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts +++ b/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts @@ -105,6 +105,10 @@ import { HttpChecksumRequiredCommandInput, HttpChecksumRequiredCommandOutput, } from "../commands/HttpChecksumRequiredCommand"; +import { + HttpEmptyPrefixHeadersCommandInput, + HttpEmptyPrefixHeadersCommandOutput, +} from "../commands/HttpEmptyPrefixHeadersCommand"; import { HttpEnumPayloadCommandInput, HttpEnumPayloadCommandOutput } from "../commands/HttpEnumPayloadCommand"; import { HttpPayloadTraitsCommandInput, HttpPayloadTraitsCommandOutput } from "../commands/HttpPayloadTraitsCommand"; import { @@ -724,6 +728,28 @@ export const se_HttpChecksumRequiredCommand = async ( return b.build(); }; +/** + * serializeAws_restJson1HttpEmptyPrefixHeadersCommand + */ +export const se_HttpEmptyPrefixHeadersCommand = async ( + input: HttpEmptyPrefixHeadersCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const b = rb(input, context); + const headers: any = map({}, isSerializableHeaderValue, { + ...(input.prefixHeaders !== undefined && + Object.keys(input.prefixHeaders).reduce((acc: any, suffix: string) => { + acc[`${suffix.toLowerCase()}`] = input.prefixHeaders![suffix]; + return acc; + }, {})), + [_h]: input[_sH]!, + }); + b.bp("/HttpEmptyPrefixHeaders"); + let body: any; + b.m("GET").h(headers).b(body); + return b.build(); +}; + /** * serializeAws_restJson1HttpEnumPayloadCommand */ @@ -843,12 +869,12 @@ export const se_HttpPrefixHeadersCommand = async ( ): Promise<__HttpRequest> => { const b = rb(input, context); const headers: any = map({}, isSerializableHeaderValue, { - [_xf]: input[_f]!, ...(input.fooMap !== undefined && Object.keys(input.fooMap).reduce((acc: any, suffix: string) => { acc[`x-foo-${suffix.toLowerCase()}`] = input.fooMap![suffix]; return acc; }, {})), + [_xf]: input[_f]!, }); b.bp("/HttpPrefixHeaders"); let body: any; @@ -2922,6 +2948,33 @@ export const de_HttpChecksumRequiredCommand = async ( return contents; }; +/** + * deserializeAws_restJson1HttpEmptyPrefixHeadersCommand + */ +export const de_HttpEmptyPrefixHeadersCommand = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + if (output.statusCode !== 200 && output.statusCode >= 300) { + return de_CommandError(output, context); + } + const contents: any = map({ + $metadata: deserializeMetadata(output), + [_sH]: [, output.headers[_h]], + prefixHeaders: [ + , + Object.keys(output.headers) + .filter((header) => header.startsWith("")) + .reduce((acc, header) => { + acc[header.substring(0)] = output.headers[header]; + return acc; + }, {} as any), + ], + }); + await collectBody(output.body, context); + return contents; +}; + /** * deserializeAws_restJson1HttpEnumPayloadCommand */ @@ -5519,6 +5572,7 @@ const _qSu = "queryShort"; const _qT = "queryTimestamp"; const _qTL = "queryTimestampList"; const _s = "shortinheader"; +const _sH = "specificHeader"; const _sIH = "shortInHeader"; const _sIQ = "shortInQuery"; const _t = "timestamp"; diff --git a/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts b/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts index 1a8cad7801e7..e7884ac2d07b 100644 --- a/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts +++ b/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts @@ -20,6 +20,7 @@ import { FractionalSecondsCommand } from "../../src/commands/FractionalSecondsCo import { GreetingWithErrorsCommand } from "../../src/commands/GreetingWithErrorsCommand"; import { HostWithPathOperationCommand } from "../../src/commands/HostWithPathOperationCommand"; import { HttpChecksumRequiredCommand } from "../../src/commands/HttpChecksumRequiredCommand"; +import { HttpEmptyPrefixHeadersCommand } from "../../src/commands/HttpEmptyPrefixHeadersCommand"; import { HttpEnumPayloadCommand } from "../../src/commands/HttpEnumPayloadCommand"; import { HttpPayloadTraitsCommand } from "../../src/commands/HttpPayloadTraitsCommand"; import { HttpPayloadTraitsWithMediaTypeCommand } from "../../src/commands/HttpPayloadTraitsWithMediaTypeCommand"; @@ -1793,14 +1794,22 @@ it("RestJsonGreetingWithErrorsNoPayload:Response", async () => { }); /** - * Serializes the X-Amzn-ErrorType header. For an example service, see Amazon EKS. + * Parses simple JSON errors */ -it("RestJsonFooErrorUsingXAmznErrorType:Error:GreetingWithErrors", async () => { +it("RestJsonInvalidGreetingError:Error:GreetingWithErrors", async () => { const client = new RestJsonProtocolClient({ ...clientParams, - requestHandler: new ResponseDeserializationTestHandler(false, 500, { - "x-amzn-errortype": "FooError", - }), + requestHandler: new ResponseDeserializationTestHandler( + false, + 400, + { + "x-amzn-errortype": "InvalidGreeting", + "content-type": "application/json", + }, + `{ + "Message": "Hi" + }` + ), }); const params: any = {}; @@ -1809,30 +1818,51 @@ it("RestJsonFooErrorUsingXAmznErrorType:Error:GreetingWithErrors", async () => { try { await client.send(command); } catch (err) { - if (err.name !== "FooError") { + if (err.name !== "InvalidGreeting") { console.log(err); - fail(`Expected a FooError to be thrown, got ${err.name} instead`); + fail(`Expected a InvalidGreeting to be thrown, got ${err.name} instead`); return; } const r: any = err; - expect(r["$metadata"].httpStatusCode).toBe(500); + expect(r["$metadata"].httpStatusCode).toBe(400); + const paramsToValidate: any = [ + { + message: "Hi", + }, + ][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); + }); return; } fail("Expected an exception to be thrown from response"); }); /** - * Some X-Amzn-Errortype headers contain URLs. Clients need to split the URL on ':' and take only the first half of the string. For example, 'ValidationException:http://internal.amazon.com/coral/com.amazon.coral.validate/' - * is to be interpreted as 'ValidationException'. - * - * For an example service see Amazon Polly. + * Serializes a complex error with no message member */ -it("RestJsonFooErrorUsingXAmznErrorTypeWithUri:Error:GreetingWithErrors", async () => { +it("RestJsonComplexErrorWithNoMessage:Error:GreetingWithErrors", async () => { const client = new RestJsonProtocolClient({ ...clientParams, - requestHandler: new ResponseDeserializationTestHandler(false, 500, { - "x-amzn-errortype": "FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/", - }), + requestHandler: new ResponseDeserializationTestHandler( + false, + 403, + { + "x-amzn-errortype": "ComplexError", + "x-header": "Header", + "content-type": "application/json", + }, + `{ + "TopLevel": "Top level", + "Nested": { + "Fooooo": "bar" + } + }` + ), }); const params: any = {}; @@ -1841,28 +1871,46 @@ it("RestJsonFooErrorUsingXAmznErrorTypeWithUri:Error:GreetingWithErrors", async try { await client.send(command); } catch (err) { - if (err.name !== "FooError") { + if (err.name !== "ComplexError") { console.log(err); - fail(`Expected a FooError to be thrown, got ${err.name} instead`); + fail(`Expected a ComplexError to be thrown, got ${err.name} instead`); return; } const r: any = err; - expect(r["$metadata"].httpStatusCode).toBe(500); + expect(r["$metadata"].httpStatusCode).toBe(403); + const paramsToValidate: any = [ + { + Header: "Header", + TopLevel: "Top level", + Nested: { + Foo: "bar", + }, + }, + ][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); + }); return; } fail("Expected an exception to be thrown from response"); }); -/** - * X-Amzn-Errortype might contain a URL and a namespace. Client should extract only the shape name. This is a pathalogical case that might not actually happen in any deployed AWS service. - */ -it("RestJsonFooErrorUsingXAmznErrorTypeWithUriAndNamespace:Error:GreetingWithErrors", async () => { +it("RestJsonEmptyComplexErrorWithNoMessage:Error:GreetingWithErrors", async () => { const client = new RestJsonProtocolClient({ ...clientParams, - requestHandler: new ResponseDeserializationTestHandler(false, 500, { - "x-amzn-errortype": - "aws.protocoltests.restjson#FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/", - }), + requestHandler: new ResponseDeserializationTestHandler( + false, + 403, + { + "x-amzn-errortype": "ComplexError", + "content-type": "application/json", + }, + `{}` + ), }); const params: any = {}; @@ -1871,36 +1919,27 @@ it("RestJsonFooErrorUsingXAmznErrorTypeWithUriAndNamespace:Error:GreetingWithErr try { await client.send(command); } catch (err) { - if (err.name !== "FooError") { + if (err.name !== "ComplexError") { console.log(err); - fail(`Expected a FooError to be thrown, got ${err.name} instead`); + fail(`Expected a ComplexError to be thrown, got ${err.name} instead`); return; } const r: any = err; - expect(r["$metadata"].httpStatusCode).toBe(500); + expect(r["$metadata"].httpStatusCode).toBe(403); return; } fail("Expected an exception to be thrown from response"); }); /** - * This example uses the 'code' property in the output rather than X-Amzn-Errortype. Some services do this though it's preferable to send the X-Amzn-Errortype. Client implementations must first check for the X-Amzn-Errortype and then check for a top-level 'code' property. - * - * For example service see Amazon S3 Glacier. + * Serializes the X-Amzn-ErrorType header. For an example service, see Amazon EKS. */ -it("RestJsonFooErrorUsingCode:Error:GreetingWithErrors", async () => { +it("RestJsonFooErrorUsingXAmznErrorType:Error:GreetingWithErrors", async () => { const client = new RestJsonProtocolClient({ ...clientParams, - requestHandler: new ResponseDeserializationTestHandler( - false, - 500, - { - "content-type": "application/json", - }, - `{ - "code": "FooError" - }` - ), + requestHandler: new ResponseDeserializationTestHandler(false, 500, { + "x-amzn-errortype": "FooError", + }), }); const params: any = {}; @@ -1922,21 +1961,17 @@ it("RestJsonFooErrorUsingCode:Error:GreetingWithErrors", async () => { }); /** - * Some services serialize errors using code, and it might contain a namespace. Clients should just take the last part of the string after '#'. + * Some X-Amzn-Errortype headers contain URLs. Clients need to split the URL on ':' and take only the first half of the string. For example, 'ValidationException:http://internal.amazon.com/coral/com.amazon.coral.validate/' + * is to be interpreted as 'ValidationException'. + * + * For an example service see Amazon Polly. */ -it("RestJsonFooErrorUsingCodeAndNamespace:Error:GreetingWithErrors", async () => { +it("RestJsonFooErrorUsingXAmznErrorTypeWithUri:Error:GreetingWithErrors", async () => { const client = new RestJsonProtocolClient({ ...clientParams, - requestHandler: new ResponseDeserializationTestHandler( - false, - 500, - { - "content-type": "application/json", - }, - `{ - "code": "aws.protocoltests.restjson#FooError" - }` - ), + requestHandler: new ResponseDeserializationTestHandler(false, 500, { + "x-amzn-errortype": "FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/", + }), }); const params: any = {}; @@ -1958,21 +1993,15 @@ it("RestJsonFooErrorUsingCodeAndNamespace:Error:GreetingWithErrors", async () => }); /** - * Some services serialize errors using code, and it might contain a namespace. It also might contain a URI. Clients should just take the last part of the string after '#' and before ":". This is a pathalogical case that might not occur in any deployed AWS service. + * X-Amzn-Errortype might contain a URL and a namespace. Client should extract only the shape name. This is a pathalogical case that might not actually happen in any deployed AWS service. */ -it("RestJsonFooErrorUsingCodeUriAndNamespace:Error:GreetingWithErrors", async () => { +it("RestJsonFooErrorUsingXAmznErrorTypeWithUriAndNamespace:Error:GreetingWithErrors", async () => { const client = new RestJsonProtocolClient({ ...clientParams, - requestHandler: new ResponseDeserializationTestHandler( - false, - 500, - { - "content-type": "application/json", - }, - `{ - "code": "aws.protocoltests.restjson#FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/" - }` - ), + requestHandler: new ResponseDeserializationTestHandler(false, 500, { + "x-amzn-errortype": + "aws.protocoltests.restjson#FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/", + }), }); const params: any = {}; @@ -1994,9 +2023,11 @@ it("RestJsonFooErrorUsingCodeUriAndNamespace:Error:GreetingWithErrors", async () }); /** - * Some services serialize errors using __type. + * This example uses the 'code' property in the output rather than X-Amzn-Errortype. Some services do this though it's preferable to send the X-Amzn-Errortype. Client implementations must first check for the X-Amzn-Errortype and then check for a top-level 'code' property. + * + * For example service see Amazon S3 Glacier. */ -it("RestJsonFooErrorWithDunderType:Error:GreetingWithErrors", async () => { +it("RestJsonFooErrorUsingCode:Error:GreetingWithErrors", async () => { const client = new RestJsonProtocolClient({ ...clientParams, requestHandler: new ResponseDeserializationTestHandler( @@ -2006,7 +2037,7 @@ it("RestJsonFooErrorWithDunderType:Error:GreetingWithErrors", async () => { "content-type": "application/json", }, `{ - "__type": "FooError" + "code": "FooError" }` ), }); @@ -2030,9 +2061,9 @@ it("RestJsonFooErrorWithDunderType:Error:GreetingWithErrors", async () => { }); /** - * Some services serialize errors using __type, and it might contain a namespace. Clients should just take the last part of the string after '#'. + * Some services serialize errors using code, and it might contain a namespace. Clients should just take the last part of the string after '#'. */ -it("RestJsonFooErrorWithDunderTypeAndNamespace:Error:GreetingWithErrors", async () => { +it("RestJsonFooErrorUsingCodeAndNamespace:Error:GreetingWithErrors", async () => { const client = new RestJsonProtocolClient({ ...clientParams, requestHandler: new ResponseDeserializationTestHandler( @@ -2042,7 +2073,7 @@ it("RestJsonFooErrorWithDunderTypeAndNamespace:Error:GreetingWithErrors", async "content-type": "application/json", }, `{ - "__type": "aws.protocoltests.restjson#FooError" + "code": "aws.protocoltests.restjson#FooError" }` ), }); @@ -2066,9 +2097,9 @@ it("RestJsonFooErrorWithDunderTypeAndNamespace:Error:GreetingWithErrors", async }); /** - * Some services serialize errors using __type, and it might contain a namespace. It also might contain a URI. Clients should just take the last part of the string after '#' and before ":". This is a pathalogical case that might not occur in any deployed AWS service. + * Some services serialize errors using code, and it might contain a namespace. It also might contain a URI. Clients should just take the last part of the string after '#' and before ":". This is a pathalogical case that might not occur in any deployed AWS service. */ -it("RestJsonFooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", async () => { +it("RestJsonFooErrorUsingCodeUriAndNamespace:Error:GreetingWithErrors", async () => { const client = new RestJsonProtocolClient({ ...clientParams, requestHandler: new ResponseDeserializationTestHandler( @@ -2078,7 +2109,7 @@ it("RestJsonFooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", asy "content-type": "application/json", }, `{ - "__type": "aws.protocoltests.restjson#FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/" + "code": "aws.protocoltests.restjson#FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/" }` ), }); @@ -2102,24 +2133,19 @@ it("RestJsonFooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", asy }); /** - * Serializes a complex error with no message member + * Some services serialize errors using __type. */ -it("RestJsonComplexErrorWithNoMessage:Error:GreetingWithErrors", async () => { +it("RestJsonFooErrorWithDunderType:Error:GreetingWithErrors", async () => { const client = new RestJsonProtocolClient({ ...clientParams, requestHandler: new ResponseDeserializationTestHandler( false, - 403, + 500, { - "x-amzn-errortype": "ComplexError", - "x-header": "Header", "content-type": "application/json", }, `{ - "TopLevel": "Top level", - "Nested": { - "Fooooo": "bar" - } + "__type": "FooError" }` ), }); @@ -2130,45 +2156,33 @@ it("RestJsonComplexErrorWithNoMessage:Error:GreetingWithErrors", async () => { try { await client.send(command); } catch (err) { - if (err.name !== "ComplexError") { + if (err.name !== "FooError") { console.log(err); - fail(`Expected a ComplexError to be thrown, got ${err.name} instead`); + fail(`Expected a FooError to be thrown, got ${err.name} instead`); return; } const r: any = err; - expect(r["$metadata"].httpStatusCode).toBe(403); - const paramsToValidate: any = [ - { - Header: "Header", - TopLevel: "Top level", - Nested: { - Foo: "bar", - }, - }, - ][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); - }); + expect(r["$metadata"].httpStatusCode).toBe(500); return; } fail("Expected an exception to be thrown from response"); }); -it("RestJsonEmptyComplexErrorWithNoMessage:Error:GreetingWithErrors", async () => { +/** + * Some services serialize errors using __type, and it might contain a namespace. Clients should just take the last part of the string after '#'. + */ +it("RestJsonFooErrorWithDunderTypeAndNamespace:Error:GreetingWithErrors", async () => { const client = new RestJsonProtocolClient({ ...clientParams, requestHandler: new ResponseDeserializationTestHandler( false, - 403, + 500, { - "x-amzn-errortype": "ComplexError", "content-type": "application/json", }, - `{}` + `{ + "__type": "aws.protocoltests.restjson#FooError" + }` ), }); @@ -2178,33 +2192,32 @@ it("RestJsonEmptyComplexErrorWithNoMessage:Error:GreetingWithErrors", async () = try { await client.send(command); } catch (err) { - if (err.name !== "ComplexError") { + if (err.name !== "FooError") { console.log(err); - fail(`Expected a ComplexError to be thrown, got ${err.name} instead`); + fail(`Expected a FooError to be thrown, got ${err.name} instead`); return; } const r: any = err; - expect(r["$metadata"].httpStatusCode).toBe(403); + expect(r["$metadata"].httpStatusCode).toBe(500); return; } fail("Expected an exception to be thrown from response"); }); /** - * Parses simple JSON errors + * Some services serialize errors using __type, and it might contain a namespace. It also might contain a URI. Clients should just take the last part of the string after '#' and before ":". This is a pathalogical case that might not occur in any deployed AWS service. */ -it("RestJsonInvalidGreetingError:Error:GreetingWithErrors", async () => { +it("RestJsonFooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", async () => { const client = new RestJsonProtocolClient({ ...clientParams, requestHandler: new ResponseDeserializationTestHandler( false, - 400, + 500, { - "x-amzn-errortype": "InvalidGreeting", "content-type": "application/json", }, `{ - "Message": "Hi" + "__type": "aws.protocoltests.restjson#FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/" }` ), }); @@ -2215,25 +2228,13 @@ it("RestJsonInvalidGreetingError:Error:GreetingWithErrors", async () => { try { await client.send(command); } catch (err) { - if (err.name !== "InvalidGreeting") { + if (err.name !== "FooError") { console.log(err); - fail(`Expected a InvalidGreeting to be thrown, got ${err.name} instead`); + fail(`Expected a FooError to be thrown, got ${err.name} instead`); return; } const r: any = err; - expect(r["$metadata"].httpStatusCode).toBe(400); - const paramsToValidate: any = [ - { - message: "Hi", - }, - ][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); - }); + expect(r["$metadata"].httpStatusCode).toBe(500); return; } fail("Expected an exception to be thrown from response"); @@ -2306,6 +2307,83 @@ it("RestJsonHttpChecksumRequired:Request", async () => { } }); +/** + * Serializes all request headers, using specific when present + */ +it("RestJsonHttpEmptyPrefixHeadersRequestClient:Request", async () => { + const client = new RestJsonProtocolClient({ + ...clientParams, + requestHandler: new RequestSerializationTestHandler(), + }); + + const command = new HttpEmptyPrefixHeadersCommand({ + prefixHeaders: { + "x-foo": "Foo", + hello: "Hello", + } as any, + specificHeader: "There", + } as any); + try { + await client.send(command); + fail("Expected an EXPECTED_REQUEST_SERIALIZATION_ERROR to be thrown"); + return; + } catch (err) { + if (!(err instanceof EXPECTED_REQUEST_SERIALIZATION_ERROR)) { + fail(err); + return; + } + const r = err.request; + expect(r.method).toBe("GET"); + expect(r.path).toBe("/HttpEmptyPrefixHeaders"); + + expect(r.headers["hello"]).toBe("There"); + expect(r.headers["x-foo"]).toBe("Foo"); + + expect(!r.body || r.body === `{}`).toBeTruthy(); + } +}); + +/** + * Deserializes all response headers with the same for prefix and specific + */ +it("RestJsonHttpEmptyPrefixHeadersResponseClient:Response", async () => { + const client = new RestJsonProtocolClient({ + ...clientParams, + requestHandler: new ResponseDeserializationTestHandler(true, 200, { + "x-foo": "Foo", + hello: "There", + }), + }); + + const params: any = {}; + const command = new HttpEmptyPrefixHeadersCommand(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); + const paramsToValidate: any = [ + { + prefixHeaders: { + "x-foo": "Foo", + hello: "There", + }, + specificHeader: "There", + }, + ][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); + }); +}); + it("RestJsonEnumPayloadRequest:Request", async () => { const client = new RestJsonProtocolClient({ ...clientParams, diff --git a/private/aws-protocoltests-restxml/README.md b/private/aws-protocoltests-restxml/README.md index dc72ab39fefe..032461861391 100644 --- a/private/aws-protocoltests-restxml/README.md +++ b/private/aws-protocoltests-restxml/README.md @@ -1058,6 +1058,14 @@ HttpChecksumRequired [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/rest-xml-protocol/command/HttpChecksumRequiredCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-xml-protocol/Interface/HttpChecksumRequiredCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-xml-protocol/Interface/HttpChecksumRequiredCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/rest-xml-protocol/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-xml-protocol/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-xml-protocol/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
@@ -1986,6 +1994,14 @@ GreetingWithErrors [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/rest-xml-protocol/command/GreetingWithErrorsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-xml-protocol/Interface/GreetingWithErrorsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-xml-protocol/Interface/GreetingWithErrorsCommandOutput/) +
+
+ +HttpEmptyPrefixHeaders + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/rest-xml-protocol/command/HttpEmptyPrefixHeadersCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-xml-protocol/Interface/HttpEmptyPrefixHeadersCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-xml-protocol/Interface/HttpEmptyPrefixHeadersCommandOutput/) +
diff --git a/private/aws-protocoltests-restxml/src/RestXmlProtocol.ts b/private/aws-protocoltests-restxml/src/RestXmlProtocol.ts index c4e6be67e019..50615e113b4c 100644 --- a/private/aws-protocoltests-restxml/src/RestXmlProtocol.ts +++ b/private/aws-protocoltests-restxml/src/RestXmlProtocol.ts @@ -77,6 +77,11 @@ import { GreetingWithErrorsCommandInput, GreetingWithErrorsCommandOutput, } from "./commands/GreetingWithErrorsCommand"; +import { + HttpEmptyPrefixHeadersCommand, + HttpEmptyPrefixHeadersCommandInput, + HttpEmptyPrefixHeadersCommandOutput, +} from "./commands/HttpEmptyPrefixHeadersCommand"; import { HttpEnumPayloadCommand, HttpEnumPayloadCommandInput, @@ -311,6 +316,7 @@ const commands = { FlattenedXmlMapWithXmlNamespaceCommand, FractionalSecondsCommand, GreetingWithErrorsCommand, + HttpEmptyPrefixHeadersCommand, HttpEnumPayloadCommand, HttpPayloadTraitsCommand, HttpPayloadTraitsWithMediaTypeCommand, @@ -620,6 +626,24 @@ export interface RestXmlProtocol { cb: (err: any, data?: GreetingWithErrorsCommandOutput) => void ): void; + /** + * @see {@link HttpEmptyPrefixHeadersCommand} + */ + httpEmptyPrefixHeaders(): Promise; + httpEmptyPrefixHeaders( + args: HttpEmptyPrefixHeadersCommandInput, + options?: __HttpHandlerOptions + ): Promise; + httpEmptyPrefixHeaders( + args: HttpEmptyPrefixHeadersCommandInput, + cb: (err: any, data?: HttpEmptyPrefixHeadersCommandOutput) => void + ): void; + httpEmptyPrefixHeaders( + args: HttpEmptyPrefixHeadersCommandInput, + options: __HttpHandlerOptions, + cb: (err: any, data?: HttpEmptyPrefixHeadersCommandOutput) => void + ): void; + /** * @see {@link HttpEnumPayloadCommand} */ diff --git a/private/aws-protocoltests-restxml/src/RestXmlProtocolClient.ts b/private/aws-protocoltests-restxml/src/RestXmlProtocolClient.ts index e2a7280ac602..b2eb57b2ed67 100644 --- a/private/aws-protocoltests-restxml/src/RestXmlProtocolClient.ts +++ b/private/aws-protocoltests-restxml/src/RestXmlProtocolClient.ts @@ -102,6 +102,10 @@ import { } from "./commands/FlattenedXmlMapWithXmlNamespaceCommand"; import { FractionalSecondsCommandInput, FractionalSecondsCommandOutput } from "./commands/FractionalSecondsCommand"; import { GreetingWithErrorsCommandInput, GreetingWithErrorsCommandOutput } from "./commands/GreetingWithErrorsCommand"; +import { + HttpEmptyPrefixHeadersCommandInput, + HttpEmptyPrefixHeadersCommandOutput, +} from "./commands/HttpEmptyPrefixHeadersCommand"; import { HttpEnumPayloadCommandInput, HttpEnumPayloadCommandOutput } from "./commands/HttpEnumPayloadCommand"; import { HttpPayloadTraitsCommandInput, HttpPayloadTraitsCommandOutput } from "./commands/HttpPayloadTraitsCommand"; import { @@ -246,6 +250,7 @@ export type ServiceInputTypes = | FlattenedXmlMapWithXmlNamespaceCommandInput | FractionalSecondsCommandInput | GreetingWithErrorsCommandInput + | HttpEmptyPrefixHeadersCommandInput | HttpEnumPayloadCommandInput | HttpPayloadTraitsCommandInput | HttpPayloadTraitsWithMediaTypeCommandInput @@ -314,6 +319,7 @@ export type ServiceOutputTypes = | FlattenedXmlMapWithXmlNamespaceCommandOutput | FractionalSecondsCommandOutput | GreetingWithErrorsCommandOutput + | HttpEmptyPrefixHeadersCommandOutput | HttpEnumPayloadCommandOutput | HttpPayloadTraitsCommandOutput | HttpPayloadTraitsWithMediaTypeCommandOutput diff --git a/private/aws-protocoltests-restxml/src/commands/HttpEmptyPrefixHeadersCommand.ts b/private/aws-protocoltests-restxml/src/commands/HttpEmptyPrefixHeadersCommand.ts new file mode 100644 index 000000000000..5092d361de23 --- /dev/null +++ b/private/aws-protocoltests-restxml/src/commands/HttpEmptyPrefixHeadersCommand.ts @@ -0,0 +1,93 @@ +// smithy-typescript generated code +import { getSerdePlugin } from "@smithy/middleware-serde"; +import { Command as $Command } from "@smithy/smithy-client"; +import { MetadataBearer as __MetadataBearer } from "@smithy/types"; + +import { HttpEmptyPrefixHeadersInput, HttpEmptyPrefixHeadersOutput } from "../models/models_0"; +import { de_HttpEmptyPrefixHeadersCommand, se_HttpEmptyPrefixHeadersCommand } from "../protocols/Aws_restXml"; +import { RestXmlProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RestXmlProtocolClient"; + +/** + * @public + */ +export type { __MetadataBearer }; +export { $Command }; +/** + * @public + * + * The input for {@link HttpEmptyPrefixHeadersCommand}. + */ +export interface HttpEmptyPrefixHeadersCommandInput extends HttpEmptyPrefixHeadersInput {} +/** + * @public + * + * The output of {@link HttpEmptyPrefixHeadersCommand}. + */ +export interface HttpEmptyPrefixHeadersCommandOutput extends HttpEmptyPrefixHeadersOutput, __MetadataBearer {} + +/** + * Clients that perform this test extract all headers from the response. + * @example + * Use a bare-bones client and the command you need to make an API call. + * ```javascript + * import { RestXmlProtocolClient, HttpEmptyPrefixHeadersCommand } from "@aws-sdk/aws-protocoltests-restxml"; // ES Modules import + * // const { RestXmlProtocolClient, HttpEmptyPrefixHeadersCommand } = require("@aws-sdk/aws-protocoltests-restxml"); // CommonJS import + * const client = new RestXmlProtocolClient(config); + * const input = { // HttpEmptyPrefixHeadersInput + * prefixHeaders: { // StringMap + * "": "STRING_VALUE", + * }, + * specificHeader: "STRING_VALUE", + * }; + * const command = new HttpEmptyPrefixHeadersCommand(input); + * const response = await client.send(command); + * // { // HttpEmptyPrefixHeadersOutput + * // prefixHeaders: { // StringMap + * // "": "STRING_VALUE", + * // }, + * // specificHeader: "STRING_VALUE", + * // }; + * + * ``` + * + * @param HttpEmptyPrefixHeadersCommandInput - {@link HttpEmptyPrefixHeadersCommandInput} + * @returns {@link HttpEmptyPrefixHeadersCommandOutput} + * @see {@link HttpEmptyPrefixHeadersCommandInput} for command's `input` shape. + * @see {@link HttpEmptyPrefixHeadersCommandOutput} for command's `response` shape. + * @see {@link RestXmlProtocolClientResolvedConfig | config} for RestXmlProtocolClient's `config` shape. + * + * @throws {@link RestXmlProtocolServiceException} + *

Base exception class for all service exceptions from RestXmlProtocol service.

+ * + * + * @public + */ +export class HttpEmptyPrefixHeadersCommand extends $Command + .classBuilder< + HttpEmptyPrefixHeadersCommandInput, + HttpEmptyPrefixHeadersCommandOutput, + RestXmlProtocolClientResolvedConfig, + ServiceInputTypes, + ServiceOutputTypes + >() + .m(function (this: any, Command: any, cs: any, config: RestXmlProtocolClientResolvedConfig, o: any) { + return [getSerdePlugin(config, this.serialize, this.deserialize)]; + }) + .s("RestXml", "HttpEmptyPrefixHeaders", {}) + .n("RestXmlProtocolClient", "HttpEmptyPrefixHeadersCommand") + .f(void 0, void 0) + .ser(se_HttpEmptyPrefixHeadersCommand) + .de(de_HttpEmptyPrefixHeadersCommand) + .build() { + /** @internal type navigation helper, not in runtime. */ + protected declare static __types: { + api: { + input: HttpEmptyPrefixHeadersInput; + output: HttpEmptyPrefixHeadersOutput; + }; + sdk: { + input: HttpEmptyPrefixHeadersCommandInput; + output: HttpEmptyPrefixHeadersCommandOutput; + }; + }; +} diff --git a/private/aws-protocoltests-restxml/src/commands/index.ts b/private/aws-protocoltests-restxml/src/commands/index.ts index d4f6576e3c5b..50121935c427 100644 --- a/private/aws-protocoltests-restxml/src/commands/index.ts +++ b/private/aws-protocoltests-restxml/src/commands/index.ts @@ -14,6 +14,7 @@ export * from "./FlattenedXmlMapWithXmlNameCommand"; export * from "./FlattenedXmlMapWithXmlNamespaceCommand"; export * from "./FractionalSecondsCommand"; export * from "./GreetingWithErrorsCommand"; +export * from "./HttpEmptyPrefixHeadersCommand"; export * from "./HttpEnumPayloadCommand"; export * from "./HttpPayloadTraitsCommand"; export * from "./HttpPayloadTraitsWithMediaTypeCommand"; diff --git a/private/aws-protocoltests-restxml/src/models/models_0.ts b/private/aws-protocoltests-restxml/src/models/models_0.ts index 7a9af185f37e..4f865e536ae7 100644 --- a/private/aws-protocoltests-restxml/src/models/models_0.ts +++ b/private/aws-protocoltests-restxml/src/models/models_0.ts @@ -254,6 +254,22 @@ export class InvalidGreeting extends __BaseException { } } +/** + * @public + */ +export interface HttpEmptyPrefixHeadersInput { + prefixHeaders?: Record | undefined; + specificHeader?: string | undefined; +} + +/** + * @public + */ +export interface HttpEmptyPrefixHeadersOutput { + prefixHeaders?: Record | undefined; + specificHeader?: string | undefined; +} + /** * @public */ diff --git a/private/aws-protocoltests-restxml/src/protocols/Aws_restXml.ts b/private/aws-protocoltests-restxml/src/protocols/Aws_restXml.ts index c59c1d375682..8262a7d9d7e4 100644 --- a/private/aws-protocoltests-restxml/src/protocols/Aws_restXml.ts +++ b/private/aws-protocoltests-restxml/src/protocols/Aws_restXml.ts @@ -86,6 +86,10 @@ import { } from "../commands/FlattenedXmlMapWithXmlNamespaceCommand"; import { FractionalSecondsCommandInput, FractionalSecondsCommandOutput } from "../commands/FractionalSecondsCommand"; import { GreetingWithErrorsCommandInput, GreetingWithErrorsCommandOutput } from "../commands/GreetingWithErrorsCommand"; +import { + HttpEmptyPrefixHeadersCommandInput, + HttpEmptyPrefixHeadersCommandOutput, +} from "../commands/HttpEmptyPrefixHeadersCommand"; import { HttpEnumPayloadCommandInput, HttpEnumPayloadCommandOutput } from "../commands/HttpEnumPayloadCommand"; import { HttpPayloadTraitsCommandInput, HttpPayloadTraitsCommandOutput } from "../commands/HttpPayloadTraitsCommand"; import { @@ -581,6 +585,28 @@ export const se_GreetingWithErrorsCommand = async ( return b.build(); }; +/** + * serializeAws_restXmlHttpEmptyPrefixHeadersCommand + */ +export const se_HttpEmptyPrefixHeadersCommand = async ( + input: HttpEmptyPrefixHeadersCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const b = rb(input, context); + const headers: any = map({}, isSerializableHeaderValue, { + ...(input.prefixHeaders !== undefined && + Object.keys(input.prefixHeaders).reduce((acc: any, suffix: string) => { + acc[`${suffix.toLowerCase()}`] = input.prefixHeaders![suffix]; + return acc; + }, {})), + [_h]: input[_sH]!, + }); + b.bp("/HttpEmptyPrefixHeaders"); + let body: any; + b.m("GET").h(headers).b(body); + return b.build(); +}; + /** * serializeAws_restXmlHttpEnumPayloadCommand */ @@ -799,12 +825,12 @@ export const se_HttpPrefixHeadersCommand = async ( ): Promise<__HttpRequest> => { const b = rb(input, context); const headers: any = map({}, isSerializableHeaderValue, { - [_xf]: input[_f]!, ...(input.fooMap !== undefined && Object.keys(input.fooMap).reduce((acc: any, suffix: string) => { acc[`x-foo-${suffix.toLowerCase()}`] = input.fooMap![suffix]; return acc; }, {})), + [_xf]: input[_f]!, }); b.bp("/HttpPrefixHeaders"); let body: any; @@ -2026,6 +2052,33 @@ export const de_GreetingWithErrorsCommand = async ( return contents; }; +/** + * deserializeAws_restXmlHttpEmptyPrefixHeadersCommand + */ +export const de_HttpEmptyPrefixHeadersCommand = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + if (output.statusCode !== 200 && output.statusCode >= 300) { + return de_CommandError(output, context); + } + const contents: any = map({ + $metadata: deserializeMetadata(output), + [_sH]: [, output.headers[_h]], + prefixHeaders: [ + , + Object.keys(output.headers) + .filter((header) => header.startsWith("")) + .reduce((acc, header) => { + acc[header.substring(0)] = output.headers[header]; + return acc; + }, {} as any), + ], + }); + await collectBody(output.body, context); + return contents; +}; + /** * deserializeAws_restXmlHttpEnumPayloadCommand */ @@ -4668,6 +4721,7 @@ const _qTL = "queryTimestampList"; const _r = "renamed"; const _rLM = "renamedListMembers"; const _rM = "recursiveMember"; +const _sH = "specificHeader"; const _sL = "stringList"; const _sLt = "structureList"; const _sS = "stringSet"; diff --git a/private/aws-protocoltests-restxml/test/functional/restxml.spec.ts b/private/aws-protocoltests-restxml/test/functional/restxml.spec.ts index 49a6023682ce..acebc45d1139 100644 --- a/private/aws-protocoltests-restxml/test/functional/restxml.spec.ts +++ b/private/aws-protocoltests-restxml/test/functional/restxml.spec.ts @@ -22,6 +22,7 @@ import { FlattenedXmlMapWithXmlNameCommand } from "../../src/commands/FlattenedX import { FlattenedXmlMapWithXmlNamespaceCommand } from "../../src/commands/FlattenedXmlMapWithXmlNamespaceCommand"; import { FractionalSecondsCommand } from "../../src/commands/FractionalSecondsCommand"; import { GreetingWithErrorsCommand } from "../../src/commands/GreetingWithErrorsCommand"; +import { HttpEmptyPrefixHeadersCommand } from "../../src/commands/HttpEmptyPrefixHeadersCommand"; import { HttpEnumPayloadCommand } from "../../src/commands/HttpEnumPayloadCommand"; import { HttpPayloadTraitsCommand } from "../../src/commands/HttpPayloadTraitsCommand"; import { HttpPayloadTraitsWithMediaTypeCommand } from "../../src/commands/HttpPayloadTraitsWithMediaTypeCommand"; @@ -1447,6 +1448,83 @@ it("ComplexError:Error:GreetingWithErrors", async () => { fail("Expected an exception to be thrown from response"); }); +/** + * Serializes all request headers, using specific when present + */ +it("HttpEmptyPrefixHeadersRequestClient:Request", async () => { + const client = new RestXmlProtocolClient({ + ...clientParams, + requestHandler: new RequestSerializationTestHandler(), + }); + + const command = new HttpEmptyPrefixHeadersCommand({ + prefixHeaders: { + "x-foo": "Foo", + hello: "Hello", + } as any, + specificHeader: "There", + } as any); + try { + await client.send(command); + fail("Expected an EXPECTED_REQUEST_SERIALIZATION_ERROR to be thrown"); + return; + } catch (err) { + if (!(err instanceof EXPECTED_REQUEST_SERIALIZATION_ERROR)) { + fail(err); + return; + } + const r = err.request; + expect(r.method).toBe("GET"); + expect(r.path).toBe("/HttpEmptyPrefixHeaders"); + + expect(r.headers["hello"]).toBe("There"); + expect(r.headers["x-foo"]).toBe("Foo"); + + expect(!r.body || r.body === `{}`).toBeTruthy(); + } +}); + +/** + * Deserializes all response headers with the same for prefix and specific + */ +it("HttpEmptyPrefixHeadersResponseClient:Response", async () => { + const client = new RestXmlProtocolClient({ + ...clientParams, + requestHandler: new ResponseDeserializationTestHandler(true, 200, { + "x-foo": "Foo", + hello: "There", + }), + }); + + const params: any = {}; + const command = new HttpEmptyPrefixHeadersCommand(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); + const paramsToValidate: any = [ + { + prefixHeaders: { + "x-foo": "Foo", + hello: "There", + }, + specificHeader: "There", + }, + ][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); + }); +}); + it("RestXmlEnumPayloadRequest:Request", async () => { const client = new RestXmlProtocolClient({ ...clientParams, diff --git a/private/aws-restjson-server/src/models/models_0.ts b/private/aws-restjson-server/src/models/models_0.ts index 9742474e9fdc..d51034687a63 100644 --- a/private/aws-restjson-server/src/models/models_0.ts +++ b/private/aws-restjson-server/src/models/models_0.ts @@ -1244,6 +1244,96 @@ export namespace HttpChecksumRequiredInputOutput { }; } +/** + * @public + */ +export interface HttpEmptyPrefixHeadersInput { + prefixHeaders?: Record | undefined; + specificHeader?: string | undefined; +} + +export namespace HttpEmptyPrefixHeadersInput { + const memberValidators: { + prefixHeaders?: __MultiConstraintValidator>; + specificHeader?: __MultiConstraintValidator; + } = {}; + /** + * @internal + */ + export const validate = (obj: HttpEmptyPrefixHeadersInput, path = ""): __ValidationFailure[] => { + function getMemberValidator( + member: T + ): NonNullable<(typeof memberValidators)[T]> { + if (memberValidators[member] === undefined) { + switch (member) { + case "prefixHeaders": { + memberValidators["prefixHeaders"] = new __CompositeMapValidator( + new __NoOpValidator(), + new __NoOpValidator(), + new __NoOpValidator() + ); + break; + } + case "specificHeader": { + memberValidators["specificHeader"] = new __NoOpValidator(); + break; + } + } + } + return memberValidators[member]!; + } + return [ + ...getMemberValidator("prefixHeaders").validate(obj.prefixHeaders, `${path}/prefixHeaders`), + ...getMemberValidator("specificHeader").validate(obj.specificHeader, `${path}/specificHeader`), + ]; + }; +} + +/** + * @public + */ +export interface HttpEmptyPrefixHeadersOutput { + prefixHeaders?: Record | undefined; + specificHeader?: string | undefined; +} + +export namespace HttpEmptyPrefixHeadersOutput { + const memberValidators: { + prefixHeaders?: __MultiConstraintValidator>; + specificHeader?: __MultiConstraintValidator; + } = {}; + /** + * @internal + */ + export const validate = (obj: HttpEmptyPrefixHeadersOutput, path = ""): __ValidationFailure[] => { + function getMemberValidator( + member: T + ): NonNullable<(typeof memberValidators)[T]> { + if (memberValidators[member] === undefined) { + switch (member) { + case "prefixHeaders": { + memberValidators["prefixHeaders"] = new __CompositeMapValidator( + new __NoOpValidator(), + new __NoOpValidator(), + new __NoOpValidator() + ); + break; + } + case "specificHeader": { + memberValidators["specificHeader"] = new __NoOpValidator(); + break; + } + } + } + return memberValidators[member]!; + } + return [ + ...getMemberValidator("prefixHeaders").validate(obj.prefixHeaders, `${path}/prefixHeaders`), + ...getMemberValidator("specificHeader").validate(obj.specificHeader, `${path}/specificHeader`), + ]; + }; +} + /** * @public */ diff --git a/private/aws-restjson-server/src/protocols/Aws_restJson1.ts b/private/aws-restjson-server/src/protocols/Aws_restJson1.ts index ce079df7d7d9..ced9e4196ca2 100644 --- a/private/aws-restjson-server/src/protocols/Aws_restJson1.ts +++ b/private/aws-restjson-server/src/protocols/Aws_restJson1.ts @@ -130,6 +130,10 @@ import { HttpChecksumRequiredServerInput, HttpChecksumRequiredServerOutput, } from "../server/operations/HttpChecksumRequired"; +import { + HttpEmptyPrefixHeadersServerInput, + HttpEmptyPrefixHeadersServerOutput, +} from "../server/operations/HttpEmptyPrefixHeaders"; import { HttpEnumPayloadServerInput, HttpEnumPayloadServerOutput } from "../server/operations/HttpEnumPayload"; import { HttpPayloadTraitsServerInput, HttpPayloadTraitsServerOutput } from "../server/operations/HttpPayloadTraits"; import { @@ -1017,6 +1021,42 @@ export const deserializeHttpChecksumRequiredRequest = async ( return contents; }; +export const deserializeHttpEmptyPrefixHeadersRequest = async ( + output: __HttpRequest, + context: __SerdeContext +): Promise => { + const contentTypeHeaderKey: string | undefined = Object.keys(output.headers).find( + (key) => key.toLowerCase() === "content-type" + ); + if (contentTypeHeaderKey != null) { + const contentType = output.headers[contentTypeHeaderKey]; + if (contentType !== undefined && contentType !== "application/json") { + throw new __UnsupportedMediaTypeException(); + } + } + const acceptHeaderKey: string | undefined = Object.keys(output.headers).find((key) => key.toLowerCase() === "accept"); + if (acceptHeaderKey != null) { + const accept = output.headers[acceptHeaderKey]; + if (!__acceptMatches(accept, "application/json")) { + throw new __NotAcceptableException(); + } + } + const contents: any = map({ + [_sH]: [, output.headers[_h]], + prefixHeaders: [ + , + Object.keys(output.headers) + .filter((header) => header.startsWith("")) + .reduce((acc, header) => { + acc[header.substring(0)] = output.headers[header]; + return acc; + }, {} as any), + ], + }); + await collectBody(output.body, context); + return contents; +}; + export const deserializeHttpEnumPayloadRequest = async ( output: __HttpRequest, context: __SerdeContext @@ -2065,7 +2105,7 @@ export const deserializeMalformedContentTypeWithoutBodyEmptyInputRequest = async } } const contents: any = map({ - [_h]: [, output.headers[_h]], + [_he]: [, output.headers[_he]], }); await collectBody(output.body, context); return contents; @@ -4499,6 +4539,49 @@ export const serializeHttpChecksumRequiredResponse = async ( }); }; +export const serializeHttpEmptyPrefixHeadersResponse = async ( + input: HttpEmptyPrefixHeadersServerOutput, + ctx: ServerSerdeContext +): Promise<__HttpResponse> => { + const context: __SerdeContext = { + ...ctx, + endpoint: () => + Promise.resolve({ + protocol: "", + hostname: "", + path: "", + }), + }; + const statusCode = 200; + let headers: any = map({}, isSerializableHeaderValue, { + ...(input.prefixHeaders !== undefined && + Object.keys(input.prefixHeaders).reduce((acc: any, suffix: string) => { + acc[`${suffix.toLowerCase()}`] = input.prefixHeaders![suffix]; + return acc; + }, {})), + "content-type": "application/json", + [_h]: input[_sH]!, + }); + let body: any; + body = "{}"; + if ( + body && + Object.keys(headers) + .map((str) => str.toLowerCase()) + .indexOf("content-length") === -1 + ) { + const length = calculateBodyLength(body); + if (length !== undefined) { + headers = { ...headers, "content-length": String(length) }; + } + } + return new __HttpResponse({ + headers, + body, + statusCode, + }); +}; + export const serializeHttpEnumPayloadResponse = async ( input: HttpEnumPayloadServerOutput, ctx: ServerSerdeContext @@ -4719,13 +4802,13 @@ export const serializeHttpPrefixHeadersResponse = async ( }; const statusCode = 200; let headers: any = map({}, isSerializableHeaderValue, { - "content-type": "application/json", - [_xf]: input[_f]!, ...(input.fooMap !== undefined && Object.keys(input.fooMap).reduce((acc: any, suffix: string) => { acc[`x-foo-${suffix.toLowerCase()}`] = input.fooMap![suffix]; return acc; }, {})), + "content-type": "application/json", + [_xf]: input[_f]!, }); let body: any; body = "{}"; @@ -4762,12 +4845,12 @@ export const serializeHttpPrefixHeadersInResponseResponse = async ( }; const statusCode = 200; let headers: any = map({}, isSerializableHeaderValue, { - "content-type": "application/json", ...(input.prefixHeaders !== undefined && Object.keys(input.prefixHeaders).reduce((acc: any, suffix: string) => { acc[`${suffix.toLowerCase()}`] = input.prefixHeaders![suffix]; return acc; }, {})), + "content-type": "application/json", }); let body: any; body = "{}"; @@ -9369,7 +9452,7 @@ const _f = "foo"; const _fIH = "floatInHeader"; const _fl = "floatinheader"; const _g = "greeting"; -const _h = "header"; +const _h = "hello"; const _hB = "headerByte"; const _hBL = "headerBooleanList"; const _hD = "headerDouble"; @@ -9388,6 +9471,7 @@ const _hSS = "headerStringSet"; const _hSe = "headerShort"; const _hTB = "headerTrueBool"; const _hTL = "headerTimestampList"; +const _he = "header"; const _i = "integerinheader"; const _iIH = "integerInHeader"; const _j = "json"; @@ -9397,6 +9481,7 @@ const _mDT = "memberDateTime"; const _mES = "memberEpochSeconds"; const _mHD = "memberHttpDate"; const _s = "shortinheader"; +const _sH = "specificHeader"; const _sIH = "shortInHeader"; const _t = "timestamp"; const _tDT = "targetDateTime"; diff --git a/private/aws-restjson-server/src/server/RestJsonService.ts b/private/aws-restjson-server/src/server/RestJsonService.ts index f4955d040b69..11b44241d061 100644 --- a/private/aws-restjson-server/src/server/RestJsonService.ts +++ b/private/aws-restjson-server/src/server/RestJsonService.ts @@ -90,6 +90,11 @@ import { HttpChecksumRequiredSerializer, HttpChecksumRequiredServerInput, } from "./operations/HttpChecksumRequired"; +import { + HttpEmptyPrefixHeaders, + HttpEmptyPrefixHeadersSerializer, + HttpEmptyPrefixHeadersServerInput, +} from "./operations/HttpEmptyPrefixHeaders"; import { HttpEnumPayload, HttpEnumPayloadSerializer, HttpEnumPayloadServerInput } from "./operations/HttpEnumPayload"; import { HttpPayloadTraits, @@ -452,6 +457,7 @@ export type RestJsonServiceOperations = | "GreetingWithErrors" | "HostWithPathOperation" | "HttpChecksumRequired" + | "HttpEmptyPrefixHeaders" | "HttpEnumPayload" | "HttpPayloadTraits" | "HttpPayloadTraitsWithMediaType" @@ -557,6 +563,7 @@ export interface RestJsonService { GreetingWithErrors: GreetingWithErrors; HostWithPathOperation: HostWithPathOperation; HttpChecksumRequired: HttpChecksumRequired; + HttpEmptyPrefixHeaders: HttpEmptyPrefixHeaders; HttpEnumPayload: HttpEnumPayload; HttpPayloadTraits: HttpPayloadTraits; HttpPayloadTraitsWithMediaType: HttpPayloadTraitsWithMediaType; @@ -917,6 +924,18 @@ export class RestJsonServiceHandler implements __ServiceHandler( [], { service: "RestJson", operation: "HttpChecksumRequired" } ), + new httpbinding.UriSpec<"RestJson", "HttpEmptyPrefixHeaders">( + "GET", + [{ type: "path_literal", value: "HttpEmptyPrefixHeaders" }], + [], + { service: "RestJson", operation: "HttpEmptyPrefixHeaders" } + ), new httpbinding.UriSpec<"RestJson", "HttpEnumPayload">( "POST", [{ type: "path_literal", value: "EnumPayload" }], @@ -2666,6 +2691,8 @@ export const getRestJsonServiceHandler = ( return new HostWithPathOperationSerializer(); case "HttpChecksumRequired": return new HttpChecksumRequiredSerializer(); + case "HttpEmptyPrefixHeaders": + return new HttpEmptyPrefixHeadersSerializer(); case "HttpEnumPayload": return new HttpEnumPayloadSerializer(); case "HttpPayloadTraits": diff --git a/private/aws-restjson-server/src/server/operations/GreetingWithErrors.ts b/private/aws-restjson-server/src/server/operations/GreetingWithErrors.ts index a181cb308ca1..529ae154d8f3 100644 --- a/private/aws-restjson-server/src/server/operations/GreetingWithErrors.ts +++ b/private/aws-restjson-server/src/server/operations/GreetingWithErrors.ts @@ -49,7 +49,7 @@ export namespace GreetingWithErrorsServerInput { } export interface GreetingWithErrorsServerOutput extends GreetingWithErrorsOutput {} -export type GreetingWithErrorsErrors = FooError | ComplexError | InvalidGreeting; +export type GreetingWithErrorsErrors = InvalidGreeting | ComplexError | FooError; export class GreetingWithErrorsSerializer implements __OperationSerializer, "GreetingWithErrors", GreetingWithErrorsErrors> @@ -58,20 +58,20 @@ export class GreetingWithErrorsSerializer deserialize = deserializeGreetingWithErrorsRequest; isOperationError(error: any): error is GreetingWithErrorsErrors { - const names: GreetingWithErrorsErrors["name"][] = ["FooError", "ComplexError", "InvalidGreeting"]; + const names: GreetingWithErrorsErrors["name"][] = ["InvalidGreeting", "ComplexError", "FooError"]; return names.includes(error.name); } serializeError(error: GreetingWithErrorsErrors, ctx: ServerSerdeContext): Promise<__HttpResponse> { switch (error.name) { - case "FooError": { - return serializeFooErrorError(error, ctx); + case "InvalidGreeting": { + return serializeInvalidGreetingError(error, ctx); } case "ComplexError": { return serializeComplexErrorError(error, ctx); } - case "InvalidGreeting": { - return serializeInvalidGreetingError(error, ctx); + case "FooError": { + return serializeFooErrorError(error, ctx); } default: { throw error; diff --git a/private/aws-restjson-server/src/server/operations/HttpEmptyPrefixHeaders.ts b/private/aws-restjson-server/src/server/operations/HttpEmptyPrefixHeaders.ts new file mode 100644 index 000000000000..3a97ce13343c --- /dev/null +++ b/private/aws-restjson-server/src/server/operations/HttpEmptyPrefixHeaders.ts @@ -0,0 +1,194 @@ +// smithy-typescript generated code +import { + httpbinding, + InternalFailureException as __InternalFailureException, + isFrameworkException as __isFrameworkException, + Mux as __Mux, + Operation as __Operation, + OperationInput as __OperationInput, + OperationOutput as __OperationOutput, + OperationSerializer as __OperationSerializer, + SerializationException as __SerializationException, + ServerSerdeContext as __ServerSerdeContext, + ServerSerdeContext, + ServiceException as __ServiceException, + ServiceHandler as __ServiceHandler, + SmithyFrameworkException as __SmithyFrameworkException, + ValidationCustomizer as __ValidationCustomizer, + ValidationFailure as __ValidationFailure, +} from "@aws-smithy/server-common"; +import { NodeHttpHandler, streamCollector } from "@smithy/node-http-handler"; +import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http"; +import { fromBase64, toBase64 } from "@smithy/util-base64"; +import { fromUtf8, toUtf8 } from "@smithy/util-utf8"; + +import { HttpEmptyPrefixHeadersInput, HttpEmptyPrefixHeadersOutput } from "../../models/models_0"; +import { + deserializeHttpEmptyPrefixHeadersRequest, + serializeFrameworkException, + serializeHttpEmptyPrefixHeadersResponse, +} from "../../protocols/Aws_restJson1"; +import { RestJsonService } from "../RestJsonService"; + +export type HttpEmptyPrefixHeaders = __Operation< + HttpEmptyPrefixHeadersServerInput, + HttpEmptyPrefixHeadersServerOutput, + Context +>; + +export interface HttpEmptyPrefixHeadersServerInput extends HttpEmptyPrefixHeadersInput {} +export namespace HttpEmptyPrefixHeadersServerInput { + /** + * @internal + */ + export const validate: (obj: Parameters[0]) => __ValidationFailure[] = + HttpEmptyPrefixHeadersInput.validate; +} +export interface HttpEmptyPrefixHeadersServerOutput extends HttpEmptyPrefixHeadersOutput {} + +export type HttpEmptyPrefixHeadersErrors = never; + +export class HttpEmptyPrefixHeadersSerializer + implements __OperationSerializer, "HttpEmptyPrefixHeaders", HttpEmptyPrefixHeadersErrors> +{ + serialize = serializeHttpEmptyPrefixHeadersResponse; + deserialize = deserializeHttpEmptyPrefixHeadersRequest; + + isOperationError(error: any): error is HttpEmptyPrefixHeadersErrors { + return false; + } + + serializeError(error: HttpEmptyPrefixHeadersErrors, ctx: ServerSerdeContext): Promise<__HttpResponse> { + throw error; + } +} + +export const getHttpEmptyPrefixHeadersHandler = ( + operation: __Operation, + customizer: __ValidationCustomizer<"HttpEmptyPrefixHeaders"> +): __ServiceHandler => { + const mux = new httpbinding.HttpBindingMux<"RestJson", "HttpEmptyPrefixHeaders">([ + new httpbinding.UriSpec<"RestJson", "HttpEmptyPrefixHeaders">( + "GET", + [{ type: "path_literal", value: "HttpEmptyPrefixHeaders" }], + [], + { service: "RestJson", operation: "HttpEmptyPrefixHeaders" } + ), + ]); + return new HttpEmptyPrefixHeadersHandler( + operation, + mux, + new HttpEmptyPrefixHeadersSerializer(), + serializeFrameworkException, + customizer + ); +}; + +const serdeContextBase = { + base64Encoder: toBase64, + base64Decoder: fromBase64, + utf8Encoder: toUtf8, + utf8Decoder: fromUtf8, + streamCollector: streamCollector, + requestHandler: new NodeHttpHandler(), + disableHostPrefix: true, +}; +async function handle( + request: __HttpRequest, + context: Context, + operationName: O, + serializer: __OperationSerializer, + operation: __Operation<__OperationInput, __OperationOutput, Context>, + serializeFrameworkException: (e: __SmithyFrameworkException, ctx: __ServerSerdeContext) => Promise<__HttpResponse>, + validationFn: (input: __OperationInput) => __ValidationFailure[], + validationCustomizer: __ValidationCustomizer +): Promise<__HttpResponse> { + let input; + try { + input = await serializer.deserialize(request, { + endpoint: () => Promise.resolve(request), + ...serdeContextBase, + }); + } catch (error: unknown) { + if (__isFrameworkException(error)) { + return serializeFrameworkException(error, serdeContextBase); + } + return serializeFrameworkException(new __SerializationException(), serdeContextBase); + } + try { + const validationFailures = validationFn(input); + if (validationFailures && validationFailures.length > 0) { + const validationException = validationCustomizer({ operation: operationName }, validationFailures); + if (validationException) { + return serializer.serializeError(validationException, serdeContextBase); + } + } + const output = await operation(input, context); + return serializer.serialize(output, serdeContextBase); + } catch (error: unknown) { + if (serializer.isOperationError(error)) { + return serializer.serializeError(error, serdeContextBase); + } + console.log("Received an unexpected error", error); + return serializeFrameworkException(new __InternalFailureException(), serdeContextBase); + } +} +export class HttpEmptyPrefixHeadersHandler implements __ServiceHandler { + private readonly operation: __Operation< + HttpEmptyPrefixHeadersServerInput, + HttpEmptyPrefixHeadersServerOutput, + Context + >; + private readonly mux: __Mux<"RestJson", "HttpEmptyPrefixHeaders">; + private readonly serializer: __OperationSerializer< + RestJsonService, + "HttpEmptyPrefixHeaders", + HttpEmptyPrefixHeadersErrors + >; + private readonly serializeFrameworkException: ( + e: __SmithyFrameworkException, + ctx: __ServerSerdeContext + ) => Promise<__HttpResponse>; + private readonly validationCustomizer: __ValidationCustomizer<"HttpEmptyPrefixHeaders">; + /** + * Construct a HttpEmptyPrefixHeaders handler. + * @param operation The {@link __Operation} implementation that supplies the business logic for HttpEmptyPrefixHeaders + * @param mux The {@link __Mux} that verifies which service and operation are being invoked by a given {@link __HttpRequest} + * @param serializer An {@link __OperationSerializer} for HttpEmptyPrefixHeaders that + * handles deserialization of requests and serialization of responses + * @param serializeFrameworkException A function that can serialize {@link __SmithyFrameworkException}s + * @param validationCustomizer A {@link __ValidationCustomizer} for turning validation failures into {@link __SmithyFrameworkException}s + */ + constructor( + operation: __Operation, + mux: __Mux<"RestJson", "HttpEmptyPrefixHeaders">, + serializer: __OperationSerializer, "HttpEmptyPrefixHeaders", HttpEmptyPrefixHeadersErrors>, + serializeFrameworkException: (e: __SmithyFrameworkException, ctx: __ServerSerdeContext) => Promise<__HttpResponse>, + validationCustomizer: __ValidationCustomizer<"HttpEmptyPrefixHeaders"> + ) { + this.operation = operation; + this.mux = mux; + this.serializer = serializer; + this.serializeFrameworkException = serializeFrameworkException; + this.validationCustomizer = validationCustomizer; + } + async handle(request: __HttpRequest, context: Context): Promise<__HttpResponse> { + const target = this.mux.match(request); + if (target === undefined) { + console.log( + "Received a request that did not match aws.protocoltests.restjson#RestJson.HttpEmptyPrefixHeaders. This indicates a misconfiguration." + ); + return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase); + } + return handle( + request, + context, + "HttpEmptyPrefixHeaders", + this.serializer, + this.operation, + this.serializeFrameworkException, + HttpEmptyPrefixHeadersServerInput.validate, + this.validationCustomizer + ); + } +} diff --git a/private/aws-restjson-server/src/server/operations/index.ts b/private/aws-restjson-server/src/server/operations/index.ts index 149769bc0e82..83d314c7260b 100644 --- a/private/aws-restjson-server/src/server/operations/index.ts +++ b/private/aws-restjson-server/src/server/operations/index.ts @@ -14,6 +14,7 @@ export * from "./FractionalSeconds"; export * from "./GreetingWithErrors"; export * from "./HostWithPathOperation"; export * from "./HttpChecksumRequired"; +export * from "./HttpEmptyPrefixHeaders"; export * from "./HttpEnumPayload"; export * from "./HttpPayloadTraits"; export * from "./HttpPayloadTraitsWithMediaType"; diff --git a/private/aws-restjson-server/test/functional/restjson1.spec.ts b/private/aws-restjson-server/test/functional/restjson1.spec.ts index 34e89ca2b704..d65229b4f8c9 100644 --- a/private/aws-restjson-server/test/functional/restjson1.spec.ts +++ b/private/aws-restjson-server/test/functional/restjson1.spec.ts @@ -48,6 +48,11 @@ import { GreetingWithErrorsServerOutput, } from "../../src/server/operations/GreetingWithErrors"; import { HttpChecksumRequired } from "../../src/server/operations/HttpChecksumRequired"; +import { + HttpEmptyPrefixHeaders, + HttpEmptyPrefixHeadersSerializer, + HttpEmptyPrefixHeadersServerOutput, +} from "../../src/server/operations/HttpEmptyPrefixHeaders"; import { HttpEnumPayload, HttpEnumPayloadSerializer, @@ -2211,21 +2216,17 @@ it("RestJsonGreetingWithErrors:ServerResponse", async () => { }); /** - * Serializes a complex error with no message member + * Parses simple JSON errors */ -it("RestJsonComplexErrorWithNoMessage:ServerErrorResponse", async () => { +it("RestJsonInvalidGreetingError:ServerErrorResponse", async () => { class TestService implements Partial> { GreetingWithErrors(input: any, ctx: {}): Promise { const response = { - Header: "Header", - TopLevel: "Top level", - Nested: { - Foo: "bar", - } as any, + Message: "Hi", } as any; - const error: ComplexError = { + const error: InvalidGreeting = { ...response, - name: "ComplexError", + name: "InvalidGreeting", $fault: "client", $metadata: {}, }; @@ -2264,28 +2265,33 @@ it("RestJsonComplexErrorWithNoMessage:ServerErrorResponse", async () => { ); const r = await handler.handle(request, {}); - expect(r.statusCode).toBe(403); + expect(r.statusCode).toBe(400); expect(r.headers["content-type"]).toBe("application/json"); - expect(r.headers["x-amzn-errortype"]).toBe("ComplexError"); - expect(r.headers["x-header"]).toBe("Header"); + expect(r.headers["x-amzn-errortype"]).toBe("InvalidGreeting"); expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"TopLevel\": \"Top level\", - \"Nested\": { - \"Fooooo\": \"bar\" - } + \"Message\": \"Hi\" }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); -it("RestJsonEmptyComplexErrorWithNoMessage:ServerErrorResponse", async () => { +/** + * Serializes a complex error with no message member + */ +it("RestJsonComplexErrorWithNoMessage:ServerErrorResponse", async () => { class TestService implements Partial> { GreetingWithErrors(input: any, ctx: {}): Promise { - const response = {} as any; + const response = { + Header: "Header", + TopLevel: "Top level", + Nested: { + Foo: "bar", + } as any, + } as any; const error: ComplexError = { ...response, name: "ComplexError", @@ -2331,26 +2337,27 @@ it("RestJsonEmptyComplexErrorWithNoMessage:ServerErrorResponse", async () => { expect(r.headers["content-type"]).toBe("application/json"); expect(r.headers["x-amzn-errortype"]).toBe("ComplexError"); + expect(r.headers["x-header"]).toBe("Header"); expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; - const bodyString = `{}`; + const bodyString = `{ + \"TopLevel\": \"Top level\", + \"Nested\": { + \"Fooooo\": \"bar\" + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); -/** - * Parses simple JSON errors - */ -it("RestJsonInvalidGreetingError:ServerErrorResponse", async () => { +it("RestJsonEmptyComplexErrorWithNoMessage:ServerErrorResponse", async () => { class TestService implements Partial> { GreetingWithErrors(input: any, ctx: {}): Promise { - const response = { - Message: "Hi", - } as any; - const error: InvalidGreeting = { + const response = {} as any; + const error: ComplexError = { ...response, - name: "InvalidGreeting", + name: "ComplexError", $fault: "client", $metadata: {}, }; @@ -2389,16 +2396,14 @@ it("RestJsonInvalidGreetingError:ServerErrorResponse", async () => { ); const r = await handler.handle(request, {}); - expect(r.statusCode).toBe(400); + expect(r.statusCode).toBe(403); expect(r.headers["content-type"]).toBe("application/json"); - expect(r.headers["x-amzn-errortype"]).toBe("InvalidGreeting"); + expect(r.headers["x-amzn-errortype"]).toBe("ComplexError"); expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; - const bodyString = `{ - \"Message\": \"Hi\" - }`; + const bodyString = `{}`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -2451,6 +2456,112 @@ it("RestJsonHttpChecksumRequired:ServerRequest", async () => { }); }); +/** + * Deserializes all request headers with the same for prefix and specific + */ +it("RestJsonHttpEmptyPrefixHeadersRequestServer:ServerRequest", async () => { + const testFunction = vi.fn(); + testFunction.mockReturnValue(Promise.resolve({})); + const testService: Partial> = { + HttpEmptyPrefixHeaders: testFunction as HttpEmptyPrefixHeaders<{}>, + }; + const handler = getRestJsonServiceHandler( + testService as RestJsonService<{}>, + (ctx: {}, failures: __ValidationFailure[]) => { + if (failures) { + throw failures; + } + return undefined; + } + ); + const request = new HttpRequest({ + method: "GET", + hostname: "foo.example.com", + path: "/HttpEmptyPrefixHeaders", + query: {}, + headers: { + "x-foo": "Foo", + hello: "There", + }, + body: Readable.from([""]), + }); + await handler.handle(request, {}); + + expect(testFunction.mock.calls.length).toBe(1); + const r: any = testFunction.mock.calls[0][0]; + + const paramsToValidate: any = [ + { + prefixHeaders: { + "x-foo": "Foo", + hello: "There", + }, + specificHeader: "There", + }, + ][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); + }); +}); + +/** + * Serializes all response headers, using specific when present + */ +it("RestJsonHttpEmptyPrefixHeadersResponseServer:ServerResponse", async () => { + class TestService implements Partial> { + HttpEmptyPrefixHeaders(input: any, ctx: {}): Promise { + const response = { + prefixHeaders: { + "x-foo": "Foo", + hello: "Hello", + } as any, + specificHeader: "There", + } as any; + return Promise.resolve({ ...response, $metadata: {} }); + } + } + const service: any = new TestService(); + const testMux = new httpbinding.HttpBindingMux<"RestJson", keyof RestJsonService<{}>>([ + new httpbinding.UriSpec<"RestJson", "HttpEmptyPrefixHeaders">("POST", [], [], { + service: "RestJson", + operation: "HttpEmptyPrefixHeaders", + }), + ]); + class TestSerializer extends HttpEmptyPrefixHeadersSerializer { + deserialize = (output: any, context: any): Promise => { + return Promise.resolve({}); + }; + } + const request = new HttpRequest({ method: "POST", hostname: "example.com" }); + const serFn: ( + op: RestJsonServiceOperations + ) => __OperationSerializer, RestJsonServiceOperations, __ServiceException> = (op) => { + return new TestSerializer(); + }; + const handler = new RestJsonServiceHandler( + service, + testMux, + serFn, + serializeFrameworkException, + (ctx: {}, f: __ValidationFailure[]) => { + if (f) { + throw f; + } + return undefined; + } + ); + const r = await handler.handle(request, {}); + + expect(r.statusCode).toBe(200); + + expect(r.headers["hello"]).toBe("There"); + expect(r.headers["x-foo"]).toBe("Foo"); +}); + it("RestJsonEnumPayloadRequest:ServerRequest", async () => { const testFunction = vi.fn(); testFunction.mockReturnValue(Promise.resolve({})); @@ -3109,9 +3220,9 @@ it("RestJsonHttpPayloadWithStructure:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"greeting\": \"hello\", - \"name\": \"Phreddy\" - }`; + \"greeting\": \"hello\", + \"name\": \"Phreddy\" + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -3250,8 +3361,8 @@ it("RestJsonHttpPayloadWithUnion:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"greeting\": \"hello\" - }`; + \"greeting\": \"hello\" + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -5345,8 +5456,8 @@ it("RestJsonJsonBlobs:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"data\": \"dmFsdWU=\" - }`; + \"data\": \"dmFsdWU=\" + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -5467,22 +5578,22 @@ it("RestJsonJsonEnums:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"fooEnum1\": \"Foo\", - \"fooEnum2\": \"0\", - \"fooEnum3\": \"1\", - \"fooEnumList\": [ - \"Foo\", - \"0\" - ], - \"fooEnumSet\": [ - \"Foo\", - \"0\" - ], - \"fooEnumMap\": { - \"hi\": \"Foo\", - \"zero\": \"0\" - } - }`; + \"fooEnum1\": \"Foo\", + \"fooEnum2\": \"0\", + \"fooEnum3\": \"1\", + \"fooEnumList\": [ + \"Foo\", + \"0\" + ], + \"fooEnumSet\": [ + \"Foo\", + \"0\" + ], + \"fooEnumMap\": { + \"hi\": \"Foo\", + \"zero\": \"0\" + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -5603,23 +5714,23 @@ it("RestJsonJsonIntEnums:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"integerEnum1\": 1, - \"integerEnum2\": 2, - \"integerEnum3\": 3, - \"integerEnumList\": [ - 1, - 2, - 3 - ], - \"integerEnumSet\": [ - 1, - 2 - ], - \"integerEnumMap\": { - \"abc\": 1, - \"def\": 2 - } - }`; + \"integerEnum1\": 1, + \"integerEnum2\": 2, + \"integerEnum3\": 3, + \"integerEnumList\": [ + 1, + 2, + 3 + ], + \"integerEnumSet\": [ + 1, + 2 + ], + \"integerEnumMap\": { + \"abc\": 1, + \"def\": 2 + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -5811,55 +5922,55 @@ it("RestJsonLists:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"stringList\": [ - \"foo\", - \"bar\" - ], - \"stringSet\": [ - \"foo\", - \"bar\" - ], - \"integerList\": [ - 1, - 2 - ], - \"booleanList\": [ - true, - false - ], - \"timestampList\": [ - 1398796238, - 1398796238 - ], - \"enumList\": [ - \"Foo\", - \"0\" - ], - \"intEnumList\": [ - 1, - 2 - ], - \"nestedStringList\": [ - [ - \"foo\", - \"bar\" - ], - [ - \"baz\", - \"qux\" - ] - ], - \"myStructureList\": [ - { - \"value\": \"1\", - \"other\": \"2\" - }, - { - \"value\": \"3\", - \"other\": \"4\" - } - ] - }`; + \"stringList\": [ + \"foo\", + \"bar\" + ], + \"stringSet\": [ + \"foo\", + \"bar\" + ], + \"integerList\": [ + 1, + 2 + ], + \"booleanList\": [ + true, + false + ], + \"timestampList\": [ + 1398796238, + 1398796238 + ], + \"enumList\": [ + \"Foo\", + \"0\" + ], + \"intEnumList\": [ + 1, + 2 + ], + \"nestedStringList\": [ + [ + \"foo\", + \"bar\" + ], + [ + \"baz\", + \"qux\" + ] + ], + \"myStructureList\": [ + { + \"value\": \"1\", + \"other\": \"2\" + }, + { + \"value\": \"3\", + \"other\": \"4\" + } + ] + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -5915,8 +6026,8 @@ it("RestJsonListsEmpty:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"stringList\": [] - }`; + \"stringList\": [] + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -6139,15 +6250,15 @@ it("RestJsonJsonMaps:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"denseStructMap\": { - \"foo\": { - \"hi\": \"there\" - }, - \"baz\": { - \"hi\": \"bye\" - } - } - }`; + \"denseStructMap\": { + \"foo\": { + \"hi\": \"there\" + }, + \"baz\": { + \"hi\": \"bye\" + } + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -6208,13 +6319,13 @@ it("RestJsonDeserializesZeroValuesInMaps:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"denseNumberMap\": { - \"x\": 0 - }, - \"denseBooleanMap\": { - \"x\": false - } - }`; + \"denseNumberMap\": { + \"x\": 0 + }, + \"denseBooleanMap\": { + \"x\": false + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -6273,11 +6384,11 @@ it("RestJsonDeserializesDenseSetMap:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"denseSetMap\": { - \"x\": [], - \"y\": [\"a\", \"b\"] - } - }`; + \"denseSetMap\": { + \"x\": [], + \"y\": [\"a\", \"b\"] + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -6662,8 +6773,8 @@ it("RestJsonJsonTimestamps:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"normal\": 1398796238 - }`; + \"normal\": 1398796238 + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -6719,8 +6830,8 @@ it("RestJsonJsonTimestampsWithDateTimeFormat:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"dateTime\": \"2014-04-29T18:30:38Z\" - }`; + \"dateTime\": \"2014-04-29T18:30:38Z\" + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -6776,8 +6887,8 @@ it("RestJsonJsonTimestampsWithDateTimeOnTargetFormat:ServerResponse", async () = expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"dateTimeOnTarget\": \"2014-04-29T18:30:38Z\" - }`; + \"dateTimeOnTarget\": \"2014-04-29T18:30:38Z\" + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -6833,8 +6944,8 @@ it("RestJsonJsonTimestampsWithEpochSecondsFormat:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"epochSeconds\": 1398796238 - }`; + \"epochSeconds\": 1398796238 + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -6890,8 +7001,8 @@ it("RestJsonJsonTimestampsWithEpochSecondsOnTargetFormat:ServerResponse", async expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"epochSecondsOnTarget\": 1398796238 - }`; + \"epochSecondsOnTarget\": 1398796238 + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -6947,8 +7058,8 @@ it("RestJsonJsonTimestampsWithHttpDateFormat:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"httpDate\": \"Tue, 29 Apr 2014 18:30:38 GMT\" - }`; + \"httpDate\": \"Tue, 29 Apr 2014 18:30:38 GMT\" + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -7004,8 +7115,8 @@ it("RestJsonJsonTimestampsWithHttpDateOnTargetFormat:ServerResponse", async () = expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"httpDateOnTarget\": \"Tue, 29 Apr 2014 18:30:38 GMT\" - }`; + \"httpDateOnTarget\": \"Tue, 29 Apr 2014 18:30:38 GMT\" + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -7566,10 +7677,10 @@ it("RestJsonDeserializeStringUnionValue:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"contents\": { - \"stringValue\": \"foo\" - } - }`; + \"contents\": { + \"stringValue\": \"foo\" + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -7627,10 +7738,10 @@ it("RestJsonDeserializeBooleanUnionValue:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"contents\": { - \"booleanValue\": true - } - }`; + \"contents\": { + \"booleanValue\": true + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -7688,10 +7799,10 @@ it("RestJsonDeserializeNumberUnionValue:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"contents\": { - \"numberValue\": 1 - } - }`; + \"contents\": { + \"numberValue\": 1 + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -7749,10 +7860,10 @@ it("RestJsonDeserializeBlobUnionValue:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"contents\": { - \"blobValue\": \"Zm9v\" - } - }`; + \"contents\": { + \"blobValue\": \"Zm9v\" + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -7810,10 +7921,10 @@ it("RestJsonDeserializeTimestampUnionValue:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"contents\": { - \"timestampValue\": 1398796238 - } - }`; + \"contents\": { + \"timestampValue\": 1398796238 + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -7871,10 +7982,10 @@ it("RestJsonDeserializeEnumUnionValue:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"contents\": { - \"enumValue\": \"Foo\" - } - }`; + \"contents\": { + \"enumValue\": \"Foo\" + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -7932,10 +8043,10 @@ it("RestJsonDeserializeListUnionValue:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"contents\": { - \"listValue\": [\"foo\", \"bar\"] - } - }`; + \"contents\": { + \"listValue\": [\"foo\", \"bar\"] + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -7996,13 +8107,13 @@ it("RestJsonDeserializeMapUnionValue:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"contents\": { - \"mapValue\": { - \"foo\": \"bar\", - \"spam\": \"eggs\" - } - } - }`; + \"contents\": { + \"mapValue\": { + \"foo\": \"bar\", + \"spam\": \"eggs\" + } + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -8062,12 +8173,12 @@ it("RestJsonDeserializeStructureUnionValue:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"contents\": { - \"structureValue\": { - \"hi\": \"hello\" - } - } - }`; + \"contents\": { + \"structureValue\": { + \"hi\": \"hello\" + } + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -27794,34 +27905,34 @@ it.skip("RestJsonServerPopulatesDefaultsInResponseWhenMissingInParams:ServerResp expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"defaultString\": \"hi\", - \"defaultBoolean\": true, - \"defaultList\": [], - \"defaultDocumentMap\": {}, - \"defaultDocumentString\": \"hi\", - \"defaultDocumentBoolean\": true, - \"defaultDocumentList\": [], - \"defaultTimestamp\": 0, - \"defaultBlob\": \"YWJj\", - \"defaultByte\": 1, - \"defaultShort\": 1, - \"defaultInteger\": 10, - \"defaultLong\": 100, - \"defaultFloat\": 1.0, - \"defaultDouble\": 1.0, - \"defaultMap\": {}, - \"defaultEnum\": \"FOO\", - \"defaultIntEnum\": 1, - \"emptyString\": \"\", - \"falseBoolean\": false, - \"emptyBlob\": \"\", - \"zeroByte\": 0, - \"zeroShort\": 0, - \"zeroInteger\": 0, - \"zeroLong\": 0, - \"zeroFloat\": 0.0, - \"zeroDouble\": 0.0 - }`; + \"defaultString\": \"hi\", + \"defaultBoolean\": true, + \"defaultList\": [], + \"defaultDocumentMap\": {}, + \"defaultDocumentString\": \"hi\", + \"defaultDocumentBoolean\": true, + \"defaultDocumentList\": [], + \"defaultTimestamp\": 0, + \"defaultBlob\": \"YWJj\", + \"defaultByte\": 1, + \"defaultShort\": 1, + \"defaultInteger\": 10, + \"defaultLong\": 100, + \"defaultFloat\": 1.0, + \"defaultDouble\": 1.0, + \"defaultMap\": {}, + \"defaultEnum\": \"FOO\", + \"defaultIntEnum\": 1, + \"emptyString\": \"\", + \"falseBoolean\": false, + \"emptyBlob\": \"\", + \"zeroByte\": 0, + \"zeroShort\": 0, + \"zeroInteger\": 0, + \"zeroLong\": 0, + \"zeroFloat\": 0.0, + \"zeroDouble\": 0.0 + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -27995,47 +28106,47 @@ it.skip("RestJsonServerPopulatesNestedDefaultValuesWhenMissingInInResponseParams expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"dialog\": { - \"language\": \"en\", - \"greeting\": \"hi\" - }, - \"dialogList\": [ - { - \"greeting\": \"hi\" - }, - { - \"greeting\": \"hi\", - \"farewell\": { - \"phrase\": \"bye\" - } - }, - { - \"language\": \"it\", - \"greeting\": \"ciao\", - \"farewell\": { - \"phrase\": \"arrivederci\" - } - } - ], - \"dialogMap\": { - \"emptyDialog\": { - \"greeting\": \"hi\" - }, - \"partialEmptyDialog\": { - \"language\": \"en\", - \"greeting\": \"hi\", - \"farewell\": { - \"phrase\": \"bye\" - } - }, - \"nonEmptyDialog\": { - \"greeting\": \"konnichiwa\", - \"farewell\": { - \"phrase\": \"sayonara\" - } - } - } - }`; + \"dialog\": { + \"language\": \"en\", + \"greeting\": \"hi\" + }, + \"dialogList\": [ + { + \"greeting\": \"hi\" + }, + { + \"greeting\": \"hi\", + \"farewell\": { + \"phrase\": \"bye\" + } + }, + { + \"language\": \"it\", + \"greeting\": \"ciao\", + \"farewell\": { + \"phrase\": \"arrivederci\" + } + } + ], + \"dialogMap\": { + \"emptyDialog\": { + \"greeting\": \"hi\" + }, + \"partialEmptyDialog\": { + \"language\": \"en\", + \"greeting\": \"hi\", + \"farewell\": { + \"phrase\": \"bye\" + } + }, + \"nonEmptyDialog\": { + \"greeting\": \"konnichiwa\", + \"farewell\": { + \"phrase\": \"sayonara\" + } + } + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -28142,10 +28253,10 @@ it("RestJsonOutputUnionWithUnitMember:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"action\": { - \"quit\": {} - } - }`; + \"action\": { + \"quit\": {} + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -28350,10 +28461,10 @@ it("PostUnionWithJsonNameResponse1:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"value\": { - \"FOO\": \"hi\" - } - }`; + \"value\": { + \"FOO\": \"hi\" + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -28411,10 +28522,10 @@ it("PostUnionWithJsonNameResponse2:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"value\": { - \"_baz\": \"hi\" - } - }`; + \"value\": { + \"_baz\": \"hi\" + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -28472,10 +28583,10 @@ it("PostUnionWithJsonNameResponse3:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"value\": { - \"bar\": \"hi\" - } - }`; + \"value\": { + \"bar\": \"hi\" + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -28802,19 +28913,19 @@ it("RestJsonRecursiveShapes:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"nested\": { - \"foo\": \"Foo1\", - \"nested\": { - \"bar\": \"Bar1\", - \"recursiveMember\": { - \"foo\": \"Foo2\", - \"nested\": { - \"bar\": \"Bar2\" - } - } - } - } - }`; + \"nested\": { + \"foo\": \"Foo1\", + \"nested\": { + \"bar\": \"Bar1\", + \"recursiveMember\": { + \"foo\": \"Foo2\", + \"nested\": { + \"bar\": \"Bar2\" + } + } + } + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -29226,16 +29337,16 @@ it("RestJsonSimpleScalarProperties:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"stringValue\": \"string\", - \"trueBooleanValue\": true, - \"falseBooleanValue\": false, - \"byteValue\": 1, - \"shortValue\": 2, - \"integerValue\": 3, - \"longValue\": 4, - \"floatValue\": 5.5, - \"DoubleDribble\": 6.5 - }`; + \"stringValue\": \"string\", + \"trueBooleanValue\": true, + \"falseBooleanValue\": false, + \"byteValue\": 1, + \"shortValue\": 2, + \"integerValue\": 3, + \"longValue\": 4, + \"floatValue\": 5.5, + \"DoubleDribble\": 6.5 + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -29347,9 +29458,9 @@ it("RestJsonSupportsNaNFloatInputs:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"floatValue\": \"NaN\", - \"DoubleDribble\": \"NaN\" - }`; + \"floatValue\": \"NaN\", + \"DoubleDribble\": \"NaN\" + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -29406,9 +29517,9 @@ it("RestJsonSupportsInfinityFloatInputs:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"floatValue\": \"Infinity\", - \"DoubleDribble\": \"Infinity\" - }`; + \"floatValue\": \"Infinity\", + \"DoubleDribble\": \"Infinity\" + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -29465,9 +29576,9 @@ it("RestJsonSupportsNegativeInfinityFloatInputs:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"floatValue\": \"-Infinity\", - \"DoubleDribble\": \"-Infinity\" - }`; + \"floatValue\": \"-Infinity\", + \"DoubleDribble\": \"-Infinity\" + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -29574,15 +29685,15 @@ it("RestJsonSparseListsSerializeNull:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"sparseStringList\": [ - null, - \"hi\" - ], - \"sparseShortList\": [ - null, - 2 - ] - }`; + \"sparseStringList\": [ + null, + \"hi\" + ], + \"sparseShortList\": [ + null, + 2 + ] + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -29918,15 +30029,15 @@ it("RestJsonSparseJsonMaps:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"sparseStructMap\": { - \"foo\": { - \"hi\": \"there\" - }, - \"baz\": { - \"hi\": \"bye\" - } - } - }`; + \"sparseStructMap\": { + \"foo\": { + \"hi\": \"there\" + }, + \"baz\": { + \"hi\": \"bye\" + } + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -29993,19 +30104,19 @@ it("RestJsonDeserializesSparseNullMapValues:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"sparseBooleanMap\": { - \"x\": null - }, - \"sparseNumberMap\": { - \"x\": null - }, - \"sparseStringMap\": { - \"x\": null - }, - \"sparseStructMap\": { - \"x\": null - } - }`; + \"sparseBooleanMap\": { + \"x\": null + }, + \"sparseNumberMap\": { + \"x\": null + }, + \"sparseStringMap\": { + \"x\": null + }, + \"sparseStructMap\": { + \"x\": null + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -30066,13 +30177,13 @@ it("RestJsonDeserializesZeroValuesInSparseMaps:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"sparseNumberMap\": { - \"x\": 0 - }, - \"sparseBooleanMap\": { - \"x\": false - } - }`; + \"sparseNumberMap\": { + \"x\": 0 + }, + \"sparseBooleanMap\": { + \"x\": false + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -30131,11 +30242,11 @@ it("RestJsonDeserializesSparseSetMap:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"sparseSetMap\": { - \"x\": [], - \"y\": [\"a\", \"b\"] - } - }`; + \"sparseSetMap\": { + \"x\": [], + \"y\": [\"a\", \"b\"] + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); @@ -30195,12 +30306,12 @@ it("RestJsonDeserializesSparseSetMapAndRetainsNull:ServerResponse", async () => expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; const bodyString = `{ - \"sparseSetMap\": { - \"x\": [], - \"y\": [\"a\", \"b\"], - \"z\": null - } - }`; + \"sparseSetMap\": { + \"x\": [], + \"y\": [\"a\", \"b\"], + \"z\": null + } + }`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); diff --git a/scripts/generate-clients/config.js b/scripts/generate-clients/config.js index 80ce32c17e2b..08f11655b6e1 100644 --- a/scripts/generate-clients/config.js +++ b/scripts/generate-clients/config.js @@ -1,7 +1,7 @@ // Update this commit when taking up new changes from smithy-typescript. module.exports = { // Use full commit hash as we explicitly fetch it. - SMITHY_TS_COMMIT: "3db70fad42c143dd53f535089166531836b440e6", + SMITHY_TS_COMMIT: "57e0a48e1d5b66d0bbc6dc42eae5e1200347d415", }; if (module.exports.SMITHY_TS_COMMIT.length < 40) {