zod 4.2.0-canary.20250826T000512 → 4.2.0-canary.20250826T001136
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
|
@@ -652,6 +652,18 @@ describe("toJSONSchema", () => {
|
|
|
652
652
|
`);
|
|
653
653
|
});
|
|
654
654
|
|
|
655
|
+
test("record openapi", () => {
|
|
656
|
+
const schema = z.record(z.string(), z.boolean());
|
|
657
|
+
expect(z.toJSONSchema(schema, { target: "openapi-3.0" })).toMatchInlineSnapshot(`
|
|
658
|
+
{
|
|
659
|
+
"additionalProperties": {
|
|
660
|
+
"type": "boolean",
|
|
661
|
+
},
|
|
662
|
+
"type": "object",
|
|
663
|
+
}
|
|
664
|
+
`);
|
|
665
|
+
});
|
|
666
|
+
|
|
655
667
|
test("tuple", () => {
|
|
656
668
|
const schema = z.tuple([z.string(), z.number()]);
|
|
657
669
|
expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
|
|
@@ -421,7 +421,7 @@ export class JSONSchemaGenerator {
|
|
|
421
421
|
case "record": {
|
|
422
422
|
const json: JSONSchema.ObjectSchema = _json as any;
|
|
423
423
|
json.type = "object";
|
|
424
|
-
if (this.target
|
|
424
|
+
if (this.target === "draft-7" || this.target === "draft-2020-12") {
|
|
425
425
|
json.propertyNames = this.process(def.keyType, {
|
|
426
426
|
...params,
|
|
427
427
|
path: [...params.path, "propertyNames"],
|
|
@@ -335,7 +335,7 @@ class JSONSchemaGenerator {
|
|
|
335
335
|
case "record": {
|
|
336
336
|
const json = _json;
|
|
337
337
|
json.type = "object";
|
|
338
|
-
if (this.target
|
|
338
|
+
if (this.target === "draft-7" || this.target === "draft-2020-12") {
|
|
339
339
|
json.propertyNames = this.process(def.keyType, {
|
|
340
340
|
...params,
|
|
341
341
|
path: [...params.path, "propertyNames"],
|
|
@@ -331,7 +331,7 @@ export class JSONSchemaGenerator {
|
|
|
331
331
|
case "record": {
|
|
332
332
|
const json = _json;
|
|
333
333
|
json.type = "object";
|
|
334
|
-
if (this.target
|
|
334
|
+
if (this.target === "draft-7" || this.target === "draft-2020-12") {
|
|
335
335
|
json.propertyNames = this.process(def.keyType, {
|
|
336
336
|
...params,
|
|
337
337
|
path: [...params.path, "propertyNames"],
|