Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-schema-to-zod

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-to-zod - npm Package Compare versions

Comparing version 2.0.12 to 2.0.13

CONTRIBUTING.md

2

dist/cjs/parsers/parseNullable.js

@@ -10,4 +10,4 @@ "use strict";

const parseNullable = (schema, refs) => {
return `${(0, parseSchema_js_1.parseSchema)((0, omit_js_1.omit)(schema, "nullable"), refs)}.nullable()`;
return `${(0, parseSchema_js_1.parseSchema)((0, omit_js_1.omit)(schema, "nullable"), refs, true)}.nullable()`;
};
exports.parseNullable = parseNullable;

@@ -20,3 +20,3 @@ "use strict";

const parseNullable_js_1 = require("./parseNullable.js");
const parseSchema = (schema, refs = { seen: new Map(), path: [] }) => {
const parseSchema = (schema, refs = { seen: new Map(), path: [] }, blockMeta) => {
if (typeof schema !== "object")

@@ -45,5 +45,7 @@ return schema ? "z.any()" : "z.never()";

let parsed = selectParser(schema, refs);
parsed = addMeta(schema, parsed);
if (!refs.withoutDefaults) {
parsed = addDefaults(schema, parsed);
if (!blockMeta) {
parsed = addMeta(schema, parsed);
if (!refs.withoutDefaults) {
parsed = addDefaults(schema, parsed);
}
}

@@ -50,0 +52,0 @@ seen.r = parsed;

@@ -7,3 +7,3 @@ import { omit } from "../utils/omit.js";

export const parseNullable = (schema, refs) => {
return `${parseSchema(omit(schema, "nullable"), refs)}.nullable()`;
return `${parseSchema(omit(schema, "nullable"), refs, true)}.nullable()`;
};

@@ -17,3 +17,3 @@ import { parseAnyOf } from "./parseAnyOf.js";

import { parseNullable } from "./parseNullable.js";
export const parseSchema = (schema, refs = { seen: new Map(), path: [] }) => {
export const parseSchema = (schema, refs = { seen: new Map(), path: [] }, blockMeta) => {
if (typeof schema !== "object")

@@ -42,5 +42,7 @@ return schema ? "z.any()" : "z.never()";

let parsed = selectParser(schema, refs);
parsed = addMeta(schema, parsed);
if (!refs.withoutDefaults) {
parsed = addDefaults(schema, parsed);
if (!blockMeta) {
parsed = addMeta(schema, parsed);
if (!refs.withoutDefaults) {
parsed = addDefaults(schema, parsed);
}
}

@@ -47,0 +49,0 @@ seen.r = parsed;

import { Refs, JsonSchemaObject, JsonSchema, Serializable } from "../Types.js";
export declare const parseSchema: (schema: JsonSchema, refs?: Refs) => string;
export declare const parseSchema: (schema: JsonSchema, refs?: Refs, blockMeta?: boolean) => string;
export declare const its: {

@@ -4,0 +4,0 @@ an: {

{
"name": "json-schema-to-zod",
"version": "2.0.12",
"version": "2.0.13",
"description": "Converts JSON schema objects or files into Zod schemas",

@@ -5,0 +5,0 @@ "types": "./dist/types/index.d.ts",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc