avancement planning
This commit is contained in:
+12
-21
@@ -3,7 +3,11 @@
|
||||
[](https://npmjs.org/package/zod-to-json-schema)
|
||||
[](https://npmjs.org/package/zod-to-json-schema)
|
||||
|
||||
_Looking for the exact opposite? Check out [json-schema-to-zod](https://npmjs.org/package/json-schema-to-zod)_
|
||||
## Notice of deprecation
|
||||
|
||||
As of November 2025, this project will no longer be actively maintained. [Zod v4 natively supports generating JSON schemas](https://zod.dev/json-schema#ztojsonschema), so I recommend you switch to the new major.
|
||||
|
||||
Thank you to all the contributors and sponsors throughout the years! So long, and thanks for all the fish.
|
||||
|
||||
## Summary
|
||||
|
||||
@@ -13,10 +17,13 @@ Does what it says on the tin; converts [Zod schemas](https://github.com/colinhac
|
||||
- Resolves recursive and recurring schemas with internal `$ref`s.
|
||||
- Supports targeting legacy Open API 3.0 specification (3.1 supports regular Json Schema).
|
||||
- Supports Open AI strict mode schemas (Optional object properties are replaced with required but nullable ones).
|
||||
- As of v3.25 you can use Zod v4 as a peer-dependency, so long as you still provide v3-schemas.
|
||||
|
||||
_Looking for the exact opposite? Check out [json-schema-to-zod](https://npmjs.org/package/json-schema-to-zod)_
|
||||
|
||||
## Sponsors
|
||||
|
||||
A great big thank you to our amazing sponsors! Please consider joining them through my [GitHub Sponsors page](https://github.com/sponsors/StefanTerdell). Every cent helps, but these fellas have really gone above and beyond 💚:
|
||||
As this project will no longer be receiving updates I am no longer accepting new partnerships. Huge shout-out to CodeRabbit for keeping it real to the end <3
|
||||
|
||||
<table align="center" style="justify-content: center;align-items: center;display: flex;">
|
||||
<tr>
|
||||
@@ -39,24 +46,6 @@ A great big thank you to our amazing sponsors! Please consider joining them thro
|
||||
<p></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<p></p>
|
||||
<p>
|
||||
<a href="https://retool.com/?ref=stefanterdell&utm_source=github&utm_medium=referral&utm_campaign=stefanterdell">
|
||||
<picture height="45px">
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/colinhacks/zod/assets/3084745/ac65013f-aeb4-48dd-a2ee-41040b69cbe6">
|
||||
<img alt="stainless" height="45px" src="https://github.com/colinhacks/zod/assets/3084745/5ef4c11b-efeb-4495-90a8-41b83f798600">
|
||||
</picture>
|
||||
</a>
|
||||
<br />
|
||||
Build AI apps and workflows with <a href="https://retool.com/products/ai?ref=stefanterdell&utm_source=github&utm_medium=referral&utm_campaign=stefanterdell">Retool AI</a>
|
||||
<br/>
|
||||
<a href="https://retool.com/?ref=stefanterdell&utm_source=github&utm_medium=referral&utm_campaign=stefanterdell" style="text-decoration:none;">retool.com</a>
|
||||
</p>
|
||||
<p></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Usage
|
||||
@@ -64,7 +53,7 @@ A great big thank you to our amazing sponsors! Please consider joining them thro
|
||||
### Basic example
|
||||
|
||||
```typescript
|
||||
import { z } from "zod";
|
||||
import { z } from "zod"; // Or, using v3.25 or v4, "zod/v3"
|
||||
import { zodToJsonSchema } from "zod-to-json-schema";
|
||||
|
||||
const mySchema = z
|
||||
@@ -394,6 +383,8 @@ This package _does not_ follow semantic versioning. The major and minor versions
|
||||
|
||||
I will do my best to keep API-breaking changes to an absolute minimum, but new features may appear as "patches", such as introducing the options pattern in 3.9.1.
|
||||
|
||||
While v3.25 supports Zod v4 as a peer-dependency, it does _not_ mean it supports v4 schemas. Use `import { z } from "zod/v3"` and refer to the Zod documentation.
|
||||
|
||||
## Changelog
|
||||
|
||||
https://github.com/StefanTerdell/zod-to-json-schema/blob/master/changelog.md
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 3.9.x | :white_check_mark: |
|
||||
| < 3.9 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Please log an issue [here](https://github.com/StefanTerdell/zod-to-json-schema/issues)
|
||||
+81
-78
@@ -1,80 +1,83 @@
|
||||
# Changelog
|
||||
|
||||
| Version | Change |
|
||||
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 3.24.6 | Removed use of instanceOf to check for optional properties as differing package versions could produce intermittent bugs. Added OpenAiAnyType to work around their schema restrictions. |
|
||||
| 3.24.5 | Update .npmignore to drop 2 mb of test files. Thanks [Misha Kaletsky](https://github.com/mmkal)! |
|
||||
| 3.24.4 | Added options to set the value of additionalProperties in objects and record |
|
||||
| 3.24.3 | Adds postProcess callback option |
|
||||
| 3.24.2 | Restructured internals to remove circular dependencies which apparently might cause some build systems to whine a bit. Big thanks to [Víctor Hernández](https://github.com/NanezX) for the fix. |
|
||||
| 3.24.1 | Adds OpenAI target |
|
||||
| 3.24.0 | Implements new string checks (jwt, base64url, cidr ipv4/v6), matching the new Zod version |
|
||||
| 3.23.5 | Module import hotfix by [Enzo Monjardín](https://github.com/enzomonjardin). Thanks! |
|
||||
| 3.23.4 | Fixes branded regex property names and a weird edgecase in arrays. Thanks to [Isaiah Marc Sanchez](https://github.com/imsanchez) and [Mitchell Merry](https://github.com/mitchell-merry)! |
|
||||
| 3.23.3 | More tests (Thanks [Brett Zamir!](https://github.com/brettz9)), removed dead code |
|
||||
| 3.23.2 | Lazily loads Emoji regex to avoid incompatibility with some environments. Thanks [Jacob Lee](https://github.com/jacoblee93)! |
|
||||
| 3.23.1 | Best-effort RegEx flag support by [Spappz](https://github.com/Spappz)! Some minor fixes and additions, such as the title option. |
|
||||
| 3.23.0 | Adds support for base64, date, time, duration and nanoid string validations. A warm welcome and a big thanks to [Colin](https://www.github.com/colinhacks), the creator of Zod, joining in as a contributor :) |
|
||||
| 3.22.5 | Adds new z.date() parsing options and override callback |
|
||||
| 3.22.4 | Adds fix for nullable references in OpenAPI mode |
|
||||
| 3.22.3 | Adjust root path from "#/" to "#" according to RFC 6901 |
|
||||
| 3.22.2 | Adds "output" pipe strategy |
|
||||
| 3.22.1 | Fixes broken imports when using some bundlers |
|
||||
| 3.22.0 | Support readonly. Export both CJS and ESM. Export everything from index. Alternative map parser. Improved pattern handling and updated sources. |
|
||||
| 3.21.4 | Fixes missing support for exact array length |
|
||||
| 3.21.3 | Fixes issue #77 (Reference path to nullable schemas in Open-API mode) |
|
||||
| 3.21.2 | Adds "integer" type Date output to support min/max checks, markdownDescription option, fixes "none" refStrategy by adding "seen" and adds an option to use "pattern" with Zods' email enum instead of "format". |
|
||||
| 3.21.1 | New target (2019-09) along with improved intersection schemas, improved mutual recursion references in definitions, descriptions respected in union parser and not removed in collapsed |
|
||||
| 3.21.0 | Added new string validations (ip, emoji, etc) and BigInt checks to support Zod 3.21 |
|
||||
| 3.20.5 | Added uniqueItems to Set and an option to disregard pipe schemas |
|
||||
| 3.20.4 | Bugfixes and improved record parsing for openApi3 |
|
||||
| 3.20.3 | Added Cuid2 support introduced in Zod 3.20.3 |
|
||||
| 3.20.2 | Reintroduced conditional simplified return-type for when target is OpenAPI 3 |
|
||||
| 3.20.1 | Fixed inconsistent casing in imports |
|
||||
| 3.20.0 | Adds support for Zod 3.20 with catch and pipe parser as well as new string validations. Refactored Ref handling; adding definitions no longer considered experimental. Main API function refactored and simplified; output type less defined but a lot easier to maintain. Doubt anyone will miss it. <br/><quote><i>Narrator: Someone did in fact miss it</i></quote> |
|
||||
| 3.19.4 | Adds custom error message support |
|
||||
| 3.19.3 | Mark `definitions` as experimental in the readme |
|
||||
| 3.19.2 | Added `definitions` option |
|
||||
| 3.19.1 | Strict unions fix |
|
||||
| 3.19.0 | No new features added in Zod, parity bump |
|
||||
| 3.18.2 | Fixes support for native enums |
|
||||
| 3.18.1 | Add strictUnions options |
|
||||
| 3.18.0 | Added support for branded types |
|
||||
| 3.17.2 | Fix for reference paths when supplying name option string. |
|
||||
| 3.17.1 | Added startsWith and endsWith string checks. Merge multiple pattern checks into allOf array. |
|
||||
| 3.17.0 | Added switch case handler for new trim "check". No changes to functionality. |
|
||||
| 3.15.x - 3.16.x | Skipped: Did not change the Zod API in any way relevant for this package. |
|
||||
| 3.14.1 | Dependabot security updates |
|
||||
| 3.14.0 | Moves Zod into peerDependencies. Supports checks for sets, NaN-type (sort of), discriminated union type and standalone optional properties (as unions with undefined) |
|
||||
| 3.12.x - 3.13.x | Skipped |
|
||||
| 3.11.3 | Joins unions of enums into single enum and allows enums as keys of records |
|
||||
| 3.11.2 | Adds option to target Open API 3 spec (paths) instead of Json Schema 7. |
|
||||
| 3.11.1 | Performance boost when using $refStrategy `none` and internal improvements. |
|
||||
| 3.11.0 | Added description support introduced in Zod 3.11.5 |
|
||||
| 3.10.x | Skipped: Minor 10 did not change the Zod API |
|
||||
| 3.9.5 | Type bug fix: used dev dependency types in package |
|
||||
| 3.9.4 | Path bug fix and test case when using optional definitions path |
|
||||
| 3.9.3 | Added option to change definition property name to $defs |
|
||||
| 3.9.2 | Added option to handle transform results as any instead of relying on their input schema. |
|
||||
| 3.9.1 | Refactored the way reference pointers are passed around and added options pattern to main function without braking backwards compatibility! You can now add a base path, change the reference strategy (or opt out), and still set the schema name inside the options object or outside as before. |
|
||||
| 3.9.0 | Added support for multipleOf number validaion, .rest() schemas for tuples and key validation for records (only compatible with string keys due to JSON Schema limitation). |
|
||||
| 3.7.x - 3.8.x | Skipped to reach functional parity with Zod versioning. |
|
||||
| 3.6.1 | Realised intersection had another potential ref pathing bug. Fixed. |
|
||||
| 3.6.0 | Added support for default & effects (refine). Broke out changelog.md |
|
||||
| 3.5.0 | Added support for CUID string validation |
|
||||
| 3.4.3 | Fixed $ref pathing for catchall and intersection. Additional tests and code structure fixes. |
|
||||
| 3.4.2 | Fixed broken intersection parser (Thanks [Noah2610](https://github.com/Noah2610)!) |
|
||||
| 3.4.1 | Fixed pathing bug for nullable items. |
|
||||
| 3.4.0 | Added support for z.lazy() |
|
||||
| 3.3.0 | Added support for catchall (additionalProperties schema on objects). Rebuilt object parser. |
|
||||
| 3.2.0 | Added support for Map and Set as seen by their most common JSON definitions. Beware no standardized definition seem to exist and JSON.parse doesn't handle either natively. Their implementations here are based on the spread approach. Also further simplified intersection definition to just allOf. |
|
||||
| 3.1.0 | String patterns finally supported! Fixed bugs include broken external type, unsafe nullable parsing, bad intersection implementation, and missing support for passthrough keys in objects. |
|
||||
| 3.0.3 | Fixed array deep pathing bug (path contained `array` instead of `items`) |
|
||||
| 3.0.2 | Fixed broken type usage (NonEmptyArrayDefinition was removed from Zod) |
|
||||
| 3.0.1 | Fixed a typo in the readme |
|
||||
| 3.0.0 | Compatible with Zod 3.2.0. Huge props to [Mr Hammad Asif](https://github.com/mrhammadasif) for his work on this. |
|
||||
| 0.6.2 | Hotfix for undefined object properties. Could crash the parser when using Pick |
|
||||
| 0.6.1 | Fixed bug in union pathing. `$Ref` was missing `/anyOf` |
|
||||
| 0.6.0 | Moved `@types/json-schema` and `typescript` to dev dependencies. `@types/json-schema` is now only used for the test suites. Using `strict: true` in ts config. |
|
||||
| 0.5.1 | First working release with all relevant Zod types present with most validations (except for string patterns due to Zod not exposing the source regexp pattern for those). |
|
||||
| < 0.5.1 | Deprecated due to broken package structure. Please be patient, I eat crayons. |
|
||||
| Version | Change |
|
||||
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 3.25.2 | Bumps the peer dependency of Zod 3 to 3.25.28 - Versions before patch 13 caused [OOM issues](https://github.com/StefanTerdell/zod-to-json-schema/issues/185) and versions between that and 28 removed the /v3 import alias. |
|
||||
| 3.25.1 | Fixes large install size due to accidental inclusion of test files. Thanks, [Felix Mosheev](https://github.com/felixmosh)! |
|
||||
| 3.25.0 | Adds support for v3.25 and v3 through v4 (`import { z } from "zod/v3"`). Big thank you to both [Andrey Gubanovs](https://github.com/finom) and especially to [Faïz Hernawan Abdillah](https://github.com/Abdillah), whose more minimal implementation was merged. This will likely be the final release of `zod-to-json-schema`, as v4 now supports JSON schema natively. |
|
||||
| 3.24.6 | Removed use of instanceOf to check for optional properties as differing package versions could produce intermittent bugs. Added OpenAiAnyType to work around their schema restrictions. |
|
||||
| 3.24.5 | Update .npmignore to drop 2 mb of test files. Thanks [Misha Kaletsky](https://github.com/mmkal)! |
|
||||
| 3.24.4 | Added options to set the value of additionalProperties in objects and record |
|
||||
| 3.24.3 | Adds postProcess callback option |
|
||||
| 3.24.2 | Restructured internals to remove circular dependencies which apparently might cause some build systems to whine a bit. Big thanks to [Víctor Hernández](https://github.com/NanezX) for the fix. |
|
||||
| 3.24.1 | Adds OpenAI target |
|
||||
| 3.24.0 | Implements new string checks (jwt, base64url, cidr ipv4/v6), matching the new Zod version |
|
||||
| 3.23.5 | Module import hotfix by [Enzo Monjardín](https://github.com/enzomonjardin). Thanks! |
|
||||
| 3.23.4 | Fixes branded regex property names and a weird edgecase in arrays. Thanks to [Isaiah Marc Sanchez](https://github.com/imsanchez) and [Mitchell Merry](https://github.com/mitchell-merry)! |
|
||||
| 3.23.3 | More tests (Thanks [Brett Zamir!](https://github.com/brettz9)), removed dead code |
|
||||
| 3.23.2 | Lazily loads Emoji regex to avoid incompatibility with some environments. Thanks [Jacob Lee](https://github.com/jacoblee93)! |
|
||||
| 3.23.1 | Best-effort RegEx flag support by [Spappz](https://github.com/Spappz)! Some minor fixes and additions, such as the title option. |
|
||||
| 3.23.0 | Adds support for base64, date, time, duration and nanoid string validations. A warm welcome and a big thanks to [Colin](https://www.github.com/colinhacks), the creator of Zod, joining in as a contributor :) |
|
||||
| 3.22.5 | Adds new z.date() parsing options and override callback |
|
||||
| 3.22.4 | Adds fix for nullable references in OpenAPI mode |
|
||||
| 3.22.3 | Adjust root path from "#/" to "#" according to RFC 6901 |
|
||||
| 3.22.2 | Adds "output" pipe strategy |
|
||||
| 3.22.1 | Fixes broken imports when using some bundlers |
|
||||
| 3.22.0 | Support readonly. Export both CJS and ESM. Export everything from index. Alternative map parser. Improved pattern handling and updated sources. |
|
||||
| 3.21.4 | Fixes missing support for exact array length |
|
||||
| 3.21.3 | Fixes issue #77 (Reference path to nullable schemas in Open-API mode) |
|
||||
| 3.21.2 | Adds "integer" type Date output to support min/max checks, markdownDescription option, fixes "none" refStrategy by adding "seen" and adds an option to use "pattern" with Zods' email enum instead of "format". |
|
||||
| 3.21.1 | New target (2019-09) along with improved intersection schemas, improved mutual recursion references in definitions, descriptions respected in union parser and not removed in collapsed |
|
||||
| 3.21.0 | Added new string validations (ip, emoji, etc) and BigInt checks to support Zod 3.21 |
|
||||
| 3.20.5 | Added uniqueItems to Set and an option to disregard pipe schemas |
|
||||
| 3.20.4 | Bugfixes and improved record parsing for openApi3 |
|
||||
| 3.20.3 | Added Cuid2 support introduced in Zod 3.20.3 |
|
||||
| 3.20.2 | Reintroduced conditional simplified return-type for when target is OpenAPI 3 |
|
||||
| 3.20.1 | Fixed inconsistent casing in imports |
|
||||
| 3.20.0 | Adds support for Zod 3.20 with catch and pipe parser as well as new string validations. Refactored Ref handling; adding definitions no longer considered experimental. Main API function refactored and simplified; output type less defined but a lot easier to maintain. Doubt anyone will miss it. <br/><quote><i>Narrator: Someone did in fact miss it</i></quote> |
|
||||
| 3.19.4 | Adds custom error message support |
|
||||
| 3.19.3 | Mark `definitions` as experimental in the readme |
|
||||
| 3.19.2 | Added `definitions` option |
|
||||
| 3.19.1 | Strict unions fix |
|
||||
| 3.19.0 | No new features added in Zod, parity bump |
|
||||
| 3.18.2 | Fixes support for native enums |
|
||||
| 3.18.1 | Add strictUnions options |
|
||||
| 3.18.0 | Added support for branded types |
|
||||
| 3.17.2 | Fix for reference paths when supplying name option string. |
|
||||
| 3.17.1 | Added startsWith and endsWith string checks. Merge multiple pattern checks into allOf array. |
|
||||
| 3.17.0 | Added switch case handler for new trim "check". No changes to functionality. |
|
||||
| 3.15.x - 3.16.x | Skipped: Did not change the Zod API in any way relevant for this package. |
|
||||
| 3.14.1 | Dependabot security updates |
|
||||
| 3.14.0 | Moves Zod into peerDependencies. Supports checks for sets, NaN-type (sort of), discriminated union type and standalone optional properties (as unions with undefined) |
|
||||
| 3.12.x - 3.13.x | Skipped |
|
||||
| 3.11.3 | Joins unions of enums into single enum and allows enums as keys of records |
|
||||
| 3.11.2 | Adds option to target Open API 3 spec (paths) instead of Json Schema 7. |
|
||||
| 3.11.1 | Performance boost when using $refStrategy `none` and internal improvements. |
|
||||
| 3.11.0 | Added description support introduced in Zod 3.11.5 |
|
||||
| 3.10.x | Skipped: Minor 10 did not change the Zod API |
|
||||
| 3.9.5 | Type bug fix: used dev dependency types in package |
|
||||
| 3.9.4 | Path bug fix and test case when using optional definitions path |
|
||||
| 3.9.3 | Added option to change definition property name to $defs |
|
||||
| 3.9.2 | Added option to handle transform results as any instead of relying on their input schema. |
|
||||
| 3.9.1 | Refactored the way reference pointers are passed around and added options pattern to main function without braking backwards compatibility! You can now add a base path, change the reference strategy (or opt out), and still set the schema name inside the options object or outside as before. |
|
||||
| 3.9.0 | Added support for multipleOf number validaion, .rest() schemas for tuples and key validation for records (only compatible with string keys due to JSON Schema limitation). |
|
||||
| 3.7.x - 3.8.x | Skipped to reach functional parity with Zod versioning. |
|
||||
| 3.6.1 | Realised intersection had another potential ref pathing bug. Fixed. |
|
||||
| 3.6.0 | Added support for default & effects (refine). Broke out changelog.md |
|
||||
| 3.5.0 | Added support for CUID string validation |
|
||||
| 3.4.3 | Fixed $ref pathing for catchall and intersection. Additional tests and code structure fixes. |
|
||||
| 3.4.2 | Fixed broken intersection parser (Thanks [Noah2610](https://github.com/Noah2610)!) |
|
||||
| 3.4.1 | Fixed pathing bug for nullable items. |
|
||||
| 3.4.0 | Added support for z.lazy() |
|
||||
| 3.3.0 | Added support for catchall (additionalProperties schema on objects). Rebuilt object parser. |
|
||||
| 3.2.0 | Added support for Map and Set as seen by their most common JSON definitions. Beware no standardized definition seem to exist and JSON.parse doesn't handle either natively. Their implementations here are based on the spread approach. Also further simplified intersection definition to just allOf. |
|
||||
| 3.1.0 | String patterns finally supported! Fixed bugs include broken external type, unsafe nullable parsing, bad intersection implementation, and missing support for passthrough keys in objects. |
|
||||
| 3.0.3 | Fixed array deep pathing bug (path contained `array` instead of `items`) |
|
||||
| 3.0.2 | Fixed broken type usage (NonEmptyArrayDefinition was removed from Zod) |
|
||||
| 3.0.1 | Fixed a typo in the readme |
|
||||
| 3.0.0 | Compatible with Zod 3.2.0. Huge props to [Mr Hammad Asif](https://github.com/mrhammadasif) for his work on this. |
|
||||
| 0.6.2 | Hotfix for undefined object properties. Could crash the parser when using Pick |
|
||||
| 0.6.1 | Fixed bug in union pathing. `$Ref` was missing `/anyOf` |
|
||||
| 0.6.0 | Moved `@types/json-schema` and `typescript` to dev dependencies. `@types/json-schema` is now only used for the test suites. Using `strict: true` in ts config. |
|
||||
| 0.5.1 | First working release with all relevant Zod types present with most validations (except for string patterns due to Zod not exposing the source regexp pattern for those). |
|
||||
| < 0.5.1 | Deprecated due to broken package structure. Please be patient, I eat crayons. |
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseArrayDef = void 0;
|
||||
const zod_1 = require("zod");
|
||||
const v3_1 = require("zod/v3");
|
||||
const errorMessages_js_1 = require("../errorMessages.js");
|
||||
const parseDef_js_1 = require("../parseDef.js");
|
||||
function parseArrayDef(def, refs) {
|
||||
@@ -9,7 +9,7 @@ function parseArrayDef(def, refs) {
|
||||
type: "array",
|
||||
};
|
||||
if (def.type?._def &&
|
||||
def.type?._def?.typeName !== zod_1.ZodFirstPartyTypeKind.ZodAny) {
|
||||
def.type?._def?.typeName !== v3_1.ZodFirstPartyTypeKind.ZodAny) {
|
||||
res.items = (0, parseDef_js_1.parseDef)(def.type._def, {
|
||||
...refs,
|
||||
currentPath: [...refs.currentPath, "items"],
|
||||
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseRecordDef = void 0;
|
||||
const zod_1 = require("zod");
|
||||
const v3_1 = require("zod/v3");
|
||||
const parseDef_js_1 = require("../parseDef.js");
|
||||
const string_js_1 = require("./string.js");
|
||||
const branded_js_1 = require("./branded.js");
|
||||
@@ -11,7 +11,7 @@ function parseRecordDef(def, refs) {
|
||||
console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
||||
}
|
||||
if (refs.target === "openApi3" &&
|
||||
def.keyType?._def.typeName === zod_1.ZodFirstPartyTypeKind.ZodEnum) {
|
||||
def.keyType?._def.typeName === v3_1.ZodFirstPartyTypeKind.ZodEnum) {
|
||||
return {
|
||||
type: "object",
|
||||
required: def.keyType._def.values,
|
||||
@@ -35,7 +35,7 @@ function parseRecordDef(def, refs) {
|
||||
if (refs.target === "openApi3") {
|
||||
return schema;
|
||||
}
|
||||
if (def.keyType?._def.typeName === zod_1.ZodFirstPartyTypeKind.ZodString &&
|
||||
if (def.keyType?._def.typeName === v3_1.ZodFirstPartyTypeKind.ZodString &&
|
||||
def.keyType._def.checks?.length) {
|
||||
const { type, ...keyType } = (0, string_js_1.parseStringDef)(def.keyType._def, refs);
|
||||
return {
|
||||
@@ -43,7 +43,7 @@ function parseRecordDef(def, refs) {
|
||||
propertyNames: keyType,
|
||||
};
|
||||
}
|
||||
else if (def.keyType?._def.typeName === zod_1.ZodFirstPartyTypeKind.ZodEnum) {
|
||||
else if (def.keyType?._def.typeName === v3_1.ZodFirstPartyTypeKind.ZodEnum) {
|
||||
return {
|
||||
...schema,
|
||||
propertyNames: {
|
||||
@@ -51,8 +51,8 @@ function parseRecordDef(def, refs) {
|
||||
},
|
||||
};
|
||||
}
|
||||
else if (def.keyType?._def.typeName === zod_1.ZodFirstPartyTypeKind.ZodBranded &&
|
||||
def.keyType._def.type._def.typeName === zod_1.ZodFirstPartyTypeKind.ZodString &&
|
||||
else if (def.keyType?._def.typeName === v3_1.ZodFirstPartyTypeKind.ZodBranded &&
|
||||
def.keyType._def.type._def.typeName === v3_1.ZodFirstPartyTypeKind.ZodString &&
|
||||
def.keyType._def.type._def.checks?.length) {
|
||||
const { type, ...keyType } = (0, branded_js_1.parseBrandedDef)(def.keyType._def, refs);
|
||||
return {
|
||||
|
||||
-1
@@ -187,7 +187,6 @@ function parseStringDef(def, refs) {
|
||||
case "trim":
|
||||
break;
|
||||
default:
|
||||
/* c8 ignore next */
|
||||
((_) => { })(check);
|
||||
}
|
||||
}
|
||||
|
||||
+37
-38
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.selectParser = void 0;
|
||||
const zod_1 = require("zod");
|
||||
const v3_1 = require("zod/v3");
|
||||
const any_js_1 = require("./parsers/any.js");
|
||||
const array_js_1 = require("./parsers/array.js");
|
||||
const bigint_js_1 = require("./parsers/bigint.js");
|
||||
@@ -34,76 +34,75 @@ const unknown_js_1 = require("./parsers/unknown.js");
|
||||
const readonly_js_1 = require("./parsers/readonly.js");
|
||||
const selectParser = (def, typeName, refs) => {
|
||||
switch (typeName) {
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodString:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodString:
|
||||
return (0, string_js_1.parseStringDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodNumber:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodNumber:
|
||||
return (0, number_js_1.parseNumberDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodObject:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodObject:
|
||||
return (0, object_js_1.parseObjectDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodBigInt:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodBigInt:
|
||||
return (0, bigint_js_1.parseBigintDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodBoolean:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodBoolean:
|
||||
return (0, boolean_js_1.parseBooleanDef)();
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodDate:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodDate:
|
||||
return (0, date_js_1.parseDateDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodUndefined:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodUndefined:
|
||||
return (0, undefined_js_1.parseUndefinedDef)(refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodNull:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodNull:
|
||||
return (0, null_js_1.parseNullDef)(refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodArray:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodArray:
|
||||
return (0, array_js_1.parseArrayDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodUnion:
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodUnion:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
||||
return (0, union_js_1.parseUnionDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodIntersection:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodIntersection:
|
||||
return (0, intersection_js_1.parseIntersectionDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodTuple:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodTuple:
|
||||
return (0, tuple_js_1.parseTupleDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodRecord:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodRecord:
|
||||
return (0, record_js_1.parseRecordDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodLiteral:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodLiteral:
|
||||
return (0, literal_js_1.parseLiteralDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodEnum:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodEnum:
|
||||
return (0, enum_js_1.parseEnumDef)(def);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodNativeEnum:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodNativeEnum:
|
||||
return (0, nativeEnum_js_1.parseNativeEnumDef)(def);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodNullable:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodNullable:
|
||||
return (0, nullable_js_1.parseNullableDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodOptional:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodOptional:
|
||||
return (0, optional_js_1.parseOptionalDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodMap:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodMap:
|
||||
return (0, map_js_1.parseMapDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodSet:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodSet:
|
||||
return (0, set_js_1.parseSetDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodLazy:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodLazy:
|
||||
return () => def.getter()._def;
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodPromise:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodPromise:
|
||||
return (0, promise_js_1.parsePromiseDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodNaN:
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodNever:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodNaN:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodNever:
|
||||
return (0, never_js_1.parseNeverDef)(refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodEffects:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodEffects:
|
||||
return (0, effects_js_1.parseEffectsDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodAny:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodAny:
|
||||
return (0, any_js_1.parseAnyDef)(refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodUnknown:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodUnknown:
|
||||
return (0, unknown_js_1.parseUnknownDef)(refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodDefault:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodDefault:
|
||||
return (0, default_js_1.parseDefaultDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodBranded:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodBranded:
|
||||
return (0, branded_js_1.parseBrandedDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodReadonly:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodReadonly:
|
||||
return (0, readonly_js_1.parseReadonlyDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodCatch:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodCatch:
|
||||
return (0, catch_js_1.parseCatchDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodPipeline:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodPipeline:
|
||||
return (0, pipeline_js_1.parsePipelineDef)(def, refs);
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodFunction:
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodVoid:
|
||||
case zod_1.ZodFirstPartyTypeKind.ZodSymbol:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodFunction:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodVoid:
|
||||
case v3_1.ZodFirstPartyTypeKind.ZodSymbol:
|
||||
return undefined;
|
||||
default:
|
||||
/* c8 ignore next */
|
||||
return ((_) => undefined)(typeName);
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodFirstPartyTypeKind } from "zod";
|
||||
import { ZodFirstPartyTypeKind } from "zod/v3";
|
||||
import { setResponseValueAndErrors } from "../errorMessages.js";
|
||||
import { parseDef } from "../parseDef.js";
|
||||
export function parseArrayDef(def, refs) {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodFirstPartyTypeKind, } from "zod";
|
||||
import { ZodFirstPartyTypeKind, } from "zod/v3";
|
||||
import { parseDef } from "../parseDef.js";
|
||||
import { parseStringDef } from "./string.js";
|
||||
import { parseBrandedDef } from "./branded.js";
|
||||
|
||||
-1
@@ -184,7 +184,6 @@ export function parseStringDef(def, refs) {
|
||||
case "trim":
|
||||
break;
|
||||
default:
|
||||
/* c8 ignore next */
|
||||
((_) => { })(check);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
import { ZodFirstPartyTypeKind } from "zod";
|
||||
import { ZodFirstPartyTypeKind } from "zod/v3";
|
||||
import { parseAnyDef } from "./parsers/any.js";
|
||||
import { parseArrayDef } from "./parsers/array.js";
|
||||
import { parseBigintDef } from "./parsers/bigint.js";
|
||||
@@ -100,7 +100,6 @@ export const selectParser = (def, typeName, refs) => {
|
||||
case ZodFirstPartyTypeKind.ZodSymbol:
|
||||
return undefined;
|
||||
default:
|
||||
/* c8 ignore next */
|
||||
return ((_) => undefined)(typeName);
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodSchema, ZodTypeDef } from "zod";
|
||||
import { ZodSchema, ZodTypeDef } from "zod/v3";
|
||||
import { Refs, Seen } from "./Refs";
|
||||
import { JsonSchema7Type } from "./parseTypes";
|
||||
export type Targets = "jsonSchema7" | "jsonSchema2019-09" | "openApi3" | "openAi";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodTypeDef } from "zod";
|
||||
import { ZodTypeDef } from "zod/v3";
|
||||
import { Options, Targets } from "./Options.js";
|
||||
import { JsonSchema7Type } from "./parseTypes.js";
|
||||
export type Refs = {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodTypeDef } from "zod";
|
||||
import { ZodTypeDef } from "zod/v3";
|
||||
import { Refs } from "./Refs.js";
|
||||
import { JsonSchema7Type } from "./parseTypes.js";
|
||||
export declare function parseDef(def: ZodTypeDef, refs: Refs, forceResolution?: boolean): JsonSchema7Type | undefined;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodArrayDef } from "zod";
|
||||
import { ZodArrayDef } from "zod/v3";
|
||||
import { ErrorMessages } from "../errorMessages.js";
|
||||
import { JsonSchema7Type } from "../parseTypes.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodBigIntDef } from "zod";
|
||||
import { ZodBigIntDef } from "zod/v3";
|
||||
import { Refs } from "../Refs.js";
|
||||
import { ErrorMessages } from "../errorMessages.js";
|
||||
export type JsonSchema7BigintType = {
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
import { ZodBrandedDef } from "zod";
|
||||
import { ZodBrandedDef } from "zod/v3";
|
||||
import { Refs } from "../Refs.js";
|
||||
export declare function parseBrandedDef(_def: ZodBrandedDef<any>, refs: Refs): import("../parseTypes.js").JsonSchema7Type | undefined;
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
import { ZodCatchDef } from "zod";
|
||||
import { ZodCatchDef } from "zod/v3";
|
||||
import { Refs } from "../Refs.js";
|
||||
export declare const parseCatchDef: (def: ZodCatchDef<any>, refs: Refs) => import("../parseTypes.js").JsonSchema7Type | undefined;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodDateDef } from "zod";
|
||||
import { ZodDateDef } from "zod/v3";
|
||||
import { Refs } from "../Refs.js";
|
||||
import { ErrorMessages } from "../errorMessages.js";
|
||||
import { JsonSchema7NumberType } from "./number.js";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodDefaultDef } from "zod";
|
||||
import { ZodDefaultDef } from "zod/v3";
|
||||
import { JsonSchema7Type } from "../parseTypes.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
export declare function parseDefaultDef(_def: ZodDefaultDef, refs: Refs): JsonSchema7Type & {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodEffectsDef } from "zod";
|
||||
import { ZodEffectsDef } from "zod/v3";
|
||||
import { JsonSchema7Type } from "../parseTypes.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
export declare function parseEffectsDef(_def: ZodEffectsDef, refs: Refs): JsonSchema7Type | undefined;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodEnumDef } from "zod";
|
||||
import { ZodEnumDef } from "zod/v3";
|
||||
export type JsonSchema7EnumType = {
|
||||
type: "string";
|
||||
enum: string[];
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodIntersectionDef } from "zod";
|
||||
import { ZodIntersectionDef } from "zod/v3";
|
||||
import { JsonSchema7Type } from "../parseTypes.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
export type JsonSchema7AllOfType = {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodLiteralDef } from "zod";
|
||||
import { ZodLiteralDef } from "zod/v3";
|
||||
import { Refs } from "../Refs.js";
|
||||
export type JsonSchema7LiteralType = {
|
||||
type: "string" | "number" | "integer" | "boolean";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodMapDef } from "zod";
|
||||
import { ZodMapDef } from "zod/v3";
|
||||
import { JsonSchema7Type } from "../parseTypes.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
import { JsonSchema7RecordType } from "./record.js";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodNativeEnumDef } from "zod";
|
||||
import { ZodNativeEnumDef } from "zod/v3";
|
||||
export type JsonSchema7NativeEnumType = {
|
||||
type: "string" | "number" | ["string", "number"];
|
||||
enum: (string | number)[];
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodNullableDef } from "zod";
|
||||
import { ZodNullableDef } from "zod/v3";
|
||||
import { JsonSchema7Type } from "../parseTypes.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
import { JsonSchema7NullType } from "./null.js";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodNumberDef } from "zod";
|
||||
import { ZodNumberDef } from "zod/v3";
|
||||
import { ErrorMessages } from "../errorMessages.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
export type JsonSchema7NumberType = {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodObjectDef } from "zod";
|
||||
import { ZodObjectDef } from "zod/v3";
|
||||
import { JsonSchema7Type } from "../parseTypes.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
export type JsonSchema7ObjectType = {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodOptionalDef } from "zod";
|
||||
import { ZodOptionalDef } from "zod/v3";
|
||||
import { JsonSchema7Type } from "../parseTypes.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
export declare const parseOptionalDef: (def: ZodOptionalDef, refs: Refs) => JsonSchema7Type | undefined;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodPipelineDef } from "zod";
|
||||
import { ZodPipelineDef } from "zod/v3";
|
||||
import { JsonSchema7Type } from "../parseTypes.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
import { JsonSchema7AllOfType } from "./intersection.js";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodPromiseDef } from "zod";
|
||||
import { ZodPromiseDef } from "zod/v3";
|
||||
import { JsonSchema7Type } from "../parseTypes.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
export declare function parsePromiseDef(def: ZodPromiseDef, refs: Refs): JsonSchema7Type | undefined;
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
import { ZodReadonlyDef } from "zod";
|
||||
import { ZodReadonlyDef } from "zod/v3";
|
||||
import { Refs } from "../Refs.js";
|
||||
export declare const parseReadonlyDef: (def: ZodReadonlyDef<any>, refs: Refs) => import("../parseTypes.js").JsonSchema7Type | undefined;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodMapDef, ZodRecordDef, ZodTypeAny } from "zod";
|
||||
import { ZodMapDef, ZodRecordDef, ZodTypeAny } from "zod/v3";
|
||||
import { JsonSchema7Type } from "../parseTypes.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
import { JsonSchema7EnumType } from "./enum.js";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodSetDef } from "zod";
|
||||
import { ZodSetDef } from "zod/v3";
|
||||
import { ErrorMessages } from "../errorMessages.js";
|
||||
import { JsonSchema7Type } from "../parseTypes.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodStringDef } from "zod";
|
||||
import { ZodStringDef } from "zod/v3";
|
||||
import { ErrorMessages } from "../errorMessages.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodTupleDef, ZodTupleItems, ZodTypeAny } from "zod";
|
||||
import { ZodTupleDef, ZodTupleItems, ZodTypeAny } from "zod/v3";
|
||||
import { JsonSchema7Type } from "../parseTypes.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
export type JsonSchema7TupleType = {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodDiscriminatedUnionDef, ZodUnionDef } from "zod";
|
||||
import { ZodDiscriminatedUnionDef, ZodUnionDef } from "zod/v3";
|
||||
import { JsonSchema7Type } from "../parseTypes.js";
|
||||
import { Refs } from "../Refs.js";
|
||||
export declare const primitiveMappings: {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodFirstPartyTypeKind } from "zod";
|
||||
import { ZodFirstPartyTypeKind } from "zod/v3";
|
||||
import { Refs } from "./Refs.js";
|
||||
import { JsonSchema7Type } from "./parseTypes.js";
|
||||
export type InnerDefGetter = () => any;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { ZodSchema } from "zod";
|
||||
import { ZodSchema } from "zod/v3";
|
||||
import { Options, Targets } from "./Options.js";
|
||||
import { JsonSchema7Type } from "./parseTypes.js";
|
||||
declare const zodToJsonSchema: <Target extends Targets = "jsonSchema7">(schema: ZodSchema<any>, options?: string | Partial<Options<Target>> | undefined) => (Target extends "jsonSchema7" ? JsonSchema7Type : object) & {
|
||||
|
||||
+16
-10
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "zod-to-json-schema",
|
||||
"version": "3.24.6",
|
||||
"version": "3.25.2",
|
||||
"description": "Converts Zod schemas to Json Schemas",
|
||||
"types": "./dist/types/index.d.ts",
|
||||
"main": "./dist/cjs/index.js",
|
||||
@@ -16,7 +16,7 @@
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build:test": "npm --prefix ./dist-test test",
|
||||
"build:test": "npm --prefix ./dist-test-v3 test && npm --prefix ./dist-test-v4 test",
|
||||
"build:types": "tsc -p tsconfig.types.json",
|
||||
"build:cjs": "tsc -p tsconfig.cjs.json && tsx postcjs.ts",
|
||||
"build:esm": "tsc -p tsconfig.esm.json && tsx postesm.ts",
|
||||
@@ -27,10 +27,14 @@
|
||||
"test": "tsx test/index.ts",
|
||||
"gen": "tsx createIndex.ts"
|
||||
},
|
||||
"c8": {
|
||||
"exclude": ["createIndex.ts", "postcjs.ts", "postesm.ts", "test"]
|
||||
},
|
||||
"keywords": ["zod", "json", "schema", "open", "api", "conversion"],
|
||||
"keywords": [
|
||||
"zod",
|
||||
"json",
|
||||
"schema",
|
||||
"open",
|
||||
"api",
|
||||
"conversion"
|
||||
],
|
||||
"author": "Stefan Terdell",
|
||||
"contributors": [
|
||||
"Hammad Asif (https://github.com/mrhammadasif)",
|
||||
@@ -53,7 +57,9 @@
|
||||
"Isaiah Marc Sanchez (https://github.com/imsanchez)",
|
||||
"Mitchell Merry (https://github.com/mitchell-merry)",
|
||||
"Enzo Monjardín (https://github.com/enzomonjardin)",
|
||||
"Víctor Hernández (https://github.com/NanezX)"
|
||||
"Víctor Hernández (https://github.com/NanezX)",
|
||||
"Faïz Hernawan Abdillah (https://github.com/Abdillah)",
|
||||
"Felix Mosheev (https://github.com/felixmosh)"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -61,7 +67,7 @@
|
||||
},
|
||||
"license": "ISC",
|
||||
"peerDependencies": {
|
||||
"zod": "^3.24.1"
|
||||
"zod": "^3.25.28 || ^4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/json-schema": "^7.0.9",
|
||||
@@ -71,9 +77,9 @@
|
||||
"ajv-formats": "^2.1.1",
|
||||
"fast-diff": "^1.3.0",
|
||||
"local-ref-resolver": "^0.2.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"rimraf": "^6.1.3",
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.1.3",
|
||||
"zod": "^3.24.1"
|
||||
"zod": "^3.25.28 || ^4"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user