A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/aws/aws-sdk-js-v3/commit/425c0037aab4b567ccc3a765a78b0c9ddc30e8d3 below:

correct x-amz-target header in schema protocol… · aws/aws-sdk-js-v3@425c003 · GitHub

File tree Expand file treeCollapse file tree 15 files changed

+222

-29

lines changed

Filter options

Expand file treeCollapse file tree 15 files changed

+222

-29

lines changed Original file line number Diff line number Diff line change

@@ -109,6 +109,9 @@ tasks.register("generate-smithy-build") {

109 109

val useLegacyAuthServices = setOf<String>(

110 110

// e.g. "S3" - use this as exclusion list if needed.

111 111

)

112 +

val useSchemaSerde = setOf<String>(

113 +

// "CloudWatch Logs"

114 +

)

112 115

val projectionContents = Node.objectNodeBuilder()

113 116

.withMember("imports", Node.fromStrings("${models.getAbsolutePath()}${File.separator}${file.name}"))

114 117

.withMember("plugins", Node.objectNode()

@@ -121,6 +124,8 @@ tasks.register("generate-smithy-build") {

121 124

+ clientName + " Client for Node.js, Browser and React Native")

122 125

.withMember("useLegacyAuth",

123 126

useLegacyAuthServices.contains(serviceTrait.sdkId))

127 +

.withMember("generateSchemas",

128 +

useSchemaSerde.contains(serviceTrait.sdkId))

124 129

.build()))

125 130

.build()

126 131

projectionsBuilder.withMember(sdkId + "." + version.toLowerCase(), projectionContents)

Original file line number Diff line number Diff line change

@@ -37,6 +37,7 @@ public AddProtocolConfig() {

37 37

SchemaGenerationAllowlist.allow("com.amazonaws.s3#AmazonS3");

38 38

SchemaGenerationAllowlist.allow("com.amazonaws.dynamodb#DynamoDB_20120810");

39 39

SchemaGenerationAllowlist.allow("com.amazonaws.lambda#AWSGirApiService");

40 +

SchemaGenerationAllowlist.allow("com.amazonaws.cloudwatchlogs#Logs_20140328");

40 41 41 42

// protocol tests

42 43

SchemaGenerationAllowlist.allow("aws.protocoltests.json10#JsonRpc10");

@@ -69,6 +70,7 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(

69 70

return Collections.emptyMap();

70 71

}

71 72

String namespace = settings.getService().getNamespace();

73 +

String rpcTarget = settings.getService().getName();

72 74

String xmlns = settings.getService(model)

73 75

.getTrait(XmlNamespaceTrait.class)

74 76

.map(XmlNamespaceTrait::getUri)

@@ -144,7 +146,11 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(

144 146

writer.addImportSubmodule(

145 147

"AwsJson1_0Protocol", null,

146 148

AwsDependency.AWS_SDK_CORE, "/protocols");

147 -

writer.write("new AwsJson1_0Protocol({ defaultNamespace: $S })", namespace);

149 +

writer.write(

150 +

"new AwsJson1_0Protocol({ defaultNamespace: $S, serviceTarget: $S })",

151 +

namespace,

152 +

rpcTarget

153 +

);

148 154

}

149 155

);

150 156

} else if (Objects.equals(settings.getProtocol(), AwsJson1_1Trait.ID)) {

@@ -153,7 +159,11 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(

153 159

writer.addImportSubmodule(

154 160

"AwsJson1_1Protocol", null,

155 161

AwsDependency.AWS_SDK_CORE, "/protocols");

156 -

writer.write("new AwsJson1_1Protocol({ defaultNamespace: $S })", namespace);

162 +

writer.write(

163 +

"new AwsJson1_1Protocol({ defaultNamespace: $S, serviceTarget: $S })",

164 +

namespace,

165 +

rpcTarget

166 +

);

157 167

}

158 168

);

159 169

}

Original file line number Diff line number Diff line change

@@ -30,6 +30,7 @@ describe(AwsJson1_0Protocol.name, () => {

30 30

it("serializes blobs and timestamps", () => {

31 31

const protocol = new AwsJson1_0Protocol({

32 32

defaultNamespace: "namespace",

33 +

serviceTarget: "JsonRpc10",

33 34

});

34 35

protocol.setSerdeContext(serdeContext);

35 36

const codec = protocol.getPayloadCodec();

@@ -55,6 +56,7 @@ describe(AwsJson1_0Protocol.name, () => {

55 56

it("deserializes blobs and timestamps", async () => {

56 57

const protocol = new AwsJson1_0Protocol({

57 58

defaultNamespace: "namespace",

59 +

serviceTarget: "JsonRpc10",

58 60

});

59 61

protocol.setSerdeContext(serdeContext);

60 62

const codec = protocol.getPayloadCodec();

@@ -73,6 +75,7 @@ describe(AwsJson1_0Protocol.name, () => {

73 75

it("ignores JSON name and HTTP bindings", async () => {

74 76

const protocol = new AwsJson1_0Protocol({

75 77

defaultNamespace: "namespace",

78 +

serviceTarget: "JsonRpc10",

76 79

});

77 80

protocol.setSerdeContext(serdeContext);

78 81 Original file line number Diff line number Diff line change

@@ -5,9 +5,10 @@ import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol";

5 5

* @see https://smithy.io/2.0/aws/protocols/aws-json-1_1-protocol.html#differences-between-awsjson1-0-and-awsjson1-1

6 6

*/

7 7

export class AwsJson1_0Protocol extends AwsJsonRpcProtocol {

8 -

public constructor({ defaultNamespace }: { defaultNamespace: string }) {

8 +

public constructor({ defaultNamespace, serviceTarget }: { defaultNamespace: string; serviceTarget: string }) {

9 9

super({

10 10

defaultNamespace,

11 +

serviceTarget,

11 12

});

12 13

}

13 14

@@ -18,4 +19,11 @@ export class AwsJson1_0Protocol extends AwsJsonRpcProtocol {

18 19

protected getJsonRpcVersion() {

19 20

return "1.0" as const;

20 21

}

22 + 23 +

/**

24 +

* @override

25 +

*/

26 +

protected getDefaultContentType(): string {

27 +

return "application/x-amz-json-1.0";

28 +

}

21 29

}

Original file line number Diff line number Diff line change

@@ -2,22 +2,24 @@ import { HttpResponse } from "@smithy/protocol-http";

2 2

import { describe, expect, test as it } from "vitest";

3 3 4 4

import { context, deleteObjects } from "../test-schema.spec";

5 -

import { AwsJson1_0Protocol } from "./AwsJson1_0Protocol";

5 +

import { AwsJson1_1Protocol } from "./AwsJson1_1Protocol";

6 6 7 7

/**

8 8

* These tests are cursory since most coverage is provided by protocol tests.

9 9

*/

10 -

describe(AwsJson1_0Protocol, () => {

10 +

describe(AwsJson1_1Protocol, () => {

11 11

it("is 1.0", async () => {

12 -

const protocol = new AwsJson1_0Protocol({

12 +

const protocol = new AwsJson1_1Protocol({

13 13

defaultNamespace: "",

14 +

serviceTarget: "JsonRpc11",

14 15

});

15 -

expect(protocol.getShapeId()).toEqual("aws.protocols#awsJson1_0");

16 +

expect(protocol.getShapeId()).toEqual("aws.protocols#awsJson1_1");

16 17

});

17 18 18 19

it("serializes a request", async () => {

19 -

const protocol = new AwsJson1_0Protocol({

20 +

const protocol = new AwsJson1_1Protocol({

20 21

defaultNamespace: "",

22 +

serviceTarget: "JsonRpc11",

21 23

});

22 24

const httpRequest = await protocol.serializeRequest(

23 25

deleteObjects,

@@ -59,8 +61,9 @@ describe(AwsJson1_0Protocol, () => {

59 61

headers: {},

60 62

});

61 63 62 -

const protocol = new AwsJson1_0Protocol({

64 +

const protocol = new AwsJson1_1Protocol({

63 65

defaultNamespace: "",

66 +

serviceTarget: "JsonRpc11",

64 67

});

65 68 66 69

const output = await protocol.deserializeResponse(deleteObjects, context, httpResponse);

Original file line number Diff line number Diff line change

@@ -5,9 +5,10 @@ import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol";

5 5

* @see https://smithy.io/2.0/aws/protocols/aws-json-1_1-protocol.html#differences-between-awsjson1-0-and-awsjson1-1

6 6

*/

7 7

export class AwsJson1_1Protocol extends AwsJsonRpcProtocol {

8 -

public constructor({ defaultNamespace }: { defaultNamespace: string }) {

8 +

public constructor({ defaultNamespace, serviceTarget }: { defaultNamespace: string; serviceTarget: string }) {

9 9

super({

10 10

defaultNamespace,

11 +

serviceTarget,

11 12

});

12 13

}

13 14

@@ -18,4 +19,11 @@ export class AwsJson1_1Protocol extends AwsJsonRpcProtocol {

18 19

protected getJsonRpcVersion() {

19 20

return "1.1" as const;

20 21

}

22 + 23 +

/**

24 +

* @override

25 +

*/

26 +

protected getDefaultContentType(): string {

27 +

return "application/x-amz-json-1.1";

28 +

}

21 29

}

Original file line number Diff line number Diff line change

@@ -7,7 +7,7 @@ describe(AwsJsonRpcProtocol.name, () => {

7 7

it("has expected codec settings", async () => {

8 8

const protocol = new (class extends AwsJsonRpcProtocol {

9 9

constructor() {

10 -

super({ defaultNamespace: "" });

10 +

super({ defaultNamespace: "", serviceTarget: "" });

11 11

}

12 12 13 13

getShapeId(): string {

Original file line number Diff line number Diff line change

@@ -22,12 +22,14 @@ import { loadRestJsonErrorCode } from "./parseJsonBody";

22 22

export abstract class AwsJsonRpcProtocol extends RpcProtocol {

23 23

protected serializer: ShapeSerializer<string | Uint8Array>;

24 24

protected deserializer: ShapeDeserializer<string | Uint8Array>;

25 +

protected serviceTarget: string;

25 26

private codec: JsonCodec;

26 27 27 -

protected constructor({ defaultNamespace }: { defaultNamespace: string }) {

28 +

protected constructor({ defaultNamespace, serviceTarget }: { defaultNamespace: string; serviceTarget: string }) {

28 29

super({

29 30

defaultNamespace,

30 31

});

32 +

this.serviceTarget = serviceTarget;

31 33

this.codec = new JsonCodec({

32 34

timestampFormat: {

33 35

useTrait: true,

@@ -50,9 +52,7 @@ export abstract class AwsJsonRpcProtocol extends RpcProtocol {

50 52

}

51 53

Object.assign(request.headers, {

52 54

"content-type": `application/x-amz-json-${this.getJsonRpcVersion()}`,

53 -

"x-amz-target":

54 -

(this.getJsonRpcVersion() === "1.0" ? `JsonRpc10.` : `JsonProtocol.`) +

55 -

NormalizedSchema.of(operationSchema).getName(),

55 +

"x-amz-target": `${this.serviceTarget}.${NormalizedSchema.of(operationSchema).getName()}`,

56 56

});

57 57

if (deref(operationSchema.input) === "unit" || !request.body) {

58 58

request.body = "{}";

Original file line number Diff line number Diff line change

@@ -81,15 +81,15 @@ export class AwsRestJsonProtocol extends HttpBindingProtocol {

81 81

} else if (httpPayloadMember.isBlobSchema()) {

82 82

request.headers["content-type"] = "application/octet-stream";

83 83

} else {

84 -

request.headers["content-type"] = "application/json";

84 +

request.headers["content-type"] = this.getDefaultContentType();

85 85

}

86 86

} else if (!inputSchema.isUnitSchema()) {

87 87

const hasBody = Object.values(members).find((m) => {

88 88

const { httpQuery, httpQueryParams, httpHeader, httpLabel, httpPrefixHeaders } = m.getMergedTraits();

89 89

return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && httpPrefixHeaders === void 0;

90 90

});

91 91

if (hasBody) {

92 -

request.headers["content-type"] = "application/json";

92 +

request.headers["content-type"] = this.getDefaultContentType();

93 93

}

94 94

}

95 95

}

@@ -157,4 +157,11 @@ export class AwsRestJsonProtocol extends HttpBindingProtocol {

157 157 158 158

throw exception;

159 159

}

160 + 161 +

/**

162 +

* @override

163 +

*/

164 +

protected getDefaultContentType(): string {

165 +

return "application/json";

166 +

}

160 167

}

Original file line number Diff line number Diff line change

@@ -212,4 +212,11 @@ export class AwsQueryProtocol extends RpcProtocol {

212 212

const errorData = this.loadQueryError(data);

213 213

return errorData?.message ?? errorData?.Message ?? data.message ?? data.Message ?? "Unknown";

214 214

}

215 + 216 +

/**

217 +

* @override

218 +

*/

219 +

protected getDefaultContentType(): string {

220 +

return "application/x-www-form-urlencoded";

221 +

}

215 222

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4