zod 4.2.0-canary.20250826T001136 → 4.2.0-canary.20250826T001214

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "4.2.0-canary.20250826T001136",
3
+ "version": "4.2.0-canary.20250826T001214",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Colin McDonnell <zod@colinhacks.com>",
@@ -571,6 +571,19 @@ describe("toJSONSchema", () => {
571
571
  `);
572
572
  });
573
573
 
574
+ test("number with exclusive min-max openapi", () => {
575
+ const schema = z.number().lt(100).gt(1);
576
+ expect(z.toJSONSchema(schema, { target: "openapi-3.0" })).toMatchInlineSnapshot(`
577
+ {
578
+ "exclusiveMaximum": true,
579
+ "exclusiveMinimum": true,
580
+ "maximum": 100,
581
+ "minimum": 1,
582
+ "type": "number",
583
+ }
584
+ `);
585
+ });
586
+
574
587
  test("arrays", () => {
575
588
  expect(z.toJSONSchema(z.array(z.string()))).toMatchInlineSnapshot(`
576
589
  {
@@ -183,7 +183,7 @@ export class JSONSchemaGenerator {
183
183
  else json.type = "number";
184
184
 
185
185
  if (typeof exclusiveMinimum === "number") {
186
- if (this.target === "draft-4") {
186
+ if (this.target === "draft-4" || this.target === "openapi-3.0") {
187
187
  json.minimum = exclusiveMinimum;
188
188
  json.exclusiveMinimum = true;
189
189
  } else {
@@ -199,7 +199,7 @@ export class JSONSchemaGenerator {
199
199
  }
200
200
 
201
201
  if (typeof exclusiveMaximum === "number") {
202
- if (this.target === "draft-4") {
202
+ if (this.target === "draft-4" || this.target === "openapi-3.0") {
203
203
  json.maximum = exclusiveMaximum;
204
204
  json.exclusiveMaximum = true;
205
205
  } else {
@@ -101,7 +101,7 @@ class JSONSchemaGenerator {
101
101
  else
102
102
  json.type = "number";
103
103
  if (typeof exclusiveMinimum === "number") {
104
- if (this.target === "draft-4") {
104
+ if (this.target === "draft-4" || this.target === "openapi-3.0") {
105
105
  json.minimum = exclusiveMinimum;
106
106
  json.exclusiveMinimum = true;
107
107
  }
@@ -119,7 +119,7 @@ class JSONSchemaGenerator {
119
119
  }
120
120
  }
121
121
  if (typeof exclusiveMaximum === "number") {
122
- if (this.target === "draft-4") {
122
+ if (this.target === "draft-4" || this.target === "openapi-3.0") {
123
123
  json.maximum = exclusiveMaximum;
124
124
  json.exclusiveMaximum = true;
125
125
  }
@@ -97,7 +97,7 @@ export class JSONSchemaGenerator {
97
97
  else
98
98
  json.type = "number";
99
99
  if (typeof exclusiveMinimum === "number") {
100
- if (this.target === "draft-4") {
100
+ if (this.target === "draft-4" || this.target === "openapi-3.0") {
101
101
  json.minimum = exclusiveMinimum;
102
102
  json.exclusiveMinimum = true;
103
103
  }
@@ -115,7 +115,7 @@ export class JSONSchemaGenerator {
115
115
  }
116
116
  }
117
117
  if (typeof exclusiveMaximum === "number") {
118
- if (this.target === "draft-4") {
118
+ if (this.target === "draft-4" || this.target === "openapi-3.0") {
119
119
  json.maximum = exclusiveMaximum;
120
120
  json.exclusiveMaximum = true;
121
121
  }