MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / jsonSchemaForTarget

Function jsonSchemaForTarget

packages/server/src/middleware/schema.ts:46–60  ·  view source on GitHub ↗
(
  schema: z.ZodTypeAny,
  io: 'input' | 'output',
  target: 'draft-7' | 'openapi-3.0',
)

Source from the content-addressed store, hash-verified

44}
45
46function jsonSchemaForTarget(
47 schema: z.ZodTypeAny,
48 io: 'input' | 'output',
49 target: 'draft-7' | 'openapi-3.0',
50): Record<string, unknown> {
51 const converted = z.toJSONSchema(schema, {
52 target,
53 io,
54 unrepresentable: 'any',
55 }) as Record<string, unknown>;
56 if (converted['$schema'] !== undefined) {
57 delete converted['$schema'];
58 }
59 return converted;
60}
61
62/**
63 * Wrap a data Zod schema in the server's envelope shape and return its

Callers 3

jsonSchemaFunction · 0.85
outputJsonSchemaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected