mirror of
https://github.com/Kong/insomnia.git
synced 2026-11-08 05:54:25 -05:00
* migrate request related p2 - grpc-request - cookie-jar - fix ts errors * add unit test to check field mismatch * migrate request group model * migrate the socket io request and import parser * migrate websocket schema and fix ts error * fix order issue and add unit tests
14 lines
554 B
TypeScript
14 lines
554 B
TypeScript
import { z } from 'zod/v4';
|
|
|
|
// Basic literal types that can appear in JSON data
|
|
export const LiteralSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
|
|
export const KeyLiteralSchema = z.union([z.string(), z.number()]);
|
|
|
|
type Literal = z.infer<typeof LiteralSchema>;
|
|
type Json = Literal | { [key: string]: Json } | Json[];
|
|
|
|
// Recursive JSON schema that can handle nested objects and arrays
|
|
export const JsonSchema: z.ZodType<Json> = z.lazy(() =>
|
|
z.union([LiteralSchema, z.array(JsonSchema), z.record(KeyLiteralSchema, JsonSchema)]),
|
|
);
|