zod-openapi 4.2.3 → 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 +87 -194
- 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 -2278
- package/dist/components.chunk.mjs +908 -2278
- package/dist/create/components.d.ts +81 -120
- package/dist/create/content.d.ts +8 -6
- package/dist/create/document.d.ts +39 -34
- 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 +12 -12
- 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
|
@@ -1,124 +1,85 @@
|
|
|
1
|
-
import { ZodType } from 'zod';
|
|
2
|
-
import { SchemaObject
|
|
3
|
-
import {
|
|
4
|
-
import { ZodOpenApiVersion, ZodOpenApiComponentsObject, CreateDocumentOptions, ZodOpenApiResponseObject, ZodOpenApiRequestBodyObject, ZodOpenApiCallbackObject } from './document.js';
|
|
1
|
+
import { $ZodType } from 'zod/v4/core';
|
|
2
|
+
import { SchemaObject, ReferenceObject, HeaderObject, RequestBodyObject, ResponseObject, ParameterObject, PathItemObject, ComponentsObject } from '../openapi3-ts/dist/model/openapi31.js';
|
|
3
|
+
import { ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiCallbackObject, ZodOpenApiPathItemObject, CreateDocumentOptions, ZodOpenApiComponentsObject } from './document.js';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
type
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
5
|
+
interface ComponentRegistry {
|
|
6
|
+
/**
|
|
7
|
+
* Contains a map of component name to their OpenAPI schema object or reference.
|
|
8
|
+
*/
|
|
9
|
+
schemas: {
|
|
10
|
+
dynamicSchemaCount: number;
|
|
11
|
+
input: {
|
|
12
|
+
seen: WeakMap<$ZodType, {
|
|
13
|
+
type: 'manual';
|
|
14
|
+
id: string;
|
|
15
|
+
schemaObject: SchemaObject | ReferenceObject;
|
|
16
|
+
} | {
|
|
17
|
+
type: 'schema';
|
|
18
|
+
schemaObject: SchemaObject | ReferenceObject;
|
|
19
|
+
}>;
|
|
20
|
+
schemas: Map<string, {
|
|
21
|
+
zodType: $ZodType;
|
|
22
|
+
schemaObject: SchemaObject | ReferenceObject;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
output: {
|
|
26
|
+
seen: WeakMap<$ZodType, {
|
|
27
|
+
type: 'manual';
|
|
28
|
+
id: string;
|
|
29
|
+
schemaObject: SchemaObject | ReferenceObject;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'schema';
|
|
32
|
+
schemaObject: SchemaObject | ReferenceObject;
|
|
33
|
+
}>;
|
|
34
|
+
schemas: Map<string, {
|
|
35
|
+
zodType: $ZodType;
|
|
36
|
+
schemaObject: SchemaObject | ReferenceObject;
|
|
37
|
+
}>;
|
|
38
|
+
};
|
|
39
|
+
ids: Map<string, SchemaObject | ReferenceObject>;
|
|
40
|
+
manual: Map<string, {
|
|
41
|
+
key: string;
|
|
42
|
+
io: {
|
|
43
|
+
input: {
|
|
44
|
+
used?: true;
|
|
45
|
+
schemaObject: SchemaObject;
|
|
46
|
+
};
|
|
47
|
+
output: {
|
|
48
|
+
used?: true;
|
|
49
|
+
schemaObject: SchemaObject;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
zodType: $ZodType;
|
|
53
|
+
}>;
|
|
54
|
+
setSchema: (key: string, schema: $ZodType, io: 'input' | 'output') => SchemaObject | ReferenceObject;
|
|
55
|
+
};
|
|
56
|
+
headers: {
|
|
57
|
+
ids: Map<string, HeaderObject | ReferenceObject>;
|
|
58
|
+
seen: WeakMap<$ZodType, HeaderObject | ReferenceObject>;
|
|
59
|
+
};
|
|
60
|
+
requestBodies: {
|
|
61
|
+
ids: Map<string, RequestBodyObject | ReferenceObject>;
|
|
62
|
+
seen: WeakMap<ZodOpenApiRequestBodyObject, RequestBodyObject | ReferenceObject>;
|
|
63
|
+
};
|
|
64
|
+
responses: {
|
|
65
|
+
ids: Map<string, ResponseObject | ReferenceObject>;
|
|
66
|
+
seen: WeakMap<ZodOpenApiResponseObject, ResponseObject | ReferenceObject>;
|
|
67
|
+
};
|
|
68
|
+
parameters: {
|
|
69
|
+
ids: Map<string, ParameterObject | ReferenceObject>;
|
|
70
|
+
seen: WeakMap<$ZodType, ParameterObject | ReferenceObject>;
|
|
71
|
+
};
|
|
72
|
+
callbacks: {
|
|
73
|
+
ids: Map<string, ZodOpenApiCallbackObject | ReferenceObject>;
|
|
74
|
+
seen: WeakMap<ZodOpenApiCallbackObject, ZodOpenApiCallbackObject | ReferenceObject>;
|
|
75
|
+
};
|
|
76
|
+
pathItems: {
|
|
77
|
+
ids: Map<string, PathItemObject | ReferenceObject>;
|
|
78
|
+
seen: WeakMap<ZodOpenApiPathItemObject, PathItemObject | ReferenceObject>;
|
|
27
79
|
};
|
|
28
|
-
};
|
|
29
|
-
interface CompleteSchemaComponent extends BaseSchemaComponent {
|
|
30
|
-
type: 'complete';
|
|
31
|
-
schemaObject: SchemaObject | ReferenceObject | SchemaObject$1 | ReferenceObject$1;
|
|
32
|
-
/** Set when the created schemaObject is specific to a particular effect */
|
|
33
|
-
effects?: Effect[];
|
|
34
|
-
resolvedEffect?: ResolvedEffect;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
*/
|
|
39
|
-
interface ManualSchemaComponent extends BaseSchemaComponent {
|
|
40
|
-
type: 'manual';
|
|
41
|
-
}
|
|
42
|
-
interface InProgressSchemaComponent extends BaseSchemaComponent {
|
|
43
|
-
type: 'in-progress';
|
|
44
|
-
}
|
|
45
|
-
interface BaseSchemaComponent {
|
|
46
|
-
ref: string;
|
|
47
|
-
}
|
|
48
|
-
type SchemaComponent = CompleteSchemaComponent | ManualSchemaComponent | InProgressSchemaComponent;
|
|
49
|
-
type SchemaComponentMap = Map<ZodType, SchemaComponent>;
|
|
50
|
-
interface CompleteParameterComponent extends BaseParameterComponent {
|
|
51
|
-
type: 'complete';
|
|
52
|
-
paramObject: ParameterObject | ReferenceObject | ParameterObject$1 | ReferenceObject$1;
|
|
53
|
-
}
|
|
54
|
-
interface PartialParameterComponent extends BaseParameterComponent {
|
|
55
|
-
type: 'manual';
|
|
56
|
-
}
|
|
57
|
-
interface BaseParameterComponent {
|
|
58
|
-
ref: string;
|
|
59
|
-
in: ParameterLocation;
|
|
60
|
-
name: string;
|
|
61
|
-
}
|
|
62
|
-
type ParameterComponent = CompleteParameterComponent | PartialParameterComponent;
|
|
63
|
-
type ParameterComponentMap = Map<ZodType, ParameterComponent>;
|
|
64
|
-
interface CompleteHeaderComponent extends BaseHeaderComponent {
|
|
65
|
-
type: 'complete';
|
|
66
|
-
headerObject: HeaderObject | ReferenceObject | HeaderObject$1 | ReferenceObject$1;
|
|
67
|
-
}
|
|
68
|
-
interface PartialHeaderComponent extends BaseHeaderComponent {
|
|
69
|
-
type: 'manual';
|
|
70
|
-
}
|
|
71
|
-
interface BaseHeaderComponent {
|
|
72
|
-
ref: string;
|
|
73
|
-
}
|
|
74
|
-
type HeaderComponent = CompleteHeaderComponent | PartialHeaderComponent;
|
|
75
|
-
type HeaderComponentMap = Map<ZodType, HeaderComponent>;
|
|
76
|
-
interface BaseResponseComponent {
|
|
77
|
-
ref: string;
|
|
78
|
-
}
|
|
79
|
-
interface CompleteResponseComponent extends BaseResponseComponent {
|
|
80
|
-
type: 'complete';
|
|
81
|
-
responseObject: ResponseObject | ReferenceObject | ResponseObject$1 | ReferenceObject$1;
|
|
82
|
-
}
|
|
83
|
-
interface PartialResponseComponent extends BaseResponseComponent {
|
|
84
|
-
type: 'manual';
|
|
85
|
-
}
|
|
86
|
-
type ResponseComponent = CompleteResponseComponent | PartialResponseComponent;
|
|
87
|
-
type ResponseComponentMap = Map<ZodOpenApiResponseObject, ResponseComponent>;
|
|
88
|
-
interface BaseRequestBodyComponent {
|
|
89
|
-
ref: string;
|
|
90
|
-
}
|
|
91
|
-
interface CompleteRequestBodyComponent extends BaseRequestBodyComponent {
|
|
92
|
-
type: 'complete';
|
|
93
|
-
requestBodyObject: RequestBodyObject | ReferenceObject | RequestBodyObject$1 | ReferenceObject$1;
|
|
94
|
-
}
|
|
95
|
-
interface PartialRequestBodyComponent extends BaseRequestBodyComponent {
|
|
96
|
-
type: 'manual';
|
|
97
|
-
}
|
|
98
|
-
type RequestBodyComponent = CompleteRequestBodyComponent | PartialRequestBodyComponent;
|
|
99
|
-
type RequestBodyComponentMap = Map<ZodOpenApiRequestBodyObject, RequestBodyComponent>;
|
|
100
|
-
interface BaseCallbackComponent {
|
|
101
|
-
ref: string;
|
|
102
|
-
}
|
|
103
|
-
interface CompleteCallbackComponent extends BaseCallbackComponent {
|
|
104
|
-
type: 'complete';
|
|
105
|
-
callbackObject: ZodOpenApiCallbackObject | CallbackObject | CallbackObject$1;
|
|
106
|
-
}
|
|
107
|
-
interface PartialCallbackComponent extends BaseCallbackComponent {
|
|
108
|
-
type: 'manual';
|
|
109
|
-
}
|
|
110
|
-
type CallbackComponent = CompleteCallbackComponent | PartialCallbackComponent;
|
|
111
|
-
type CallbackComponentMap = Map<ZodOpenApiCallbackObject, CallbackComponent>;
|
|
112
|
-
interface ComponentsObject {
|
|
113
|
-
schemas: SchemaComponentMap;
|
|
114
|
-
parameters: ParameterComponentMap;
|
|
115
|
-
headers: HeaderComponentMap;
|
|
116
|
-
requestBodies: RequestBodyComponentMap;
|
|
117
|
-
responses: ResponseComponentMap;
|
|
118
|
-
callbacks: CallbackComponentMap;
|
|
119
|
-
openapi: ZodOpenApiVersion;
|
|
120
80
|
}
|
|
121
|
-
declare const
|
|
122
|
-
declare const createComponents: (
|
|
81
|
+
declare const createRegistry: (components?: ZodOpenApiComponentsObject) => ComponentRegistry;
|
|
82
|
+
declare const createComponents: (registry: ComponentRegistry, opts: CreateDocumentOptions) => ComponentsObject;
|
|
123
83
|
|
|
124
|
-
export {
|
|
84
|
+
export { createComponents, createRegistry };
|
|
85
|
+
export type { ComponentRegistry };
|
package/dist/create/content.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { CreateDocumentOptions } from './document.js';
|
|
1
|
+
import { MediaTypeObject } from '../openapi3-ts/dist/model/openapi31.js';
|
|
2
|
+
import { ComponentRegistry } from './components.js';
|
|
3
|
+
import { ZodOpenApiMediaTypeObject } from './document.js';
|
|
5
4
|
|
|
6
|
-
declare const
|
|
5
|
+
declare const createMediaTypeObject: (mediaTypeObject: ZodOpenApiMediaTypeObject, ctx: {
|
|
6
|
+
registry: ComponentRegistry;
|
|
7
|
+
io: "input" | "output";
|
|
8
|
+
}, path: string[]) => MediaTypeObject;
|
|
7
9
|
|
|
8
|
-
export {
|
|
10
|
+
export { createMediaTypeObject };
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ZodTypeDef, ZodType } from 'zod';
|
|
2
|
+
import { $ZodType, $ZodTypes } from 'zod/v4/core';
|
|
2
3
|
import { OpenApiVersion } from '../openapi.js';
|
|
3
|
-
import { MediaTypeObject as MediaTypeObject$1, RequestBodyObject as RequestBodyObject$1, ResponseObject as ResponseObject$1, HeadersObject, ReferenceObject as ReferenceObject$1, ParameterLocation as ParameterLocation$1, OperationObject as OperationObject$1, ParameterObject as ParameterObject$1, PathItemObject as PathItemObject$1, ComponentsObject as ComponentsObject$1, SchemaObject as SchemaObject$1, HeaderObject as HeaderObject$1 } from '../openapi3-ts/dist/model/openapi30.js';
|
|
4
4
|
import { ISpecificationExtension } from '../openapi3-ts/dist/model/specification-extension.js';
|
|
5
|
-
import { MediaTypeObject, SchemaObject, ReferenceObject,
|
|
5
|
+
import { RequestBodyObject, MediaTypeObject, SchemaObject, ReferenceObject, ResponseObject, HeadersObject, PathItemObject, OperationObject, ParameterObject, ParameterLocation, HeaderObject, ComponentsObject, OpenAPIObject } from '../openapi3-ts/dist/model/openapi31.js';
|
|
6
|
+
import { Override } from '../zod.js';
|
|
6
7
|
|
|
7
|
-
interface ZodOpenApiMediaTypeObject extends Omit<MediaTypeObject
|
|
8
|
-
schema?: ZodType | SchemaObject | ReferenceObject;
|
|
8
|
+
interface ZodOpenApiMediaTypeObject extends Omit<MediaTypeObject, 'schema'> {
|
|
9
|
+
schema?: $ZodType | SchemaObject | ReferenceObject;
|
|
9
10
|
}
|
|
10
11
|
interface ZodOpenApiContentObject {
|
|
11
12
|
'application/json'?: ZodOpenApiMediaTypeObject;
|
|
12
13
|
[mediatype: string]: ZodOpenApiMediaTypeObject | undefined;
|
|
13
14
|
}
|
|
14
|
-
interface ZodOpenApiRequestBodyObject extends Omit<RequestBodyObject
|
|
15
|
+
interface ZodOpenApiRequestBodyObject extends Omit<RequestBodyObject, 'content'> {
|
|
15
16
|
content: ZodOpenApiContentObject;
|
|
16
17
|
/** Use this field to auto register this request body as a component */
|
|
17
|
-
|
|
18
|
+
id?: string;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
type ZodOpenApiHeadersObject = ZodObjectInput | HeadersObject;
|
|
21
|
+
interface ZodOpenApiResponseObject extends Omit<ResponseObject, 'content' | 'headers'> {
|
|
20
22
|
content?: ZodOpenApiContentObject;
|
|
21
|
-
headers?:
|
|
23
|
+
headers?: ZodOpenApiHeadersObject;
|
|
22
24
|
/** Use this field to auto register this response object as a component */
|
|
23
|
-
|
|
25
|
+
id?: string;
|
|
24
26
|
}
|
|
25
27
|
interface ZodOpenApiResponsesObject extends ISpecificationExtension {
|
|
26
|
-
default?: ZodOpenApiResponseObject | ReferenceObject
|
|
28
|
+
default?: ZodOpenApiResponseObject | ReferenceObject;
|
|
27
29
|
[statuscode: `${1 | 2 | 3 | 4 | 5}${string}`]: ZodOpenApiResponseObject | ReferenceObject;
|
|
28
30
|
}
|
|
29
|
-
type ZodOpenApiParameters =
|
|
30
|
-
[type in ParameterLocation & ParameterLocation$1]?: ZodObjectInputType;
|
|
31
|
-
};
|
|
31
|
+
type ZodOpenApiParameters = Partial<Record<ParameterLocation, ZodObjectInput>>;
|
|
32
32
|
interface ZodOpenApiCallbacksObject extends ISpecificationExtension {
|
|
33
33
|
[name: string]: ZodOpenApiCallbackObject;
|
|
34
34
|
}
|
|
35
35
|
interface ZodOpenApiCallbackObject extends ISpecificationExtension {
|
|
36
36
|
/** Use this field to auto register this callback object as a component */
|
|
37
|
-
|
|
37
|
+
id?: string;
|
|
38
38
|
[name: string]: ZodOpenApiPathItemObject | string | undefined;
|
|
39
39
|
}
|
|
40
|
-
interface ZodOpenApiOperationObject extends Omit<OperationObject
|
|
41
|
-
parameters?: Array
|
|
40
|
+
interface ZodOpenApiOperationObject extends Omit<OperationObject, 'requestBody' | 'responses' | 'parameters' | 'callbacks'> {
|
|
41
|
+
parameters?: Array<$ZodType | ParameterObject | ReferenceObject>;
|
|
42
42
|
requestBody?: ZodOpenApiRequestBodyObject;
|
|
43
43
|
requestParams?: ZodOpenApiParameters;
|
|
44
44
|
responses: ZodOpenApiResponsesObject;
|
|
45
45
|
callbacks?: ZodOpenApiCallbacksObject;
|
|
46
46
|
}
|
|
47
|
-
interface ZodOpenApiPathItemObject extends Omit<PathItemObject
|
|
47
|
+
interface ZodOpenApiPathItemObject extends Omit<PathItemObject, 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace'> {
|
|
48
48
|
get?: ZodOpenApiOperationObject;
|
|
49
49
|
put?: ZodOpenApiOperationObject;
|
|
50
50
|
post?: ZodOpenApiOperationObject;
|
|
@@ -53,17 +53,26 @@ interface ZodOpenApiPathItemObject extends Omit<PathItemObject & PathItemObject$
|
|
|
53
53
|
head?: ZodOpenApiOperationObject;
|
|
54
54
|
patch?: ZodOpenApiOperationObject;
|
|
55
55
|
trace?: ZodOpenApiOperationObject;
|
|
56
|
+
/**
|
|
57
|
+
* Used to register this path item as a component.
|
|
58
|
+
*/
|
|
59
|
+
id?: string;
|
|
56
60
|
}
|
|
57
61
|
interface ZodOpenApiPathsObject extends ISpecificationExtension {
|
|
58
62
|
[path: string]: ZodOpenApiPathItemObject;
|
|
59
63
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
type ZodOpenApiParameterObject = $ZodType | ParameterObject | ReferenceObject;
|
|
65
|
+
type ZodOpenApiHeaderObject = $ZodType | HeaderObject | ReferenceObject;
|
|
66
|
+
type ZodOpenApiSchemaObject = $ZodType | SchemaObject | ReferenceObject;
|
|
67
|
+
type ZodOpenApiRequestBody = $ZodType | RequestBodyObject | ReferenceObject;
|
|
68
|
+
interface ZodOpenApiComponentsObject extends Omit<ComponentsObject, 'schemas' | 'responses' | 'requestBodies' | 'headers' | 'parameters' | 'pathItems' | 'callbacks'> {
|
|
69
|
+
parameters?: Record<string, ZodOpenApiParameterObject>;
|
|
70
|
+
schemas?: Record<string, ZodOpenApiSchemaObject>;
|
|
63
71
|
requestBodies?: Record<string, ZodOpenApiRequestBodyObject>;
|
|
64
|
-
headers?: Record<string,
|
|
72
|
+
headers?: Record<string, ZodOpenApiHeaderObject>;
|
|
65
73
|
responses?: Record<string, ZodOpenApiResponseObject>;
|
|
66
74
|
callbacks?: Record<string, ZodOpenApiCallbackObject>;
|
|
75
|
+
pathItems?: Record<string, ZodOpenApiPathItemObject>;
|
|
67
76
|
}
|
|
68
77
|
type ZodOpenApiVersion = OpenApiVersion;
|
|
69
78
|
interface ZodOpenApiObject extends Omit<OpenAPIObject, 'openapi' | 'paths' | 'webhooks' | 'components'> {
|
|
@@ -73,20 +82,16 @@ interface ZodOpenApiObject extends Omit<OpenAPIObject, 'openapi' | 'paths' | 'we
|
|
|
73
82
|
components?: ZodOpenApiComponentsObject;
|
|
74
83
|
}
|
|
75
84
|
type ZodObjectInputType<Output = unknown, Def extends ZodTypeDef = ZodTypeDef, Input = Record<string, unknown>> = ZodType<Output, Def, Input>;
|
|
85
|
+
type ZodObjectInput = $ZodType<unknown, Record<string, unknown>>;
|
|
86
|
+
type OverrideType = $ZodTypes['_zod']['def']['type'];
|
|
76
87
|
interface CreateDocumentOptions {
|
|
77
88
|
/**
|
|
78
|
-
*
|
|
79
|
-
*/
|
|
80
|
-
enforceDiscriminatedUnionComponents?: boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Used to change the default Zod Date schema
|
|
83
|
-
*/
|
|
84
|
-
defaultDateSchema?: Pick<SchemaObject, 'type' | 'format'>;
|
|
85
|
-
/**
|
|
86
|
-
* Used to set the output of a ZodUnion to be `oneOf` instead of `anyOf`
|
|
89
|
+
* Use to override the rendered schema
|
|
87
90
|
*/
|
|
88
|
-
|
|
91
|
+
override?: Override;
|
|
92
|
+
allowEmptySchema?: Partial<Record<OverrideType, true>>;
|
|
89
93
|
}
|
|
90
|
-
declare const createDocument: (zodOpenApiObject: ZodOpenApiObject,
|
|
94
|
+
declare const createDocument: (zodOpenApiObject: ZodOpenApiObject, opts?: CreateDocumentOptions) => OpenAPIObject;
|
|
91
95
|
|
|
92
|
-
export {
|
|
96
|
+
export { createDocument };
|
|
97
|
+
export type { CreateDocumentOptions, ZodObjectInput, ZodObjectInputType, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBody, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiVersion };
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { ZodType
|
|
2
|
-
import { ParameterObject, ReferenceObject } from '../openapi3-ts/dist/model/openapi31.js';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import { $ZodType } from 'zod/v4/core';
|
|
2
|
+
import { ParameterLocation, ParameterObject, ReferenceObject } from '../openapi3-ts/dist/model/openapi31.js';
|
|
3
|
+
import { ComponentRegistry } from './components.js';
|
|
4
|
+
import '../zod.js';
|
|
5
5
|
|
|
6
|
-
declare const
|
|
7
|
-
|
|
6
|
+
declare const createParameter: (parameter: $ZodType, location: {
|
|
7
|
+
in: ParameterLocation;
|
|
8
|
+
name: string;
|
|
9
|
+
} | undefined, ctx: {
|
|
10
|
+
registry: ComponentRegistry;
|
|
11
|
+
io: "input" | "output";
|
|
12
|
+
}, path: string[]) => ParameterObject | ReferenceObject;
|
|
8
13
|
|
|
9
|
-
export {
|
|
14
|
+
export { createParameter };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { core } from 'zod/v4';
|
|
2
|
+
import { CreateDocumentOptions } from '../document.js';
|
|
3
|
+
import { ComponentRegistry } from '../components.js';
|
|
4
|
+
import '../../zod.js';
|
|
5
|
+
import { SchemaObject, ReferenceObject } from '../../openapi3-ts/dist/model/openapi31.js';
|
|
6
|
+
|
|
7
|
+
interface SchemaResult {
|
|
8
|
+
schema: SchemaObject | ReferenceObject;
|
|
9
|
+
components: Record<string, SchemaObject>;
|
|
10
|
+
}
|
|
11
|
+
declare const createSchema: (schema: core.$ZodType, ctx?: {
|
|
12
|
+
registry?: ComponentRegistry;
|
|
13
|
+
io?: "input" | "output";
|
|
14
|
+
opts?: CreateDocumentOptions;
|
|
15
|
+
}) => {
|
|
16
|
+
schema: SchemaObject | ReferenceObject;
|
|
17
|
+
components: Record<string, SchemaObject>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { createSchema };
|
|
21
|
+
export type { SchemaResult };
|
package/dist/index.cjs
CHANGED
|
@@ -1,60 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const components = require("./components.chunk.cjs");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const createdWebhooks = components.createPaths(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
components
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
22
|
-
return {
|
|
23
|
-
...rest,
|
|
24
|
-
...createdPaths && { paths: createdPaths },
|
|
25
|
-
...createdWebhooks && { webhooks: createdWebhooks },
|
|
26
|
-
...createdComponents && { components: createdComponents }
|
|
27
|
-
};
|
|
4
|
+
const createDocument = (zodOpenApiObject, opts = {}) => {
|
|
5
|
+
const { paths, webhooks, components: components$1, ...rest } = zodOpenApiObject;
|
|
6
|
+
const document = rest;
|
|
7
|
+
const registry = components.createRegistry(components$1);
|
|
8
|
+
const createdPaths = components.createPaths(paths, registry, ["paths"]);
|
|
9
|
+
if (createdPaths) {
|
|
10
|
+
document.paths = createdPaths;
|
|
11
|
+
}
|
|
12
|
+
const createdWebhooks = components.createPaths(webhooks, registry, ["webhooks"]);
|
|
13
|
+
if (createdWebhooks) {
|
|
14
|
+
document.webhooks = createdWebhooks;
|
|
15
|
+
}
|
|
16
|
+
const createdComponents = components.createComponents(registry, opts);
|
|
17
|
+
if (Object.keys(createdComponents).length > 0) {
|
|
18
|
+
document.components = createdComponents;
|
|
19
|
+
}
|
|
20
|
+
return document;
|
|
28
21
|
};
|
|
29
|
-
|
|
30
|
-
const components$1 = components.getDefaultComponents(
|
|
31
|
-
{
|
|
32
|
-
schemas: opts == null ? void 0 : opts.components
|
|
33
|
-
},
|
|
34
|
-
opts == null ? void 0 : opts.openapi
|
|
35
|
-
);
|
|
36
|
-
const state = {
|
|
37
|
-
components: components$1,
|
|
38
|
-
type: (opts == null ? void 0 : opts.schemaType) ?? "output",
|
|
39
|
-
path: [],
|
|
40
|
-
visited: /* @__PURE__ */ new Set(),
|
|
41
|
-
documentOptions: opts
|
|
42
|
-
};
|
|
43
|
-
const schema = components.createSchema(zodType, state, ["createSchema"]);
|
|
44
|
-
const schemaComponents = components.createSchemaComponents({}, components$1);
|
|
45
|
-
return {
|
|
46
|
-
schema,
|
|
47
|
-
components: schemaComponents
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
const oas30 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
51
|
-
__proto__: null
|
|
52
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
53
|
-
const oas31 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
54
|
-
__proto__: null
|
|
55
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
56
|
-
exports.extendZodWithOpenApi = extendZod.extendZodWithOpenApi;
|
|
22
|
+
exports.createSchema = components.createSchema;
|
|
57
23
|
exports.createDocument = createDocument;
|
|
58
|
-
exports.createSchema = createSchema;
|
|
59
|
-
exports.oas30 = oas30;
|
|
60
|
-
exports.oas31 = oas31;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export { CreateDocumentOptions, ZodObjectInputType, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiVersion, createDocument } from './create/document.js';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
import * as
|
|
5
|
-
export { oas30 };
|
|
6
|
-
import * as oas31 from './openapi3-ts/dist/oas31.js';
|
|
1
|
+
export { CreateDocumentOptions, ZodObjectInput, ZodObjectInputType, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBody, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiVersion, createDocument } from './create/document.js';
|
|
2
|
+
export { SchemaResult, createSchema } from './create/schema/schema.js';
|
|
3
|
+
export { Override, isAnyZodType } from './zod.js';
|
|
4
|
+
import * as oas31 from './openapi3-ts/oas31.js';
|
|
7
5
|
export { oas31 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export { CreateDocumentOptions, ZodObjectInputType, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiVersion, createDocument } from './create/document.js';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
import * as
|
|
5
|
-
export { oas30 };
|
|
6
|
-
import * as oas31 from './openapi3-ts/dist/oas31.js';
|
|
1
|
+
export { CreateDocumentOptions, ZodObjectInput, ZodObjectInputType, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBody, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiVersion, createDocument } from './create/document.js';
|
|
2
|
+
export { SchemaResult, createSchema } from './create/schema/schema.js';
|
|
3
|
+
export { Override, isAnyZodType } from './zod.js';
|
|
4
|
+
import * as oas31 from './openapi3-ts/oas31.js';
|
|
7
5
|
export { oas31 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,60 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
const createDocument = (zodOpenApiObject,
|
|
4
|
-
const { paths, webhooks, components
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const createdComponents = createComponents(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
...rest,
|
|
22
|
-
...createdPaths && { paths: createdPaths },
|
|
23
|
-
...createdWebhooks && { webhooks: createdWebhooks },
|
|
24
|
-
...createdComponents && { components: createdComponents }
|
|
25
|
-
};
|
|
1
|
+
import { createRegistry, createPaths, createComponents } from "./components.chunk.mjs";
|
|
2
|
+
import { createSchema } from "./components.chunk.mjs";
|
|
3
|
+
const createDocument = (zodOpenApiObject, opts = {}) => {
|
|
4
|
+
const { paths, webhooks, components, ...rest } = zodOpenApiObject;
|
|
5
|
+
const document = rest;
|
|
6
|
+
const registry = createRegistry(components);
|
|
7
|
+
const createdPaths = createPaths(paths, registry, ["paths"]);
|
|
8
|
+
if (createdPaths) {
|
|
9
|
+
document.paths = createdPaths;
|
|
10
|
+
}
|
|
11
|
+
const createdWebhooks = createPaths(webhooks, registry, ["webhooks"]);
|
|
12
|
+
if (createdWebhooks) {
|
|
13
|
+
document.webhooks = createdWebhooks;
|
|
14
|
+
}
|
|
15
|
+
const createdComponents = createComponents(registry, opts);
|
|
16
|
+
if (Object.keys(createdComponents).length > 0) {
|
|
17
|
+
document.components = createdComponents;
|
|
18
|
+
}
|
|
19
|
+
return document;
|
|
26
20
|
};
|
|
27
|
-
const createSchema = (zodType, opts) => {
|
|
28
|
-
const components = getDefaultComponents(
|
|
29
|
-
{
|
|
30
|
-
schemas: opts == null ? void 0 : opts.components
|
|
31
|
-
},
|
|
32
|
-
opts == null ? void 0 : opts.openapi
|
|
33
|
-
);
|
|
34
|
-
const state = {
|
|
35
|
-
components,
|
|
36
|
-
type: (opts == null ? void 0 : opts.schemaType) ?? "output",
|
|
37
|
-
path: [],
|
|
38
|
-
visited: /* @__PURE__ */ new Set(),
|
|
39
|
-
documentOptions: opts
|
|
40
|
-
};
|
|
41
|
-
const schema = createSchema$1(zodType, state, ["createSchema"]);
|
|
42
|
-
const schemaComponents = createSchemaComponents({}, components);
|
|
43
|
-
return {
|
|
44
|
-
schema,
|
|
45
|
-
components: schemaComponents
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
const oas30 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
49
|
-
__proto__: null
|
|
50
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
51
|
-
const oas31 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
52
|
-
__proto__: null
|
|
53
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
54
21
|
export {
|
|
55
22
|
createDocument,
|
|
56
|
-
createSchema
|
|
57
|
-
extendZodWithOpenApi,
|
|
58
|
-
oas30,
|
|
59
|
-
oas31
|
|
23
|
+
createSchema
|
|
60
24
|
};
|
package/dist/openapi.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
declare const openApiVersions: readonly ["3.
|
|
1
|
+
declare const openApiVersions: readonly ["3.1.0", "3.1.1"];
|
|
2
2
|
type OpenApiVersion = (typeof openApiVersions)[number];
|
|
3
3
|
|
|
4
|
-
export {
|
|
4
|
+
export { openApiVersions };
|
|
5
|
+
export type { OpenApiVersion };
|
|
@@ -59,6 +59,9 @@ interface ComponentsObject extends ISpecificationExtension {
|
|
|
59
59
|
callbacks?: {
|
|
60
60
|
[callback: string]: CallbackObject | ReferenceObject;
|
|
61
61
|
};
|
|
62
|
+
pathItems?: {
|
|
63
|
+
[pathItem: string]: PathItemObject | ReferenceObject;
|
|
64
|
+
};
|
|
62
65
|
}
|
|
63
66
|
interface PathsObject extends ISpecificationExtension {
|
|
64
67
|
[path: string]: PathItemObject;
|
|
@@ -205,6 +208,7 @@ interface ReferenceObject {
|
|
|
205
208
|
}
|
|
206
209
|
type SchemaObjectType = 'integer' | 'number' | 'string' | 'boolean' | 'object' | 'null' | 'array';
|
|
207
210
|
interface SchemaObject extends ISpecificationExtension {
|
|
211
|
+
$ref?: string;
|
|
208
212
|
discriminator?: DiscriminatorObject;
|
|
209
213
|
readOnly?: boolean;
|
|
210
214
|
writeOnly?: boolean;
|
|
@@ -294,4 +298,5 @@ interface SecurityRequirementObject {
|
|
|
294
298
|
[name: string]: string[];
|
|
295
299
|
}
|
|
296
300
|
|
|
297
|
-
export {
|
|
301
|
+
export { ISpecificationExtension, ServerObject };
|
|
302
|
+
export type { BaseParameterObject, CallbackObject, CallbacksObject, ComponentsObject, ContactObject, ContentObject, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, TagObject, XmlObject };
|