MCPcopy Index your code
hub / github.com/anomalyco/opencode / zodJsonSchema

Function zodJsonSchema

packages/opencode/src/tool/registry.ts:340–347  ·  view source on GitHub ↗
(schema: z.ZodType)

Source from the content-addressed store, hash-verified

338}
339
340function zodJsonSchema(schema: z.ZodType): JSONSchema7 {
341 const result = normalizeZodJsonSchema(z.toJSONSchema(schema, { io: "input", metadata: zodMetadataRegistry(schema) }))
342 if (!isJsonSchemaObject(result)) throw new Error("plugin tool Zod schema produced a non-object JSON Schema")
343 const { $defs, ...rest } = result
344 return (
345 $defs && isJsonSchemaObject($defs) ? { ...rest, definitions: $defs as JSONSchema7["definitions"] } : rest
346 ) as JSONSchema7
347}
348
349function zodMetadataRegistry(schema: z.ZodType) {
350 const registry = z.registry<Record<string, unknown>>()

Callers 1

fromPluginFunction · 0.85

Calls 3

normalizeZodJsonSchemaFunction · 0.85
zodMetadataRegistryFunction · 0.85
isJsonSchemaObjectFunction · 0.85

Tested by

no test coverage detected