kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
17 wiersze
442 B
TypeScript
17 wiersze
442 B
TypeScript
import type { z } from 'zod'
|
|
import { zodToJsonSchema as zodToJsonSchemaImpl } from 'zod-to-json-schema'
|
|
|
|
import { omit } from './utils.js'
|
|
|
|
/** Generate a JSON Schema from a Zod schema. */
|
|
export function zodToJsonSchema(schema: z.ZodType): Record<string, unknown> {
|
|
return omit(
|
|
zodToJsonSchemaImpl(schema, { $refStrategy: 'none' }),
|
|
'$schema',
|
|
'default',
|
|
'definitions',
|
|
'description',
|
|
'markdownDescription'
|
|
)
|
|
}
|