Converts OpenAPI specifications (YAML or JSON) to Zod schemas with code generation. v1.3.1 supports complex structures (allOf, oneOf, anyOf), $ref resolution, and a CLI for local/remote files. Differentiators: dual library/CLI, TypeScript-first output, and handles advanced OpenAPI patterns. Peer dependency on zod ^3.21.4.
npm install openapi-to-zod-schemaNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates converting an OpenAPI spec with a User schema to Zod schemas and generating TypeScript code.
Use import syntax or dynamic import() in CJS.
Validate spec before passing; handle undefined schemas in map.
Prefer using codegen programmatically.
Resolve references manually before passing to convertOpenAPISpecToZodSchemas.
Switch to import { ... } from 'openapi-to-zod-schema' or use dynamic import().Ensure spec has valid 'components.schemas' and is a proper OpenAPI document.
Use 'npx openapi-to-zod-schema input.yaml -o output.ts' with correct order.