(name: string, schema: Schema.Top, expectedType: string, samples: Samples)
| 73 | } |
| 74 | |
| 75 | function example(name: string, schema: Schema.Top, expectedType: string, samples: Samples): void { |
| 76 | it(name, async () => { |
| 77 | const document = generate(schema) |
| 78 | const source = document.print() |
| 79 | register(name, source, [expectedType]) |
| 80 | await withGeneratedModule<Generated>(source, ({ TestRoot0 }) => assertSamples(TestRoot0, samples)) |
| 81 | // Exercise annotations on every schema shape without normalizing generated code. |
| 82 | const annotated = generate(schema.annotate({ description: "generated annotation" })).print() |
| 83 | await withGeneratedModule<Generated>(annotated, ({ TestRoot0 }) => { |
| 84 | assert.strictEqual(Schema.resolveAnnotations(TestRoot0)?.description, "generated annotation") |
| 85 | assertSamples(TestRoot0, samples) |
| 86 | }) |
| 87 | }) |
| 88 | } |
| 89 | |
| 90 | function fromJson(schema: JsonSchema.JsonSchema): Schema.Top { |
| 91 | return SchemaRepresentation.fromJsonSchemaDocument(JsonSchema.fromSchemaDraft2020_12(schema), { |
no test coverage detected