Schema
/ API Reference
Schema
/ API Reference

fromZod

A function that converts a Zod schema to a JSON schema.
For now, it simply uses the toJSONSchema (new tab) from Zod under the hood.

The Gist

import { fromZod } from '@weser/schema'

const schema = z.object({
  name: z.string(),
})

const json = fromZod(schema)

Parameters

ParameterTypeDescription
schemaZodTypeThe Zod schema to convert to a JSON schema.

Returns

(T_JSONSchema) A JSON schema.

On this page