Skip to content

Commit 35c94df

Browse files
siddsrivkuhe
authored andcommitted
fix(codegen): allow empty string field values for headers
fix(codegen): utilize loose equality for falsy null/undefined bring isSerializableHeaderValue into smithy-client
1 parent 2406750 commit 35c94df

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

.changeset/small-gifts-tease.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/smithy-client": patch
3+
---
4+
5+
serialize empty strings and collections in headers

packages/smithy-client/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export * from "./exceptions";
1313
export * from "./extended-encode-uri-component";
1414
export * from "./get-array-if-single-item";
1515
export * from "./get-value-from-text-node";
16+
export * from "./is-serializable-header-value";
1617
export * from "./lazy-json";
1718
export * from "./object-mapping";
1819
export * from "./parse-utils";
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { isSerializableHeaderValue } from "./is-serializable-header-value";
2+
3+
describe(isSerializableHeaderValue.name, () => {
4+
it("considers empty strings serializable", () => {
5+
expect(isSerializableHeaderValue("")).toBe(true);
6+
});
7+
8+
it("considers empty collections serializable", () => {
9+
expect(isSerializableHeaderValue(new Set())).toBe(true);
10+
expect(isSerializableHeaderValue([])).toBe(true);
11+
});
12+
13+
it("considers most falsy data values to be serializable", () => {
14+
expect(isSerializableHeaderValue(false)).toBe(true);
15+
expect(isSerializableHeaderValue(0)).toBe(true);
16+
expect(isSerializableHeaderValue(new Date(0))).toBe(true);
17+
});
18+
19+
it("considered undefined and null to be unserializable", () => {
20+
expect(isSerializableHeaderValue(undefined)).toBe(false);
21+
expect(isSerializableHeaderValue(null)).toBe(false);
22+
});
23+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @internal
3+
* @returns whether the header value is serializable.
4+
*/
5+
export const isSerializableHeaderValue = (value: any) => {
6+
return value != null;
7+
};

0 commit comments

Comments
 (0)