Skip to content

Class: JSONSchemaGenerator

Defined in: node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-generator.d.cts:32

Legacy class-based interface for JSON Schema generation. This class wraps the new functional implementation to provide backward compatibility.

Deprecated

Use the toJSONSchema function instead for new code.

Example

typescript
// Legacy usage (still supported)
const gen = new JSONSchemaGenerator({ target: "draft-07" });
gen.process(schema);
const result = gen.emit(schema);

// Preferred modern usage
const result = toJSONSchema(schema, { target: "draft-07" });

Accessors

metadataRegistry

Get Signature

ts
get metadataRegistry(): $ZodRegistry<Record<string, any>>;

Defined in: node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-generator.d.cts:35

Deprecated

Access via ctx instead

Returns

$ZodRegistry<Record<string, any>>


target

Get Signature

ts
get target(): 
  | "draft-04"
  | "draft-07"
  | "draft-2020-12"
  | "openapi-3.0"
  | {
} & string;

Defined in: node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-generator.d.cts:37

Deprecated

Access via ctx instead

Returns

| "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0" | { } & string


unrepresentable

Get Signature

ts
get unrepresentable(): "any" | "throw";

Defined in: node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-generator.d.cts:39

Deprecated

Access via ctx instead

Returns

"any" | "throw"


override

Get Signature

ts
get override(): (ctx: {
  zodSchema: $ZodType;
  jsonSchema: JSONSchema;
  path: (string | number)[];
}) => void;

Defined in: node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-generator.d.cts:41

Deprecated

Access via ctx instead

Returns
ts
(ctx: {
  zodSchema: $ZodType;
  jsonSchema: JSONSchema;
  path: (string | number)[];
}): void;
Parameters
ParameterType
ctx{ zodSchema: $ZodType; jsonSchema: JSONSchema; path: (string | number)[]; }
ctx.zodSchema$ZodType
ctx.jsonSchemaJSONSchema
ctx.path(string | number)[]
Returns

void


io

Get Signature

ts
get io(): "input" | "output";

Defined in: node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-generator.d.cts:47

Deprecated

Access via ctx instead

Returns

"input" | "output"


counter

Get Signature

ts
get counter(): number;

Defined in: node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-generator.d.cts:49

Deprecated

Access via ctx instead

Returns

number


seen

Get Signature

ts
get seen(): Map<$ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>, Seen>;

Defined in: node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-generator.d.cts:52

Deprecated

Access via ctx instead

Returns

Map<$ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>, Seen>

Methods

process()

ts
process(schema: $ZodType, _params?: ProcessParams): JSONSchema;

Defined in: node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-generator.d.cts:58

Process a schema to prepare it for JSON Schema generation. This must be called before emit().

Parameters

ParameterType
schema$ZodType
_params?ProcessParams

Returns

JSONSchema


emit()

ts
emit(schema: $ZodType, _params?: EmitParams): JSONSchema;

Defined in: node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-generator.d.cts:63

Emit the final JSON Schema after processing. Must call process() first.

Parameters

ParameterType
schema$ZodType
_params?EmitParams

Returns

JSONSchema

Matterway Assistant SDK Documentation