( schema: z.ZodTypeAny, io: 'input' | 'output', target: 'draft-7' | 'openapi-3.0', )
| 44 | } |
| 45 | |
| 46 | function 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 |
no outgoing calls
no test coverage detected