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/plenty-snails-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smithy/snapshot-testing": patch
---

additional member value overrides for snapshot data generator
1 change: 1 addition & 0 deletions packages/snapshot-testing/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { SnapshotRunner } from "./SnapshotRunner";
export { customFields } from "./structure/createFromSchema";
14 changes: 12 additions & 2 deletions packages/snapshot-testing/src/structure/createFromSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export function createFromSchema(schema: $SchemaRef, path = ""): any {
const $ = NormalizedSchema.of(schema);

const memberName = $.isMemberSchema() ? $.getMemberName() : "____";
if (customFields[memberName]) {
return customFields[memberName];
}

const qualifiedName = $.getName(true) ?? "UnknownSchema!";
path += " -> " + qualifiedName + "$" + memberName;

Expand All @@ -23,7 +27,7 @@ export function createFromSchema(schema: $SchemaRef, path = ""): any {
if ($.isIdempotencyToken()) {
return "00000000-0000-4000-8000-000000000000";
}
return customFields[memberName] ?? "__" + memberName + "__";
return "__" + memberName + "__";
} else if ($.isNumericSchema()) {
return 0;
} else if ($.isBigIntegerSchema()) {
Expand Down Expand Up @@ -107,7 +111,13 @@ export function createFromSchema(schema: $SchemaRef, path = ""): any {
return "UNSUPPORTED_SCHEMA_TYPE";
}

const customFields: Record<string, string> = {
/**
* Overrides the generated values for members with matching names.
* @internal
*/
export const customFields: Record<string, string> = {
PredictEndpoint: "https://localhost",
ChecksumAlgorithm: "CRC64NVME",
AccountId: "123456789012",
OutpostId: "OutpostId",
};
Loading