zod-openapi 4.2.4 → 5.0.0-beta.0
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/README.md +72 -205
- package/dist/api.cjs +4 -4
- package/dist/api.d.mts +5 -3
- package/dist/api.d.ts +5 -3
- package/dist/api.mjs +5 -5
- package/dist/components.chunk.cjs +908 -2292
- package/dist/components.chunk.mjs +908 -2292
- package/dist/create/components.d.ts +81 -120
- package/dist/create/content.d.ts +8 -6
- package/dist/create/document.d.ts +39 -32
- package/dist/create/object.d.ts +5 -0
- package/dist/create/parameters.d.ts +12 -7
- package/dist/create/schema/schema.d.ts +21 -0
- package/dist/index.cjs +18 -55
- package/dist/index.d.mts +4 -6
- package/dist/index.d.ts +4 -6
- package/dist/index.mjs +20 -56
- package/dist/openapi.d.ts +3 -2
- package/dist/openapi3-ts/dist/model/openapi31.d.ts +6 -1
- package/dist/openapi3-ts/{dist/oas31.d.ts → oas31.d.ts} +3 -3
- package/dist/zod.d.ts +49 -0
- package/package.json +11 -11
- package/dist/create/schema/single.d.ts +0 -32
- package/dist/extend.cjs +0 -4
- package/dist/extend.d.mts +0 -1
- package/dist/extend.d.ts +0 -1
- package/dist/extend.mjs +0 -3
- package/dist/extendZod.chunk.cjs +0 -95
- package/dist/extendZod.chunk.mjs +0 -96
- package/dist/extendZod.d.ts +0 -6
- package/dist/extendZodSymbols.chunk.cjs +0 -5
- package/dist/extendZodSymbols.chunk.mjs +0 -6
- package/dist/extendZodSymbols.d.ts +0 -4
- package/dist/extendZodTypes.d.ts +0 -91
- package/dist/openapi3-ts/dist/model/openapi30.d.ts +0 -290
- package/dist/openapi3-ts/dist/oas30.d.ts +0 -3
- package/extend/index.d.ts +0 -1
- package/extend/package.json +0 -5
package/dist/zod.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { core } from 'zod/v4';
|
|
2
|
+
import { ParameterObject, HeaderObject, SchemaObject } from './openapi3-ts/dist/model/openapi31.js';
|
|
3
|
+
|
|
4
|
+
type Override = (ctx: {
|
|
5
|
+
zodSchema: core.$ZodTypes;
|
|
6
|
+
jsonSchema: core.JSONSchema.BaseSchema;
|
|
7
|
+
io: 'input' | 'output';
|
|
8
|
+
}) => void;
|
|
9
|
+
declare const isAnyZodType: (schema: unknown) => schema is core.$ZodTypes;
|
|
10
|
+
declare module 'zod/v4' {
|
|
11
|
+
interface GlobalMeta {
|
|
12
|
+
/**
|
|
13
|
+
* Used to set metadata for a parameter
|
|
14
|
+
*/
|
|
15
|
+
param?: Partial<ParameterObject> & {
|
|
16
|
+
/**
|
|
17
|
+
* Used to output this Zod Schema in the components parameters section. Any usage of this Zod Schema will then be transformed into a $ref.
|
|
18
|
+
*/
|
|
19
|
+
id?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Used to set metadata for a response header
|
|
23
|
+
*/
|
|
24
|
+
header?: Partial<HeaderObject> & {
|
|
25
|
+
/**
|
|
26
|
+
* Used to output this Zod Schema in the components headers section. Any usage of this Zod Schema will then be transformed into a $ref.
|
|
27
|
+
*/
|
|
28
|
+
id?: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Use to override the rendered schema
|
|
32
|
+
*/
|
|
33
|
+
override?: SchemaObject | Override;
|
|
34
|
+
/**
|
|
35
|
+
* For use only if this Zod Schema is manually registered in the `components` section
|
|
36
|
+
* and is not used anywhere else in the document.
|
|
37
|
+
* Defaults to `output` if not specified.
|
|
38
|
+
*/
|
|
39
|
+
unusedIO?: 'input' | 'output';
|
|
40
|
+
/**
|
|
41
|
+
* An alternate id to use for this schema in the event the schema is used in both input and output contexts.
|
|
42
|
+
* If not specified, the id will be simply derived as the id of the schema plus an `Output` suffix. Please note that `id` must be set.
|
|
43
|
+
*/
|
|
44
|
+
outputId?: string;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { isAnyZodType };
|
|
49
|
+
export type { Override };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod-openapi",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-beta.0",
|
|
4
4
|
"description": "Convert Zod Schemas to OpenAPI v3.x documentation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -72,20 +72,20 @@
|
|
|
72
72
|
"test:watch": "skuba test --watch"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@arethetypeswrong/cli": "0.
|
|
76
|
-
"@crackle/cli": "0.
|
|
77
|
-
"@redocly/cli": "1.34.
|
|
78
|
-
"@types/node": "
|
|
75
|
+
"@arethetypeswrong/cli": "0.18.1",
|
|
76
|
+
"@crackle/cli": "0.16.0",
|
|
77
|
+
"@redocly/cli": "1.34.3",
|
|
78
|
+
"@types/node": "22.15.21",
|
|
79
79
|
"eslint-plugin-zod-openapi": "1.0.0",
|
|
80
|
-
"openapi3-ts": "4.
|
|
81
|
-
"skuba": "
|
|
82
|
-
"yaml": "2.
|
|
83
|
-
"zod": "3.
|
|
80
|
+
"openapi3-ts": "4.5.0",
|
|
81
|
+
"skuba": "11.0.1",
|
|
82
|
+
"yaml": "2.8.0",
|
|
83
|
+
"zod": "3.25.67"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"zod": "^3.21.4"
|
|
87
87
|
},
|
|
88
|
-
"packageManager": "pnpm@
|
|
88
|
+
"packageManager": "pnpm@10.11.0",
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=18"
|
|
91
91
|
},
|
|
@@ -97,6 +97,6 @@
|
|
|
97
97
|
"entryPoint": "src/index.ts",
|
|
98
98
|
"template": "oss-npm-package",
|
|
99
99
|
"type": "package",
|
|
100
|
-
"version": "
|
|
100
|
+
"version": "11.0.0"
|
|
101
101
|
}
|
|
102
102
|
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ZodType } from 'zod';
|
|
2
|
-
import { OpenApiVersion } from '../../openapi.js';
|
|
3
|
-
import { SchemaObject } from '../../openapi3-ts/dist/model/openapi30.js';
|
|
4
|
-
import { SchemaObject as SchemaObject$1, ReferenceObject } from '../../openapi3-ts/dist/model/openapi31.js';
|
|
5
|
-
import { CreationType } from '../components.js';
|
|
6
|
-
import { CreateDocumentOptions } from '../document.js';
|
|
7
|
-
|
|
8
|
-
interface SchemaResult {
|
|
9
|
-
schema: SchemaObject | SchemaObject$1 | ReferenceObject;
|
|
10
|
-
components?: Record<string, SchemaObject | SchemaObject$1 | ReferenceObject> | undefined;
|
|
11
|
-
}
|
|
12
|
-
interface CreateSchemaOptions extends CreateDocumentOptions {
|
|
13
|
-
/**
|
|
14
|
-
* This controls whether this should be rendered as a request (`input`) or response (`output`). Defaults to `output`
|
|
15
|
-
*/
|
|
16
|
-
schemaType?: CreationType;
|
|
17
|
-
/**
|
|
18
|
-
* OpenAPI version to use, defaults to `'3.1.0'`
|
|
19
|
-
*/
|
|
20
|
-
openapi?: OpenApiVersion;
|
|
21
|
-
/**
|
|
22
|
-
* Additional components to use and create while rendering the schema
|
|
23
|
-
*/
|
|
24
|
-
components?: Record<string, ZodType>;
|
|
25
|
-
/**
|
|
26
|
-
* The $ref path to use for the component. Defaults to `#/components/schemas/`
|
|
27
|
-
*/
|
|
28
|
-
componentRefPath?: string;
|
|
29
|
-
}
|
|
30
|
-
declare const createSchema: (zodType: ZodType, opts?: CreateSchemaOptions) => SchemaResult;
|
|
31
|
-
|
|
32
|
-
export { type CreateSchemaOptions, type SchemaResult, createSchema };
|
package/dist/extend.cjs
DELETED
package/dist/extend.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './extendZodTypes.js';
|
package/dist/extend.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './extendZodTypes.js';
|
package/dist/extend.mjs
DELETED
package/dist/extendZod.chunk.cjs
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const extendZodSymbols = require("./extendZodSymbols.chunk.cjs");
|
|
3
|
-
const mergeOpenApi = (openapi, {
|
|
4
|
-
ref: _ref,
|
|
5
|
-
refType: _refType,
|
|
6
|
-
param: _param,
|
|
7
|
-
header: _header,
|
|
8
|
-
...rest
|
|
9
|
-
} = {}) => ({
|
|
10
|
-
...rest,
|
|
11
|
-
...openapi
|
|
12
|
-
});
|
|
13
|
-
function extendZodWithOpenApi(zod) {
|
|
14
|
-
if (typeof zod.ZodType.prototype.openapi !== "undefined") {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
zod.ZodType.prototype.openapi = function(openapi) {
|
|
18
|
-
const { zodOpenApi, ...rest } = this._def;
|
|
19
|
-
const result = new this.constructor({
|
|
20
|
-
...rest,
|
|
21
|
-
zodOpenApi: {
|
|
22
|
-
openapi: mergeOpenApi(
|
|
23
|
-
openapi,
|
|
24
|
-
zodOpenApi == null ? void 0 : zodOpenApi.openapi
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
result._def.zodOpenApi[extendZodSymbols.currentSymbol] = result;
|
|
29
|
-
if (zodOpenApi) {
|
|
30
|
-
result._def.zodOpenApi[extendZodSymbols.previousSymbol] = this;
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
const zodDescribe = zod.ZodType.prototype.describe;
|
|
35
|
-
zod.ZodType.prototype.describe = function(...args) {
|
|
36
|
-
const result = zodDescribe.apply(this, args);
|
|
37
|
-
const def = result._def;
|
|
38
|
-
if (def.zodOpenApi) {
|
|
39
|
-
const cloned = { ...def.zodOpenApi };
|
|
40
|
-
cloned.openapi = mergeOpenApi({ description: args[0] }, cloned.openapi);
|
|
41
|
-
cloned[extendZodSymbols.previousSymbol] = this;
|
|
42
|
-
cloned[extendZodSymbols.currentSymbol] = result;
|
|
43
|
-
def.zodOpenApi = cloned;
|
|
44
|
-
} else {
|
|
45
|
-
def.zodOpenApi = {
|
|
46
|
-
openapi: { description: args[0] },
|
|
47
|
-
[extendZodSymbols.currentSymbol]: result
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return result;
|
|
51
|
-
};
|
|
52
|
-
const zodObjectExtend = zod.ZodObject.prototype.extend;
|
|
53
|
-
zod.ZodObject.prototype.extend = function(...args) {
|
|
54
|
-
const extendResult = zodObjectExtend.apply(this, args);
|
|
55
|
-
const zodOpenApi = extendResult._def.zodOpenApi;
|
|
56
|
-
if (zodOpenApi) {
|
|
57
|
-
const cloned = { ...zodOpenApi };
|
|
58
|
-
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
59
|
-
cloned[extendZodSymbols.previousSymbol] = this;
|
|
60
|
-
extendResult._def.zodOpenApi = cloned;
|
|
61
|
-
} else {
|
|
62
|
-
extendResult._def.zodOpenApi = {
|
|
63
|
-
[extendZodSymbols.previousSymbol]: this
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
return extendResult;
|
|
67
|
-
};
|
|
68
|
-
const zodObjectOmit = zod.ZodObject.prototype.omit;
|
|
69
|
-
zod.ZodObject.prototype.omit = function(...args) {
|
|
70
|
-
const omitResult = zodObjectOmit.apply(this, args);
|
|
71
|
-
const zodOpenApi = omitResult._def.zodOpenApi;
|
|
72
|
-
if (zodOpenApi) {
|
|
73
|
-
const cloned = { ...zodOpenApi };
|
|
74
|
-
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
75
|
-
delete cloned[extendZodSymbols.previousSymbol];
|
|
76
|
-
delete cloned[extendZodSymbols.currentSymbol];
|
|
77
|
-
omitResult._def.zodOpenApi = cloned;
|
|
78
|
-
}
|
|
79
|
-
return omitResult;
|
|
80
|
-
};
|
|
81
|
-
const zodObjectPick = zod.ZodObject.prototype.pick;
|
|
82
|
-
zod.ZodObject.prototype.pick = function(...args) {
|
|
83
|
-
const pickResult = zodObjectPick.apply(this, args);
|
|
84
|
-
const zodOpenApi = pickResult._def.zodOpenApi;
|
|
85
|
-
if (zodOpenApi) {
|
|
86
|
-
const cloned = { ...zodOpenApi };
|
|
87
|
-
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
88
|
-
delete cloned[extendZodSymbols.previousSymbol];
|
|
89
|
-
delete cloned[extendZodSymbols.currentSymbol];
|
|
90
|
-
pickResult._def.zodOpenApi = cloned;
|
|
91
|
-
}
|
|
92
|
-
return pickResult;
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
exports.extendZodWithOpenApi = extendZodWithOpenApi;
|
package/dist/extendZod.chunk.mjs
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { currentSymbol, previousSymbol } from "./extendZodSymbols.chunk.mjs";
|
|
2
|
-
const mergeOpenApi = (openapi, {
|
|
3
|
-
ref: _ref,
|
|
4
|
-
refType: _refType,
|
|
5
|
-
param: _param,
|
|
6
|
-
header: _header,
|
|
7
|
-
...rest
|
|
8
|
-
} = {}) => ({
|
|
9
|
-
...rest,
|
|
10
|
-
...openapi
|
|
11
|
-
});
|
|
12
|
-
function extendZodWithOpenApi(zod) {
|
|
13
|
-
if (typeof zod.ZodType.prototype.openapi !== "undefined") {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
zod.ZodType.prototype.openapi = function(openapi) {
|
|
17
|
-
const { zodOpenApi, ...rest } = this._def;
|
|
18
|
-
const result = new this.constructor({
|
|
19
|
-
...rest,
|
|
20
|
-
zodOpenApi: {
|
|
21
|
-
openapi: mergeOpenApi(
|
|
22
|
-
openapi,
|
|
23
|
-
zodOpenApi == null ? void 0 : zodOpenApi.openapi
|
|
24
|
-
)
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
result._def.zodOpenApi[currentSymbol] = result;
|
|
28
|
-
if (zodOpenApi) {
|
|
29
|
-
result._def.zodOpenApi[previousSymbol] = this;
|
|
30
|
-
}
|
|
31
|
-
return result;
|
|
32
|
-
};
|
|
33
|
-
const zodDescribe = zod.ZodType.prototype.describe;
|
|
34
|
-
zod.ZodType.prototype.describe = function(...args) {
|
|
35
|
-
const result = zodDescribe.apply(this, args);
|
|
36
|
-
const def = result._def;
|
|
37
|
-
if (def.zodOpenApi) {
|
|
38
|
-
const cloned = { ...def.zodOpenApi };
|
|
39
|
-
cloned.openapi = mergeOpenApi({ description: args[0] }, cloned.openapi);
|
|
40
|
-
cloned[previousSymbol] = this;
|
|
41
|
-
cloned[currentSymbol] = result;
|
|
42
|
-
def.zodOpenApi = cloned;
|
|
43
|
-
} else {
|
|
44
|
-
def.zodOpenApi = {
|
|
45
|
-
openapi: { description: args[0] },
|
|
46
|
-
[currentSymbol]: result
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
50
|
-
};
|
|
51
|
-
const zodObjectExtend = zod.ZodObject.prototype.extend;
|
|
52
|
-
zod.ZodObject.prototype.extend = function(...args) {
|
|
53
|
-
const extendResult = zodObjectExtend.apply(this, args);
|
|
54
|
-
const zodOpenApi = extendResult._def.zodOpenApi;
|
|
55
|
-
if (zodOpenApi) {
|
|
56
|
-
const cloned = { ...zodOpenApi };
|
|
57
|
-
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
58
|
-
cloned[previousSymbol] = this;
|
|
59
|
-
extendResult._def.zodOpenApi = cloned;
|
|
60
|
-
} else {
|
|
61
|
-
extendResult._def.zodOpenApi = {
|
|
62
|
-
[previousSymbol]: this
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return extendResult;
|
|
66
|
-
};
|
|
67
|
-
const zodObjectOmit = zod.ZodObject.prototype.omit;
|
|
68
|
-
zod.ZodObject.prototype.omit = function(...args) {
|
|
69
|
-
const omitResult = zodObjectOmit.apply(this, args);
|
|
70
|
-
const zodOpenApi = omitResult._def.zodOpenApi;
|
|
71
|
-
if (zodOpenApi) {
|
|
72
|
-
const cloned = { ...zodOpenApi };
|
|
73
|
-
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
74
|
-
delete cloned[previousSymbol];
|
|
75
|
-
delete cloned[currentSymbol];
|
|
76
|
-
omitResult._def.zodOpenApi = cloned;
|
|
77
|
-
}
|
|
78
|
-
return omitResult;
|
|
79
|
-
};
|
|
80
|
-
const zodObjectPick = zod.ZodObject.prototype.pick;
|
|
81
|
-
zod.ZodObject.prototype.pick = function(...args) {
|
|
82
|
-
const pickResult = zodObjectPick.apply(this, args);
|
|
83
|
-
const zodOpenApi = pickResult._def.zodOpenApi;
|
|
84
|
-
if (zodOpenApi) {
|
|
85
|
-
const cloned = { ...zodOpenApi };
|
|
86
|
-
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
87
|
-
delete cloned[previousSymbol];
|
|
88
|
-
delete cloned[currentSymbol];
|
|
89
|
-
pickResult._def.zodOpenApi = cloned;
|
|
90
|
-
}
|
|
91
|
-
return pickResult;
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
export {
|
|
95
|
-
extendZodWithOpenApi
|
|
96
|
-
};
|
package/dist/extendZod.d.ts
DELETED
package/dist/extendZodTypes.d.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { ZodTypeAny, z, ZodObject } from 'zod';
|
|
2
|
-
import { CreationType } from './create/components.js';
|
|
3
|
-
import { currentSymbol, previousSymbol } from './extendZodSymbols.js';
|
|
4
|
-
import { HeaderObject as HeaderObject$1, SchemaObject as SchemaObject$1 } from './openapi3-ts/dist/model/openapi30.js';
|
|
5
|
-
import { ParameterObject, ExampleObject, ReferenceObject, HeaderObject, SchemaObject as SchemaObject$2 } from './openapi3-ts/dist/model/openapi31.js';
|
|
6
|
-
|
|
7
|
-
type SchemaObject = SchemaObject$1 & SchemaObject$2;
|
|
8
|
-
type ReplaceDate<T> = T extends Date ? Date | string : T;
|
|
9
|
-
/**
|
|
10
|
-
* zod-openapi metadata
|
|
11
|
-
*/
|
|
12
|
-
interface ZodOpenApiMetadata<T extends ZodTypeAny, TInferred = Exclude<ReplaceDate<z.input<T> | z.output<T>>, undefined>> extends SchemaObject {
|
|
13
|
-
example?: TInferred;
|
|
14
|
-
examples?: [TInferred, ...TInferred[]];
|
|
15
|
-
default?: TInferred;
|
|
16
|
-
/**
|
|
17
|
-
* Used to set the output of a ZodUnion to be `oneOf` instead of `allOf`
|
|
18
|
-
*/
|
|
19
|
-
unionOneOf?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Used to output this Zod Schema in the components schemas section. Any usage of this Zod Schema will then be transformed into a $ref.
|
|
22
|
-
*/
|
|
23
|
-
ref?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Used when you are manually adding a Zod Schema to the components section. This controls whether this should be rendered as a request (`input`) or response (`output`). Defaults to `output`
|
|
26
|
-
*/
|
|
27
|
-
refType?: CreationType;
|
|
28
|
-
/**
|
|
29
|
-
* Used to set the created type of an effect.
|
|
30
|
-
* If this was previously set to `same` and this is throwing an error, your effect is no longer returning the same type.
|
|
31
|
-
*/
|
|
32
|
-
effectType?: CreationType | (z.input<T> extends z.output<T> ? z.output<T> extends z.input<T> ? 'same' : never : never);
|
|
33
|
-
/**
|
|
34
|
-
* Used to set metadata for a parameter, request header or cookie
|
|
35
|
-
*/
|
|
36
|
-
param?: Partial<ParameterObject> & {
|
|
37
|
-
example?: TInferred;
|
|
38
|
-
examples?: Record<string, (ExampleObject & {
|
|
39
|
-
value: TInferred;
|
|
40
|
-
}) | ReferenceObject>;
|
|
41
|
-
/**
|
|
42
|
-
* Used to output this Zod Schema in the components parameters section. Any usage of this Zod Schema will then be transformed into a $ref.
|
|
43
|
-
*/
|
|
44
|
-
ref?: string;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Used to set data for a response header
|
|
48
|
-
*/
|
|
49
|
-
header?: Partial<HeaderObject & HeaderObject$1> & {
|
|
50
|
-
/**
|
|
51
|
-
* Used to output this Zod Schema in the components headers section. Any usage of this Zod Schema will then be transformed into a $ref.
|
|
52
|
-
*/
|
|
53
|
-
ref?: string;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Used to override the generated type. If this is provided no metadata will be generated.
|
|
57
|
-
*/
|
|
58
|
-
type?: SchemaObject['type'];
|
|
59
|
-
}
|
|
60
|
-
interface ZodOpenApiMetadataDef {
|
|
61
|
-
/**
|
|
62
|
-
* Up to date OpenAPI metadata
|
|
63
|
-
*/
|
|
64
|
-
openapi?: ZodOpenApiMetadata<ZodTypeAny>;
|
|
65
|
-
/**
|
|
66
|
-
* Used to keep track of the Zod Schema had `.openapi` called on it
|
|
67
|
-
*/
|
|
68
|
-
[currentSymbol]?: ZodTypeAny;
|
|
69
|
-
/**
|
|
70
|
-
* Used to keep track of the previous Zod Schema that had `.openapi` called on it if another `.openapi` is called.
|
|
71
|
-
* This can also be present when .extend is called on an object.
|
|
72
|
-
*/
|
|
73
|
-
[previousSymbol]?: ZodTypeAny;
|
|
74
|
-
}
|
|
75
|
-
interface ZodOpenApiExtendMetadata {
|
|
76
|
-
extends: ZodObject<any, any, any, any, any>;
|
|
77
|
-
}
|
|
78
|
-
declare module 'zod' {
|
|
79
|
-
interface ZodType {
|
|
80
|
-
/**
|
|
81
|
-
* Add OpenAPI metadata to a Zod Type
|
|
82
|
-
*/
|
|
83
|
-
openapi<T extends ZodTypeAny>(this: T, metadata: ZodOpenApiMetadata<T>): T;
|
|
84
|
-
}
|
|
85
|
-
interface ZodTypeDef {
|
|
86
|
-
zodOpenApi?: ZodOpenApiMetadataDef;
|
|
87
|
-
}
|
|
88
|
-
interface ZodObjectDef {
|
|
89
|
-
extendMetadata?: ZodOpenApiExtendMetadata;
|
|
90
|
-
}
|
|
91
|
-
}
|