Skip to content

Commit f32c1f1

Browse files
authored
chore(core/protocols): add fallback for schema short name (#7314)
1 parent 1f7ccf0 commit f32c1f1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

packages/core/src/submodules/protocols/ProtocolLib.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export class ProtocolLib {
6767
} else if (!inputSchema.isUnitSchema()) {
6868
const hasBody = Object.values(members).find((m) => {
6969
const { httpQuery, httpQueryParams, httpHeader, httpLabel, httpPrefixHeaders } = m.getMergedTraits();
70-
return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && httpPrefixHeaders === void 0;
70+
const noPrefixHeaders = httpPrefixHeaders === void 0;
71+
return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && noPrefixHeaders;
7172
});
7273
if (hasBody) {
7374
return defaultContentType;

packages/core/src/submodules/protocols/query/AwsQueryProtocol.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ export class AwsQueryProtocol extends RpcProtocol {
7676
if (deref(operationSchema.input) === "unit" || !request.body) {
7777
request.body = "";
7878
}
79-
request.body = `Action=${operationSchema.name.split("#")[1]}&Version=${this.options.version}` + request.body;
79+
const action = operationSchema.name.split("#")[1] ?? operationSchema.name;
80+
request.body = `Action=${action}&Version=${this.options.version}` + request.body;
8081
if (request.body.endsWith("&")) {
8182
request.body = request.body.slice(-1);
8283
}
@@ -110,9 +111,8 @@ export class AwsQueryProtocol extends RpcProtocol {
110111
delete response.headers[header];
111112
response.headers[header.toLowerCase()] = value;
112113
}
113-
114-
const awsQueryResultKey =
115-
ns.isStructSchema() && this.useNestedResult() ? operationSchema.name.split("#")[1] + "Result" : undefined;
114+
const shortName = operationSchema.name.split("#")[1] ?? operationSchema.name;
115+
const awsQueryResultKey = ns.isStructSchema() && this.useNestedResult() ? shortName + "Result" : undefined;
116116
const bytes: Uint8Array = await collectBody(response.body, context as SerdeFunctions);
117117
if (bytes.byteLength > 0) {
118118
Object.assign(dataObject, await deserializer.read(ns, bytes, awsQueryResultKey));

0 commit comments

Comments
 (0)