Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/serious-waves-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smithy/core": patch
---

allow struct iterator acquisition on unit schema
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ describe(NormalizedSchema.name, () => {
expect(schema.getMergedTraits()).toEqual(entrySchema.getMergedTraits());
}
});

it("can acquire structIterator on the unit schema type and its iteration is empty", () => {
const iteration = Array.from(NormalizedSchema.of("unit").structIterator());
expect(iteration.length).toBe(0);
});
});

describe("traits", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ export class NormalizedSchema implements INormalizedSchema {
* This avoids the overhead of calling Object.entries(ns.getMemberSchemas()).
*/
public *structIterator(): Generator<[string, NormalizedSchema], undefined, undefined> {
if (this.isUnitSchema()) {
return;
}
if (!this.isStructSchema()) {
throw new Error("@smithy/core/schema - cannot acquire structIterator on non-struct schema.");
}
Expand Down