| 1 | import * as Schema from "effect/Schema" |
| 2 | import * as SchemaRepresentation from "effect/SchemaRepresentation" |
| 3 | |
| 4 | const schema = Schema.toCodecJson(Schema.Struct({ |
| 5 | a: Schema.String, |
| 6 | b: Schema.optional(Schema.FiniteFromString), |
| 7 | c: Schema.Array(Schema.String) |
| 8 | })) |
| 9 | |
| 10 | const json = SchemaRepresentation.toJson(SchemaRepresentation.toRepresentation(schema.ast)) |
| 11 | |
| 12 | export const roundtrip = SchemaRepresentation.fromRepresentation( |
| 13 | SchemaRepresentation.fromJson(JSON.parse(JSON.stringify(json))), |
| 14 | { revivers: [SchemaRepresentation.isFiniteReviver] } |
| 15 | ) |