Skip to content

Documentation / @super-line/core / jsonSchemaOf

Function: jsonSchemaOf() ​

jsonSchemaOf(schema): Record<string, unknown> | undefined

Defined in: packages/core/src/contract.ts:503

Read a schema's shape as JSON Schema via the Standard JSON Schema companion spec — the vendor-neutral way to introspect a validator, implemented by Zod 4.2+, ArkType, VineJS, Sury and (via toStandardJsonSchema) Valibot.

Returns undefined when the shape is unavailable: either the schema's library has not implemented the companion spec, or the conversion threw (the spec permits that for unrepresentable schemas). Callers treat both the same way — no shape, so fall back rather than fail.

A root that is only a local $ref (Zod 4.5+ emits one for a root .meta({ id })) is replaced by its target, with the definitions kept beside it, so the shape is readable at the root.

Parameters ​

schema ​

unknown

any Standard Schema validator.

Returns ​

Record<string, unknown> | undefined

the validated OUTPUT shape as JSON Schema, or undefined if it cannot be produced.

Released under the MIT License.