json-schema-to-zod
Advanced tools
Comparing version 2.0.12 to 2.0.13
@@ -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", |
100006
2514