Skip to content

Commit 3f12b92

Browse files
darrenmcestainless-app[bot]
authored andcommitted
helpers/zod: fix type on props parameter and add test (#1018)
1 parent 8243907 commit 3f12b92

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Diff for: src/helpers/zod.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function zodToJsonSchema(schema: z.ZodType, options: { name: string }): Record<s
5858
export function zodResponseFormat<ZodInput extends z.ZodType>(
5959
zodObject: ZodInput,
6060
name: string,
61-
props?: Omit<ResponseFormatJSONSchema, 'schema' | 'strict' | 'name'>,
61+
props?: Omit<ResponseFormatJSONSchema.JSONSchema, 'schema' | 'strict' | 'name'>,
6262
): AutoParseableResponseFormat<z.infer<ZodInput>> {
6363
return makeParseableResponseFormat(
6464
{

Diff for: tests/helpers/zod.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@ describe('zodResponseFormat', () => {
132132
`);
133133
});
134134

135+
it('allows description field to be passed in', () => {
136+
expect(
137+
zodResponseFormat(
138+
z.object({
139+
city: z.string(),
140+
}),
141+
'city',
142+
{ description: 'A city' },
143+
).json_schema,
144+
).toHaveProperty('description', 'A city');
145+
});
146+
135147
test('kitchen sink types', () => {
136148
const Table = z.enum(['orders', 'customers', 'products']);
137149

0 commit comments

Comments
 (0)