From 4fff8fe206ef54bd8923ff026f6ccb450831dd4a Mon Sep 17 00:00:00 2001 From: jai <86279939+Jayavardhan11@users.noreply.github.com> Date: Wed, 23 Jul 2025 14:57:23 +0530 Subject: [PATCH] feat(openai): add jsonSchema wrapper to validate top-level object schemas Ensures OpenAI-compatible structured outputs with a strict object schema interface. --- src/jsonSchema.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/jsonSchema.ts diff --git a/src/jsonSchema.ts b/src/jsonSchema.ts new file mode 100644 index 0000000..c0773ad --- /dev/null +++ b/src/jsonSchema.ts @@ -0,0 +1,9 @@ +import type { ObjectSchema, Schema } from './types' + +export function jsonSchema(schema: Schema): ObjectSchema { + if (schema.type !== 'object') { + throw new Error('Top-level schema must be an object') + } + + return schema +}