Skip to content

Documentation / @super-line/core / jsonSchemaOf

Function: jsonSchemaOf()

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

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

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.

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.