|
7 | 7 | } from './registries'
|
8 | 8 |
|
9 | 9 | const customSchema1 = z.string().meta({
|
| 10 | + title: 'Custom String Schema', |
10 | 11 | description: 'description',
|
11 | 12 | examples: ['a', 'b'],
|
12 | 13 | })
|
@@ -45,11 +46,20 @@ JSON_SCHEMA_OUTPUT_REGISTRY.add(customSchema3, {
|
45 | 46 | examples: ['1'],
|
46 | 47 | })
|
47 | 48 |
|
| 49 | +const customSchemaWithTitleOnly = z.string().meta({ |
| 50 | + title: 'Title Only Schema', |
| 51 | +}) |
| 52 | + |
| 53 | +const unionSchema = z.union([ |
| 54 | + z.string().meta({ title: 'String Option' }), |
| 55 | + z.number().meta({ title: 'Number Option' }), |
| 56 | +]) |
| 57 | + |
48 | 58 | testSchemaConverter([
|
49 | 59 | {
|
50 | 60 | name: 'customSchema1',
|
51 | 61 | schema: customSchema1,
|
52 |
| - input: [true, { type: 'string', description: 'description', examples: ['a', 'b'] }], |
| 62 | + input: [true, { type: 'string', title: 'Custom String Schema', description: 'description', examples: ['a', 'b'] }], |
53 | 63 | },
|
54 | 64 | {
|
55 | 65 | name: 'customSchema1_unsupported_examples',
|
@@ -93,4 +103,19 @@ testSchemaConverter([
|
93 | 103 | schema: z.string().readonly(),
|
94 | 104 | input: [true, { type: 'string', readOnly: true }],
|
95 | 105 | },
|
| 106 | + { |
| 107 | + name: 'customSchemaWithTitleOnly', |
| 108 | + schema: customSchemaWithTitleOnly, |
| 109 | + input: [true, { type: 'string', title: 'Title Only Schema' }], |
| 110 | + }, |
| 111 | + { |
| 112 | + name: 'unionSchema', |
| 113 | + schema: unionSchema, |
| 114 | + input: [true, { |
| 115 | + anyOf: [ |
| 116 | + { type: 'string', title: 'String Option' }, |
| 117 | + { type: 'number', title: 'Number Option' }, |
| 118 | + ], |
| 119 | + }], |
| 120 | + }, |
96 | 121 | ])
|
0 commit comments