Skip to content

Commit 56c18fc

Browse files
gosarAllanZhengYP
authored andcommitted
chore(codegen): update to Smithy 1.19.x (#3507)
Enables a protocol test that was fixed since last Smithy version.
1 parent 43b428d commit 56c18fc

File tree

6 files changed

+47
-118
lines changed

6 files changed

+47
-118
lines changed

codegen/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ allprojects {
3131
version = "0.10.0"
3232
}
3333

34-
extra["smithyVersion"] = "[1.17.0,1.18.0["
34+
extra["smithyVersion"] = "[1.19.0,1.20.0["
3535

3636
// The root project doesn't produce a JAR.
3737
tasks["jar"].enabled = false

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,6 @@ private static boolean filterProtocolTests(
314314
return true;
315315
}
316316

317-
// TODO remove after 1.17.1 or later
318-
// https://github.com/awslabs/smithy/pull/1084
319-
if (testCase.getId().equals("RestJsonOutputUnionWithUnitMember")) {
320-
return true;
321-
}
322-
323317
return false;
324318
}
325319

private/aws-protocoltests-restjson/src/commands/StreamingTraitsRequireLengthCommand.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,24 @@ import {
1111
SerdeContext as __SerdeContext,
1212
} from "@aws-sdk/types";
1313

14-
import { StreamingTraitsRequireLengthInputOutput } from "../models/models_0";
14+
import { StreamingTraitsRequireLengthInput } from "../models/models_0";
1515
import {
1616
deserializeAws_restJson1StreamingTraitsRequireLengthCommand,
1717
serializeAws_restJson1StreamingTraitsRequireLengthCommand,
1818
} from "../protocols/Aws_restJson1";
1919
import { RestJsonProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RestJsonProtocolClient";
2020

21-
type StreamingTraitsRequireLengthCommandInputType = Omit<StreamingTraitsRequireLengthInputOutput, "blob"> & {
21+
type StreamingTraitsRequireLengthCommandInputType = Omit<StreamingTraitsRequireLengthInput, "blob"> & {
2222
/**
23-
* For *`StreamingTraitsRequireLengthInputOutput["blob"]`*, see {@link StreamingTraitsRequireLengthInputOutput.blob}.
23+
* For *`StreamingTraitsRequireLengthInput["blob"]`*, see {@link StreamingTraitsRequireLengthInput.blob}.
2424
*/
25-
blob?: StreamingTraitsRequireLengthInputOutput["blob"] | string | Uint8Array | Buffer;
25+
blob?: StreamingTraitsRequireLengthInput["blob"] | string | Uint8Array | Buffer;
2626
};
2727
/**
28-
* This interface extends from `StreamingTraitsRequireLengthInputOutput` interface. There are more parameters than `blob` defined in {@link StreamingTraitsRequireLengthInputOutput}
28+
* This interface extends from `StreamingTraitsRequireLengthInput` interface. There are more parameters than `blob` defined in {@link StreamingTraitsRequireLengthInput}
2929
*/
3030
export interface StreamingTraitsRequireLengthCommandInput extends StreamingTraitsRequireLengthCommandInputType {}
31-
export interface StreamingTraitsRequireLengthCommandOutput
32-
extends StreamingTraitsRequireLengthInputOutput,
33-
__MetadataBearer {}
31+
export interface StreamingTraitsRequireLengthCommandOutput extends __MetadataBearer {}
3432

3533
/**
3634
* This examples serializes a streaming blob shape with a required content
@@ -86,8 +84,8 @@ export class StreamingTraitsRequireLengthCommand extends $Command<
8684
logger,
8785
clientName,
8886
commandName,
89-
inputFilterSensitiveLog: StreamingTraitsRequireLengthInputOutput.filterSensitiveLog,
90-
outputFilterSensitiveLog: StreamingTraitsRequireLengthInputOutput.filterSensitiveLog,
87+
inputFilterSensitiveLog: StreamingTraitsRequireLengthInput.filterSensitiveLog,
88+
outputFilterSensitiveLog: (output: any) => output,
9189
};
9290
const { requestHandler } = configuration;
9391
return stack.resolve(

private/aws-protocoltests-restjson/src/models/models_0.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,7 @@ export namespace MalformedRequestBodyInput {
10941094

10951095
export interface MalformedSetInput {
10961096
set?: string[];
1097+
blobSet?: Uint8Array[];
10971098
}
10981099

10991100
export namespace MalformedSetInput {
@@ -1473,7 +1474,7 @@ export namespace PlayerAction {
14731474
}
14741475

14751476
export interface PostPlayerActionInput {
1476-
action: PlayerAction | undefined;
1477+
action?: PlayerAction;
14771478
}
14781479

14791480
export namespace PostPlayerActionInput {
@@ -1577,16 +1578,16 @@ export namespace StreamingTraitsInputOutput {
15771578
});
15781579
}
15791580

1580-
export interface StreamingTraitsRequireLengthInputOutput {
1581+
export interface StreamingTraitsRequireLengthInput {
15811582
foo?: string;
15821583
blob?: Readable | ReadableStream | Blob;
15831584
}
15841585

1585-
export namespace StreamingTraitsRequireLengthInputOutput {
1586+
export namespace StreamingTraitsRequireLengthInput {
15861587
/**
15871588
* @internal
15881589
*/
1589-
export const filterSensitiveLog = (obj: StreamingTraitsRequireLengthInputOutput): any => ({
1590+
export const filterSensitiveLog = (obj: StreamingTraitsRequireLengthInput): any => ({
15901591
...obj,
15911592
});
15921593
}

private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,6 +1939,8 @@ export const serializeAws_restJson1MalformedSetCommand = async (
19391939
const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/MalformedSet";
19401940
let body: any;
19411941
body = JSON.stringify({
1942+
...(input.blobSet !== undefined &&
1943+
input.blobSet !== null && { blobSet: serializeAws_restJson1BlobSet(input.blobSet, context) }),
19421944
...(input.set !== undefined && input.set !== null && { set: serializeAws_restJson1SimpleSet(input.set, context) }),
19431945
});
19441946
return new __HttpRequest({
@@ -6145,14 +6147,8 @@ export const deserializeAws_restJson1StreamingTraitsRequireLengthCommand = async
61456147
}
61466148
const contents: StreamingTraitsRequireLengthCommandOutput = {
61476149
$metadata: deserializeMetadata(output),
6148-
blob: undefined,
6149-
foo: undefined,
61506150
};
6151-
if (output.headers["x-foo"] !== undefined) {
6152-
contents.foo = output.headers["x-foo"];
6153-
}
6154-
const data: any = output.body;
6155-
contents.blob = data;
6151+
await collectBody(output.body, context);
61566152
return Promise.resolve(contents);
61576153
};
61586154

@@ -6547,6 +6543,17 @@ const deserializeAws_restJson1InvalidGreetingResponse = async (
65476543
return __decorateServiceException(exception, parsedOutput.body);
65486544
};
65496545

6546+
const serializeAws_restJson1BlobSet = (input: Uint8Array[], context: __SerdeContext): any => {
6547+
return input
6548+
.filter((e: any) => e != null)
6549+
.map((entry) => {
6550+
if (entry === null) {
6551+
return null as any;
6552+
}
6553+
return context.base64Encoder(entry);
6554+
});
6555+
};
6556+
65506557
const serializeAws_restJson1DenseBooleanMap = (input: { [key: string]: boolean }, context: __SerdeContext): any => {
65516558
return Object.entries(input).reduce((acc: { [key: string]: any }, [key, value]: [string, any]) => {
65526559
if (value === null) {

private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts

Lines changed: 19 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,12 @@ it("RestJsonSupportsNaNFloatQueryValues:Request", async () => {
384384
queryFloat: NaN,
385385

386386
queryDouble: NaN,
387+
388+
queryParamsMapOfStringList: {
389+
Float: ["NaN"],
390+
391+
Double: ["NaN"],
392+
} as any,
387393
} as any);
388394
try {
389395
await client.send(command);
@@ -419,6 +425,12 @@ it("RestJsonSupportsInfinityFloatQueryValues:Request", async () => {
419425
queryFloat: Infinity,
420426

421427
queryDouble: Infinity,
428+
429+
queryParamsMapOfStringList: {
430+
Float: ["Infinity"],
431+
432+
Double: ["Infinity"],
433+
} as any,
422434
} as any);
423435
try {
424436
await client.send(command);
@@ -454,6 +466,12 @@ it("RestJsonSupportsNegativeInfinityFloatQueryValues:Request", async () => {
454466
queryFloat: -Infinity,
455467

456468
queryDouble: -Infinity,
469+
470+
queryParamsMapOfStringList: {
471+
Float: ["-Infinity"],
472+
473+
Double: ["-Infinity"],
474+
} as any,
457475
} as any);
458476
try {
459477
await client.send(command);
@@ -6478,7 +6496,7 @@ it("RestJsonInputUnionWithUnitMember:Request", async () => {
64786496
/**
64796497
* Unit types in unions are serialized like normal structures in responses.
64806498
*/
6481-
it.skip("RestJsonOutputUnionWithUnitMember:Response", async () => {
6499+
it("RestJsonOutputUnionWithUnitMember:Response", async () => {
64826500
const client = new RestJsonProtocolClient({
64836501
...clientParams,
64846502
requestHandler: new ResponseDeserializationTestHandler(
@@ -7474,95 +7492,6 @@ it("RestJsonStreamingTraitsRequireLengthWithNoBlobBody:Request", async () => {
74747492
}
74757493
});
74767494

7477-
/**
7478-
* Serializes a blob in the HTTP payload with a required length
7479-
*/
7480-
it("RestJsonStreamingTraitsRequireLengthWithBlob:Response", async () => {
7481-
const client = new RestJsonProtocolClient({
7482-
...clientParams,
7483-
requestHandler: new ResponseDeserializationTestHandler(
7484-
true,
7485-
200,
7486-
{
7487-
"x-foo": "Foo",
7488-
"content-type": "application/octet-stream",
7489-
},
7490-
`blobby blob blob`
7491-
),
7492-
});
7493-
7494-
const params: any = {};
7495-
const command = new StreamingTraitsRequireLengthCommand(params);
7496-
7497-
let r: any;
7498-
try {
7499-
r = await client.send(command);
7500-
} catch (err) {
7501-
fail("Expected a valid response to be returned, got err.");
7502-
return;
7503-
}
7504-
expect(r["$metadata"].httpStatusCode).toBe(200);
7505-
const paramsToValidate: any = [
7506-
{
7507-
foo: "Foo",
7508-
7509-
blob: Uint8Array.from("blobby blob blob", (c) => c.charCodeAt(0)),
7510-
},
7511-
][0];
7512-
const comparableBlob = await client.config.streamCollector(r["blob"]);
7513-
Object.keys(paramsToValidate).forEach((param) => {
7514-
expect(r[param]).toBeDefined();
7515-
if (param === "blob") {
7516-
expect(equivalentContents(comparableBlob, paramsToValidate[param])).toBe(true);
7517-
} else {
7518-
expect(equivalentContents(r[param], paramsToValidate[param])).toBe(true);
7519-
}
7520-
});
7521-
});
7522-
7523-
/**
7524-
* Serializes an empty blob in the HTTP payload
7525-
*/
7526-
it("RestJsonStreamingTraitsRequireLengthWithNoBlobBody:Response", async () => {
7527-
const client = new RestJsonProtocolClient({
7528-
...clientParams,
7529-
requestHandler: new ResponseDeserializationTestHandler(
7530-
true,
7531-
200,
7532-
{
7533-
"x-foo": "Foo",
7534-
},
7535-
``
7536-
),
7537-
});
7538-
7539-
const params: any = {};
7540-
const command = new StreamingTraitsRequireLengthCommand(params);
7541-
7542-
let r: any;
7543-
try {
7544-
r = await client.send(command);
7545-
} catch (err) {
7546-
fail("Expected a valid response to be returned, got err.");
7547-
return;
7548-
}
7549-
expect(r["$metadata"].httpStatusCode).toBe(200);
7550-
const paramsToValidate: any = [
7551-
{
7552-
foo: "Foo",
7553-
},
7554-
][0];
7555-
const comparableBlob = await client.config.streamCollector(r["blob"]);
7556-
Object.keys(paramsToValidate).forEach((param) => {
7557-
expect(r[param]).toBeDefined();
7558-
if (param === "blob") {
7559-
expect(equivalentContents(comparableBlob, paramsToValidate[param])).toBe(true);
7560-
} else {
7561-
expect(equivalentContents(r[param], paramsToValidate[param])).toBe(true);
7562-
}
7563-
});
7564-
});
7565-
75667495
/**
75677496
* Serializes a blob in the HTTP payload with a content-type
75687497
*/

0 commit comments

Comments
 (0)