@internal
()
| 1075 | } |
| 1076 | /** @internal */ |
| 1077 | toCodecStringTree(): AST { |
| 1078 | if (this.enums.some(([_, v]) => typeof v === "number")) { |
| 1079 | const coercions = Object.fromEntries(this.enums.map(([_, v]) => [globalThis.String(v), v])) |
| 1080 | return replaceEncoding(this, [ |
| 1081 | new Link( |
| 1082 | new Union(Object.keys(coercions).map((k) => new Literal(k)), "anyOf"), |
| 1083 | new SchemaTransformation.Transformation( |
| 1084 | SchemaGetter.transform((s) => coercions[s]), |
| 1085 | SchemaGetter.String() |
| 1086 | ) |
| 1087 | ) |
| 1088 | ]) |
| 1089 | } |
| 1090 | return this |
| 1091 | } |
| 1092 | /** @internal */ |
| 1093 | getExpected(): string { |
| 1094 | return this.enums.map(([_, value]) => JSON.stringify(value)).join(" | ") |