Skip to content

Graphorin API reference v0.7.0


Graphorin API reference / @graphorin/tools / / projectSchemaToJsonSchema

Function: projectSchemaToJsonSchema()

ts
function projectSchemaToJsonSchema(raw, opts?): 
  | JsonSchemaRecord
  | undefined;

Defined in: packages/tools/src/schema/to-json-schema.ts:804

Project a tool's declared inputSchema / outputSchema - whatever the author supplied - onto a JSON Schema record fit for a provider wire body or a code-mode signature. Resolution order:

  1. undefined/nullundefined.
  2. A toJSON() method → its result (MCP validators, hand-rolled schemas; a throwing/non-object toJSON falls through).
  3. A Zod v4 or v3 schema → zodToJsonSchema.
  4. Plain JSON-Schema-shaped data → passed through as-is.
  5. Anything else (an opaque validator this converter cannot read) → undefined, reported via onUnsupported - callers substitute a permissive {} rather than shipping serialized internals.

Parameters

ParameterType
rawunknown
optsProjectSchemaOptions

Returns

| JsonSchemaRecord | undefined

Stable