n8n/packages/@n8n/json-schema-to-zod
Eugene 28487edb13
chore: Upgrade LangChain packages to latest versions (no-changelog) (#11771)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
2024-12-02 15:35:23 +01:00
..
src chore: Upgrade LangChain packages to latest versions (no-changelog) (#11771) 2024-12-02 15:35:23 +01:00
test feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
.eslintrc.js feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
.gitignore feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
.npmignore feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
jest.config.js feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
LICENSE feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
package.json 🚀 Release 1.65.0 (#11386) 2024-10-24 12:29:51 +02:00
postcjs.js feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
postesm.js feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
README.md feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
tsconfig.cjs.json feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
tsconfig.esm.json feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
tsconfig.json feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
tsconfig.types.json feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00

Json-Schema-to-Zod

A package to convert JSON schema (draft 4+) objects into Zod schemas in the form of Zod objects at runtime.

Installation

npm install @n8n/json-schema-to-zod

Simple example

import { jsonSchemaToZod } from "json-schema-to-zod";

const jsonSchema = {
  type: "object",
  properties: {
    hello: {
      type: "string",
    },
  },
};

const zodSchema = jsonSchemaToZod(myObject);

Overriding a parser

You can pass a function to the overrideParser option, which represents a function that receives the current schema node and the reference object, and should return a zod object when it wants to replace a default output. If the default output should be used for the node just return undefined.

Acknowledgements

This is a fork of json-schema-to-zod.