zod 4.2.0-canary.20250825T230433 → 4.2.0-canary.20250825T235836
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/v4/classic/tests/to-json-schema.test.ts +23 -19
- package/src/v4/core/to-json-schema.ts +4 -2
- package/src/v4/core/versions.ts +1 -1
- package/v4/core/to-json-schema.cjs +4 -2
- package/v4/core/to-json-schema.js +4 -2
- package/v4/core/versions.cjs +1 -1
- package/v4/core/versions.js +1 -1
package/package.json
CHANGED
|
@@ -695,14 +695,16 @@ describe("toJSONSchema", () => {
|
|
|
695
695
|
const schema = z.tuple([z.string(), z.number()]);
|
|
696
696
|
expect(z.toJSONSchema(schema, { target: "openapi-3.0" })).toMatchInlineSnapshot(`
|
|
697
697
|
{
|
|
698
|
-
"items":
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
698
|
+
"items": {
|
|
699
|
+
"anyOf": [
|
|
700
|
+
{
|
|
701
|
+
"type": "string",
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
"type": "number",
|
|
705
|
+
},
|
|
706
|
+
],
|
|
707
|
+
},
|
|
706
708
|
"maxItems": 2,
|
|
707
709
|
"minItems": 2,
|
|
708
710
|
"type": "array",
|
|
@@ -714,17 +716,19 @@ describe("toJSONSchema", () => {
|
|
|
714
716
|
const schema = z.tuple([z.string(), z.number()]).rest(z.boolean());
|
|
715
717
|
expect(z.toJSONSchema(schema, { target: "openapi-3.0" })).toMatchInlineSnapshot(`
|
|
716
718
|
{
|
|
717
|
-
"items":
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
719
|
+
"items": {
|
|
720
|
+
"anyOf": [
|
|
721
|
+
{
|
|
722
|
+
"type": "string",
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
"type": "number",
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
"type": "boolean",
|
|
729
|
+
},
|
|
730
|
+
],
|
|
731
|
+
},
|
|
728
732
|
"minItems": 2,
|
|
729
733
|
"type": "array",
|
|
730
734
|
}
|
|
@@ -384,9 +384,11 @@ export class JSONSchemaGenerator {
|
|
|
384
384
|
json.items = rest;
|
|
385
385
|
}
|
|
386
386
|
} else if (this.target === "openapi-3.0") {
|
|
387
|
-
json.items =
|
|
387
|
+
json.items = {
|
|
388
|
+
anyOf: [...prefixItems],
|
|
389
|
+
};
|
|
388
390
|
if (rest) {
|
|
389
|
-
json.items.push(rest);
|
|
391
|
+
json.items.anyOf!.push(rest);
|
|
390
392
|
}
|
|
391
393
|
json.minItems = prefixItems.length;
|
|
392
394
|
if (!rest) {
|
package/src/v4/core/versions.ts
CHANGED
|
@@ -302,9 +302,11 @@ class JSONSchemaGenerator {
|
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
else if (this.target === "openapi-3.0") {
|
|
305
|
-
json.items =
|
|
305
|
+
json.items = {
|
|
306
|
+
anyOf: [...prefixItems],
|
|
307
|
+
};
|
|
306
308
|
if (rest) {
|
|
307
|
-
json.items.push(rest);
|
|
309
|
+
json.items.anyOf.push(rest);
|
|
308
310
|
}
|
|
309
311
|
json.minItems = prefixItems.length;
|
|
310
312
|
if (!rest) {
|
|
@@ -298,9 +298,11 @@ export class JSONSchemaGenerator {
|
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
else if (this.target === "openapi-3.0") {
|
|
301
|
-
json.items =
|
|
301
|
+
json.items = {
|
|
302
|
+
anyOf: [...prefixItems],
|
|
303
|
+
};
|
|
302
304
|
if (rest) {
|
|
303
|
-
json.items.push(rest);
|
|
305
|
+
json.items.anyOf.push(rest);
|
|
304
306
|
}
|
|
305
307
|
json.minItems = prefixItems.length;
|
|
306
308
|
if (!rest) {
|
package/v4/core/versions.cjs
CHANGED
package/v4/core/versions.js
CHANGED