{"_id":"@dylibso/json-schema-to-zod-openai","name":"@dylibso/json-schema-to-zod-openai","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.5":{"name":"@dylibso/json-schema-to-zod-openai","version":"1.0.5","description":"Convert JSON Schema to Zod schema. Tailored for OpenAI.","main":"dist/index.js","types":"dist/index.d.ts","type":"module","publishConfig":{"access":"public"},"scripts":{"build":"tsc"},"dependencies":{"zod":"^3.22.4"},"devDependencies":{"typescript":"^5.3.3"},"repository":{"type":"git","url":"git+https://github.com/dylibso/json-schema-to-zod-openai.git"},"bugs":{"url":"https://github.com/dylibso/json-schema-to-zod-openai/issues"},"homepage":"https://github.com/dylibso/json-schema-to-zod-openai#readme","_id":"@dylibso/json-schema-to-zod-openai@1.0.5","gitHead":"dd7e7f5cd33de2c43dcbe5a560fb1268f8cb2260","_nodeVersion":"22.11.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-QOphWt6FGervqwQES1AHQePhF4AywAo/pv27GRhmSmDIdTAk24lbDMBGalzgk8TkywaL53bfADs5qt18ZRPZCg==","shasum":"c98402c3f39f44d22e054ff0b7c7b363820fb6aa","tarball":"https://registry.npmjs.org/@dylibso/json-schema-to-zod-openai/-/json-schema-to-zod-openai-1.0.5.tgz","fileCount":5,"unpackedSize":6039,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDwqSqRuN9v1RszvUkFuVQbXhML/TI7kb8r2Mc+NZZeRQIga74uF1hLJ9+eGHa6CmpxlutI7+sIkViPmB0cCGnRybQ="}]},"_npmUser":{"name":"dylibso","email":"oss@dylibso.com"},"directories":{},"maintainers":[{"name":"dylibso","email":"oss@dylibso.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/json-schema-to-zod-openai_1.0.5_1739280168836_0.8100050339737643"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-11T13:22:48.710Z","1.0.5":"2025-02-11T13:22:49.044Z","modified":"2025-02-11T13:22:49.380Z"},"maintainers":[{"name":"dylibso","email":"oss@dylibso.com"}],"description":"Convert JSON Schema to Zod schema. Tailored for OpenAI.","homepage":"https://github.com/dylibso/json-schema-to-zod-openai#readme","repository":{"type":"git","url":"git+https://github.com/dylibso/json-schema-to-zod-openai.git"},"bugs":{"url":"https://github.com/dylibso/json-schema-to-zod-openai/issues"},"readme":"# json-schema-to-zod-openai\r\n\r\nA TypeScript library that converts JSON Schema to Zod schema with OpenAI compatibility.\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install json-schema-to-zod-openai\r\n```\r\n\r\n## Usage\r\n\r\n```typescript\r\nimport { convertToZodSchema } from 'json-schema-to-zod-openai';\r\n\r\nconst jsonSchema = {\r\n  type: 'object',\r\n  properties: {\r\n    name: { type: 'string' },\r\n    age: { type: 'number' },\r\n    roles: {\r\n      type: 'array',\r\n      items: {\r\n        type: 'string',\r\n        enum: ['admin', 'user', 'guest']\r\n      }\r\n    }\r\n  },\r\n  required: ['name']\r\n};\r\n\r\nconst zodSchema = convertToZodSchema(jsonSchema);\r\n\r\n// Use the schema for validation\r\ntry {\r\n  const validated = zodSchema.parse({\r\n    name: 'John Doe',\r\n    age: 30,\r\n    roles: ['admin', 'user']\r\n  });\r\n  console.log('Valid data:', validated);\r\n} catch (error) {\r\n  console.error('Validation error:', error);\r\n}\r\n```\r\n\r\n## Features\r\n\r\n- Converts JSON Schema to Zod schema\r\n- Supports OpenAI's schema limitations\r\n- Handles:\r\n  - Basic types (string, number, boolean)\r\n  - Arrays\r\n  - Enums\r\n  - Nullable fields\r\n  - Required fields\r\n  - Object properties\r\n  - Nested objects\r\n  - Additional properties control\r\n","readmeFilename":"README.md"}