Skip to content

Commit

Permalink
helpers/zod: fix type on props parameter and add test (#1018)
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenmce authored and stainless-app[bot] committed Aug 29, 2024
1 parent 8243907 commit 3f12b92
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/helpers/zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function zodToJsonSchema(schema: z.ZodType, options: { name: string }): Record<s
export function zodResponseFormat<ZodInput extends z.ZodType>(
zodObject: ZodInput,
name: string,
props?: Omit<ResponseFormatJSONSchema, 'schema' | 'strict' | 'name'>,
props?: Omit<ResponseFormatJSONSchema.JSONSchema, 'schema' | 'strict' | 'name'>,
): AutoParseableResponseFormat<z.infer<ZodInput>> {
return makeParseableResponseFormat(
{
Expand Down
12 changes: 12 additions & 0 deletions tests/helpers/zod.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ describe('zodResponseFormat', () => {
`);
});

it('allows description field to be passed in', () => {
expect(
zodResponseFormat(
z.object({
city: z.string(),
}),
'city',
{ description: 'A city' },
).json_schema,
).toHaveProperty('description', 'A city');
});

test('kitchen sink types', () => {
const Table = z.enum(['orders', 'customers', 'products']);

Expand Down

0 comments on commit 3f12b92

Please sign in to comment.