chatgpt-api/packages/core/src/zod-to-json-schema.ts

18 wiersze
470 B
TypeScript
Czysty Zwykły widok Historia

2024-05-21 13:52:06 +00:00
import type { z } from 'zod'
import { zodToJsonSchema as zodToJsonSchemaImpl } from 'zod-to-json-schema'
import type * as types from './types'
import { omit } from './utils'
2024-05-21 13:52:06 +00:00
/** Generate a JSON Schema from a Zod schema. */
2024-07-26 21:40:34 +00:00
export function zodToJsonSchema(schema: z.ZodType): types.JSONSchema {
2024-05-21 13:52:06 +00:00
return omit(
zodToJsonSchemaImpl(schema, { $refStrategy: 'none' }),
'$schema',
'default',
'definitions',
'description',
2024-05-22 08:11:36 +00:00
'markdownDescription'
2024-05-21 13:52:06 +00:00
)
}