zod-openapi 4.2.0 → 4.2.1
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/dist/components.chunk.cjs +11 -2
- package/dist/components.chunk.mjs +11 -2
- package/dist/extend.cjs +4 -0
- package/dist/extend.d.mts +1 -1
- package/dist/extend.d.ts +1 -1
- package/dist/extend.mjs +5 -0
- package/dist/extendZod.chunk.cjs +12 -11
- package/dist/extendZod.chunk.mjs +12 -11
- package/dist/extendZod.d.ts +0 -1
- package/dist/extendZodTypes.chunk.cjs +5 -0
- package/dist/extendZodTypes.chunk.mjs +6 -0
- package/dist/extendZodTypes.d.ts +6 -2
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const extendZodTypes = require("./extendZodTypes.chunk.cjs");
|
|
2
3
|
const isZodType = (zodType, typeName) => {
|
|
3
4
|
var _a;
|
|
4
5
|
return ((_a = zodType == null ? void 0 : zodType._def) == null ? void 0 : _a.typeName) === typeName;
|
|
@@ -1538,8 +1539,16 @@ const createSchemaOrRef = (zodSchema, state, onlyRef) => {
|
|
|
1538
1539
|
if (existingRef) {
|
|
1539
1540
|
return existingRef;
|
|
1540
1541
|
}
|
|
1541
|
-
const previous = ((_a = zodSchema._def.zodOpenApi) == null ? void 0 : _a.
|
|
1542
|
-
|
|
1542
|
+
const previous = ((_a = zodSchema._def.zodOpenApi) == null ? void 0 : _a[extendZodTypes.previousSymbol]) ? createSchemaOrRef(
|
|
1543
|
+
zodSchema._def.zodOpenApi[extendZodTypes.previousSymbol],
|
|
1544
|
+
state,
|
|
1545
|
+
true
|
|
1546
|
+
) : void 0;
|
|
1547
|
+
const current = ((_b = zodSchema._def.zodOpenApi) == null ? void 0 : _b[extendZodTypes.currentSymbol]) && zodSchema._def.zodOpenApi[extendZodTypes.currentSymbol] !== zodSchema ? createSchemaOrRef(
|
|
1548
|
+
zodSchema._def.zodOpenApi[extendZodTypes.currentSymbol],
|
|
1549
|
+
state,
|
|
1550
|
+
true
|
|
1551
|
+
) : void 0;
|
|
1543
1552
|
const ref = ((_d = (_c = zodSchema._def.zodOpenApi) == null ? void 0 : _c.openapi) == null ? void 0 : _d.ref) ?? (component == null ? void 0 : component.ref);
|
|
1544
1553
|
if (ref) {
|
|
1545
1554
|
return current ? createNewSchema({ zodSchema, previous: current, state }) : createNewRef({ ref, zodSchema, previous, state });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { previousSymbol, currentSymbol } from "./extendZodTypes.chunk.mjs";
|
|
1
2
|
const isZodType = (zodType, typeName) => {
|
|
2
3
|
var _a;
|
|
3
4
|
return ((_a = zodType == null ? void 0 : zodType._def) == null ? void 0 : _a.typeName) === typeName;
|
|
@@ -1537,8 +1538,16 @@ const createSchemaOrRef = (zodSchema, state, onlyRef) => {
|
|
|
1537
1538
|
if (existingRef) {
|
|
1538
1539
|
return existingRef;
|
|
1539
1540
|
}
|
|
1540
|
-
const previous = ((_a = zodSchema._def.zodOpenApi) == null ? void 0 : _a
|
|
1541
|
-
|
|
1541
|
+
const previous = ((_a = zodSchema._def.zodOpenApi) == null ? void 0 : _a[previousSymbol]) ? createSchemaOrRef(
|
|
1542
|
+
zodSchema._def.zodOpenApi[previousSymbol],
|
|
1543
|
+
state,
|
|
1544
|
+
true
|
|
1545
|
+
) : void 0;
|
|
1546
|
+
const current = ((_b = zodSchema._def.zodOpenApi) == null ? void 0 : _b[currentSymbol]) && zodSchema._def.zodOpenApi[currentSymbol] !== zodSchema ? createSchemaOrRef(
|
|
1547
|
+
zodSchema._def.zodOpenApi[currentSymbol],
|
|
1548
|
+
state,
|
|
1549
|
+
true
|
|
1550
|
+
) : void 0;
|
|
1542
1551
|
const ref = ((_d = (_c = zodSchema._def.zodOpenApi) == null ? void 0 : _c.openapi) == null ? void 0 : _d.ref) ?? (component == null ? void 0 : component.ref);
|
|
1543
1552
|
if (ref) {
|
|
1544
1553
|
return current ? createNewSchema({ zodSchema, previous: current, state }) : createNewRef({ ref, zodSchema, previous, state });
|
package/dist/extend.cjs
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
3
|
const zod = require("zod");
|
|
3
4
|
const extendZod = require("./extendZod.chunk.cjs");
|
|
5
|
+
const extendZodTypes = require("./extendZodTypes.chunk.cjs");
|
|
4
6
|
extendZod.extendZodWithOpenApi(zod.z);
|
|
7
|
+
exports.currentSymbol = extendZodTypes.currentSymbol;
|
|
8
|
+
exports.previousSymbol = extendZodTypes.previousSymbol;
|
package/dist/extend.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { currentSymbol, previousSymbol } from './extendZodTypes.js';
|
package/dist/extend.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { currentSymbol, previousSymbol } from './extendZodTypes.js';
|
package/dist/extend.mjs
CHANGED
package/dist/extendZod.chunk.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const extendZodTypes = require("./extendZodTypes.chunk.cjs");
|
|
2
3
|
const mergeOpenApi = (openapi, {
|
|
3
4
|
ref: _ref,
|
|
4
5
|
refType: _refType,
|
|
@@ -24,9 +25,9 @@ function extendZodWithOpenApi(zod) {
|
|
|
24
25
|
)
|
|
25
26
|
}
|
|
26
27
|
});
|
|
27
|
-
result._def.zodOpenApi.
|
|
28
|
+
result._def.zodOpenApi[extendZodTypes.currentSymbol] = result;
|
|
28
29
|
if (zodOpenApi) {
|
|
29
|
-
result._def.zodOpenApi.
|
|
30
|
+
result._def.zodOpenApi[extendZodTypes.previousSymbol] = this;
|
|
30
31
|
}
|
|
31
32
|
return result;
|
|
32
33
|
};
|
|
@@ -37,13 +38,13 @@ function extendZodWithOpenApi(zod) {
|
|
|
37
38
|
if (def.zodOpenApi) {
|
|
38
39
|
const cloned = { ...def.zodOpenApi };
|
|
39
40
|
cloned.openapi = mergeOpenApi({ description: args[0] }, cloned.openapi);
|
|
40
|
-
cloned.
|
|
41
|
-
cloned.
|
|
41
|
+
cloned[extendZodTypes.previousSymbol] = this;
|
|
42
|
+
cloned[extendZodTypes.currentSymbol] = result;
|
|
42
43
|
def.zodOpenApi = cloned;
|
|
43
44
|
} else {
|
|
44
45
|
def.zodOpenApi = {
|
|
45
46
|
openapi: { description: args[0] },
|
|
46
|
-
|
|
47
|
+
[extendZodTypes.currentSymbol]: result
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
return result;
|
|
@@ -55,11 +56,11 @@ function extendZodWithOpenApi(zod) {
|
|
|
55
56
|
if (zodOpenApi) {
|
|
56
57
|
const cloned = { ...zodOpenApi };
|
|
57
58
|
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
58
|
-
cloned.
|
|
59
|
+
cloned[extendZodTypes.previousSymbol] = this;
|
|
59
60
|
extendResult._def.zodOpenApi = cloned;
|
|
60
61
|
} else {
|
|
61
62
|
extendResult._def.zodOpenApi = {
|
|
62
|
-
|
|
63
|
+
[extendZodTypes.previousSymbol]: this
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
66
|
return extendResult;
|
|
@@ -71,8 +72,8 @@ function extendZodWithOpenApi(zod) {
|
|
|
71
72
|
if (zodOpenApi) {
|
|
72
73
|
const cloned = { ...zodOpenApi };
|
|
73
74
|
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
74
|
-
delete cloned.
|
|
75
|
-
delete cloned.
|
|
75
|
+
delete cloned[extendZodTypes.previousSymbol];
|
|
76
|
+
delete cloned[extendZodTypes.currentSymbol];
|
|
76
77
|
omitResult._def.zodOpenApi = cloned;
|
|
77
78
|
}
|
|
78
79
|
return omitResult;
|
|
@@ -84,8 +85,8 @@ function extendZodWithOpenApi(zod) {
|
|
|
84
85
|
if (zodOpenApi) {
|
|
85
86
|
const cloned = { ...zodOpenApi };
|
|
86
87
|
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
87
|
-
delete cloned.
|
|
88
|
-
delete cloned.
|
|
88
|
+
delete cloned[extendZodTypes.previousSymbol];
|
|
89
|
+
delete cloned[extendZodTypes.currentSymbol];
|
|
89
90
|
pickResult._def.zodOpenApi = cloned;
|
|
90
91
|
}
|
|
91
92
|
return pickResult;
|
package/dist/extendZod.chunk.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { currentSymbol, previousSymbol } from "./extendZodTypes.chunk.mjs";
|
|
1
2
|
const mergeOpenApi = (openapi, {
|
|
2
3
|
ref: _ref,
|
|
3
4
|
refType: _refType,
|
|
@@ -23,9 +24,9 @@ function extendZodWithOpenApi(zod) {
|
|
|
23
24
|
)
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
|
-
result._def.zodOpenApi
|
|
27
|
+
result._def.zodOpenApi[currentSymbol] = result;
|
|
27
28
|
if (zodOpenApi) {
|
|
28
|
-
result._def.zodOpenApi
|
|
29
|
+
result._def.zodOpenApi[previousSymbol] = this;
|
|
29
30
|
}
|
|
30
31
|
return result;
|
|
31
32
|
};
|
|
@@ -36,13 +37,13 @@ function extendZodWithOpenApi(zod) {
|
|
|
36
37
|
if (def.zodOpenApi) {
|
|
37
38
|
const cloned = { ...def.zodOpenApi };
|
|
38
39
|
cloned.openapi = mergeOpenApi({ description: args[0] }, cloned.openapi);
|
|
39
|
-
cloned
|
|
40
|
-
cloned
|
|
40
|
+
cloned[previousSymbol] = this;
|
|
41
|
+
cloned[currentSymbol] = result;
|
|
41
42
|
def.zodOpenApi = cloned;
|
|
42
43
|
} else {
|
|
43
44
|
def.zodOpenApi = {
|
|
44
45
|
openapi: { description: args[0] },
|
|
45
|
-
|
|
46
|
+
[currentSymbol]: result
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
return result;
|
|
@@ -54,11 +55,11 @@ function extendZodWithOpenApi(zod) {
|
|
|
54
55
|
if (zodOpenApi) {
|
|
55
56
|
const cloned = { ...zodOpenApi };
|
|
56
57
|
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
57
|
-
cloned
|
|
58
|
+
cloned[previousSymbol] = this;
|
|
58
59
|
extendResult._def.zodOpenApi = cloned;
|
|
59
60
|
} else {
|
|
60
61
|
extendResult._def.zodOpenApi = {
|
|
61
|
-
|
|
62
|
+
[previousSymbol]: this
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
65
|
return extendResult;
|
|
@@ -70,8 +71,8 @@ function extendZodWithOpenApi(zod) {
|
|
|
70
71
|
if (zodOpenApi) {
|
|
71
72
|
const cloned = { ...zodOpenApi };
|
|
72
73
|
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
73
|
-
delete cloned
|
|
74
|
-
delete cloned
|
|
74
|
+
delete cloned[previousSymbol];
|
|
75
|
+
delete cloned[currentSymbol];
|
|
75
76
|
omitResult._def.zodOpenApi = cloned;
|
|
76
77
|
}
|
|
77
78
|
return omitResult;
|
|
@@ -83,8 +84,8 @@ function extendZodWithOpenApi(zod) {
|
|
|
83
84
|
if (zodOpenApi) {
|
|
84
85
|
const cloned = { ...zodOpenApi };
|
|
85
86
|
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
86
|
-
delete cloned
|
|
87
|
-
delete cloned
|
|
87
|
+
delete cloned[previousSymbol];
|
|
88
|
+
delete cloned[currentSymbol];
|
|
88
89
|
pickResult._def.zodOpenApi = cloned;
|
|
89
90
|
}
|
|
90
91
|
return pickResult;
|
package/dist/extendZod.d.ts
CHANGED
package/dist/extendZodTypes.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { ParameterObject, ExampleObject, ReferenceObject, HeaderObject, SchemaOb
|
|
|
5
5
|
|
|
6
6
|
type SchemaObject = SchemaObject$1 & SchemaObject$2;
|
|
7
7
|
type ReplaceDate<T> = T extends Date ? Date | string : T;
|
|
8
|
+
declare const currentSymbol: unique symbol;
|
|
9
|
+
declare const previousSymbol: unique symbol;
|
|
8
10
|
/**
|
|
9
11
|
* zod-openapi metadata
|
|
10
12
|
*/
|
|
@@ -64,12 +66,12 @@ interface ZodOpenApiMetadataDef {
|
|
|
64
66
|
/**
|
|
65
67
|
* Used to keep track of the Zod Schema had `.openapi` called on it
|
|
66
68
|
*/
|
|
67
|
-
|
|
69
|
+
[currentSymbol]?: ZodTypeAny;
|
|
68
70
|
/**
|
|
69
71
|
* Used to keep track of the previous Zod Schema that had `.openapi` called on it if another `.openapi` is called.
|
|
70
72
|
* This can also be present when .extend is called on an object.
|
|
71
73
|
*/
|
|
72
|
-
|
|
74
|
+
[previousSymbol]?: ZodTypeAny;
|
|
73
75
|
}
|
|
74
76
|
interface ZodOpenApiExtendMetadata {
|
|
75
77
|
extends: ZodObject<any, any, any, any, any>;
|
|
@@ -88,3 +90,5 @@ declare module 'zod' {
|
|
|
88
90
|
extendMetadata?: ZodOpenApiExtendMetadata;
|
|
89
91
|
}
|
|
90
92
|
}
|
|
93
|
+
|
|
94
|
+
export { currentSymbol, previousSymbol };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod-openapi",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "Convert Zod Schemas to OpenAPI v3.x documentation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -97,6 +97,6 @@
|
|
|
97
97
|
"entryPoint": "src/index.ts",
|
|
98
98
|
"template": "oss-npm-package",
|
|
99
99
|
"type": "package",
|
|
100
|
-
"version": "9.
|
|
100
|
+
"version": "9.1.0"
|
|
101
101
|
}
|
|
102
102
|
}
|