@kubb/plugin-zod 3.0.0-alpha.3 → 3.0.0-alpha.31
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 +13 -4
- package/dist/chunk-FLFW72FT.cjs +344 -0
- package/dist/chunk-FLFW72FT.cjs.map +1 -0
- package/dist/chunk-G6GLWNC4.cjs +245 -0
- package/dist/chunk-G6GLWNC4.cjs.map +1 -0
- package/dist/chunk-KMSM5GLX.js +236 -0
- package/dist/chunk-KMSM5GLX.js.map +1 -0
- package/dist/chunk-UONLSRDV.js +337 -0
- package/dist/chunk-UONLSRDV.js.map +1 -0
- package/dist/components.cjs +11 -6
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +20 -19
- package/dist/components.d.ts +20 -19
- package/dist/components.js +2 -10
- package/dist/components.js.map +1 -1
- package/dist/generators.cjs +17 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +10 -0
- package/dist/generators.d.ts +10 -0
- package/dist/generators.js +4 -0
- package/dist/generators.js.map +1 -0
- package/dist/index.cjs +12 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -137
- package/dist/index.d.ts +4 -137
- package/dist/index.js +3 -8
- package/dist/index.js.map +1 -1
- package/dist/types-ryu2n1NA.d.cts +95 -0
- package/dist/types-ryu2n1NA.d.ts +95 -0
- package/package.json +19 -21
- package/src/components/Operations.tsx +19 -103
- package/src/components/Zod.tsx +66 -0
- package/src/components/index.ts +1 -2
- package/src/generators/__snapshots__/anyof.ts +3 -0
- package/src/generators/__snapshots__/createPet.ts +15 -0
- package/src/generators/__snapshots__/createPetWithUnknownTypeAny.ts +13 -0
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +15 -0
- package/src/generators/__snapshots__/deletePet.ts +3 -0
- package/src/generators/__snapshots__/discriminator.ts +3 -0
- package/src/generators/__snapshots__/enumBooleanLiteral.ts +3 -0
- package/src/generators/__snapshots__/enumNamesType.ts +3 -0
- package/src/generators/__snapshots__/enumNullable.ts +3 -0
- package/src/generators/__snapshots__/enumSingleLiteral.ts +3 -0
- package/src/generators/__snapshots__/enumVarNamesType.ts +3 -0
- package/src/generators/__snapshots__/example.ts +3 -0
- package/src/generators/__snapshots__/getPets.ts +18 -0
- package/src/generators/__snapshots__/mixedValueTypeConst.ts +6 -0
- package/src/generators/__snapshots__/nullableString.ts +3 -0
- package/src/generators/__snapshots__/nullableStringUuid.ts +3 -0
- package/src/generators/__snapshots__/nullableStringWithAnyOf.ts +3 -0
- package/src/generators/__snapshots__/numberValueConst.ts +6 -0
- package/src/generators/__snapshots__/oneof.ts +3 -0
- package/src/generators/__snapshots__/operations.ts +46 -0
- package/src/generators/__snapshots__/optionalPetInfer.ts +5 -0
- package/src/generators/__snapshots__/optionalPetTyped.ts +3 -0
- package/src/generators/__snapshots__/order.ts +3 -0
- package/src/generators/__snapshots__/orderDateTyeString.ts +10 -0
- package/src/generators/__snapshots__/orderDateTypeFalse.ts +3 -0
- package/src/generators/__snapshots__/orderDateTypeString.ts +3 -0
- package/src/generators/__snapshots__/pet.ts +3 -0
- package/src/generators/__snapshots__/petArray.ts +6 -0
- package/src/generators/__snapshots__/petCoercion.ts +3 -0
- package/src/generators/__snapshots__/petTupleObject.ts +6 -0
- package/src/generators/__snapshots__/petWithMapper.ts +3 -0
- package/src/generators/__snapshots__/pets.ts +3 -0
- package/src/generators/__snapshots__/recursive.ts +3 -0
- package/src/generators/__snapshots__/showPetById.ts +18 -0
- package/src/generators/__snapshots__/stringValueConst.ts +6 -0
- package/src/generators/__snapshots__/uuidSchema.ts +3 -0
- package/src/generators/index.ts +2 -0
- package/src/generators/operationsGenerator.tsx +39 -0
- package/src/generators/zodGenerator.tsx +121 -0
- package/src/parser/index.ts +34 -10
- package/src/plugin.ts +28 -46
- package/src/types.ts +42 -88
- package/dist/Operations-BlQtRP31.d.cts +0 -47
- package/dist/Operations-BlQtRP31.d.ts +0 -47
- package/dist/chunk-7X3NWYUN.cjs +0 -1242
- package/dist/chunk-7X3NWYUN.cjs.map +0 -1
- package/dist/chunk-XCGVHLYD.js +0 -1242
- package/dist/chunk-XCGVHLYD.js.map +0 -1
- package/src/SchemaGenerator.tsx +0 -22
- package/src/components/OperationSchema.tsx +0 -64
- package/src/components/Schema.tsx +0 -162
- package/src/components/__snapshots__/operations.ts +0 -50
package/dist/index.d.cts
CHANGED
|
@@ -1,142 +1,9 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { ResolvePathOptions, Exclude, Include, Override, Schema } from '@kubb/plugin-oas';
|
|
6
|
-
import { O as Operations } from './Operations-BlQtRP31.cjs';
|
|
7
|
-
import '@kubb/react';
|
|
8
|
-
import 'react';
|
|
9
|
-
|
|
10
|
-
type Templates = {
|
|
11
|
-
operations?: typeof Operations.templates | false;
|
|
12
|
-
};
|
|
13
|
-
type Options = {
|
|
14
|
-
output?: {
|
|
15
|
-
/**
|
|
16
|
-
* Relative path to save the Zod schemas.
|
|
17
|
-
* When output is a file it will save all models inside that file else it will create a file per schema item.
|
|
18
|
-
* @default 'zod'
|
|
19
|
-
*/
|
|
20
|
-
path: string;
|
|
21
|
-
/**
|
|
22
|
-
* Name to be used for the `export * as {{exportAs}} from './'`
|
|
23
|
-
*/
|
|
24
|
-
exportAs?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Add an extension to the generated imports and exports, default it will not use an extension
|
|
27
|
-
*/
|
|
28
|
-
extName?: KubbFile.Extname;
|
|
29
|
-
/**
|
|
30
|
-
* Define what needs to exported, here you can also disable the export of barrel files
|
|
31
|
-
* @default `'barrel'`
|
|
32
|
-
*/
|
|
33
|
-
exportType?: 'barrel' | 'barrelNamed' | false;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Group the Zod schemas based on the provided name.
|
|
37
|
-
*/
|
|
38
|
-
group?: {
|
|
39
|
-
/**
|
|
40
|
-
* Tag will group based on the operation tag inside the Swagger file
|
|
41
|
-
*/
|
|
42
|
-
type: 'tag';
|
|
43
|
-
/**
|
|
44
|
-
* Relative path to save the grouped Zod schemas.
|
|
45
|
-
*
|
|
46
|
-
* `{{tag}}` will be replaced by the current tagName.
|
|
47
|
-
* @example `${output}/{{tag}}Controller` => `zod/PetController`
|
|
48
|
-
* @default `${output}/{{tag}}Controller`
|
|
49
|
-
*/
|
|
50
|
-
output?: string;
|
|
51
|
-
/**
|
|
52
|
-
* Name to be used for the `export * as {{exportAs}} from './`
|
|
53
|
-
* @default `"{{tag}}Schemas"`
|
|
54
|
-
*/
|
|
55
|
-
exportAs?: string;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
59
|
-
*/
|
|
60
|
-
exclude?: Array<Exclude>;
|
|
61
|
-
/**
|
|
62
|
-
* Array containing include parameters to include tags/operations/methods/paths.
|
|
63
|
-
*/
|
|
64
|
-
include?: Array<Include>;
|
|
65
|
-
/**
|
|
66
|
-
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
67
|
-
*/
|
|
68
|
-
override?: Array<Override<ResolvedOptions>>;
|
|
69
|
-
transformers?: {
|
|
70
|
-
/**
|
|
71
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
72
|
-
*/
|
|
73
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
74
|
-
/**
|
|
75
|
-
* Receive schema and baseName(propertName) and return FakerMeta array
|
|
76
|
-
* TODO TODO add docs
|
|
77
|
-
* @beta
|
|
78
|
-
*/
|
|
79
|
-
schema?: (props: {
|
|
80
|
-
schema?: SchemaObject;
|
|
81
|
-
name?: string;
|
|
82
|
-
parentName?: string;
|
|
83
|
-
}, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
84
|
-
};
|
|
85
|
-
mapper?: Record<string, string>;
|
|
86
|
-
/**
|
|
87
|
-
* Make it possible to override one of the templates
|
|
88
|
-
*/
|
|
89
|
-
templates?: Partial<Templates>;
|
|
90
|
-
/**
|
|
91
|
-
* Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
|
|
92
|
-
* False will fallback on a simple z.string() format
|
|
93
|
-
* @default 'string' 'stringOffset' will become the default in Kubb v3
|
|
94
|
-
*/
|
|
95
|
-
dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
96
|
-
/**
|
|
97
|
-
* Which type to use when the Swagger/OpenAPI file is not providing more information
|
|
98
|
-
* @default 'any'
|
|
99
|
-
*/
|
|
100
|
-
unknownType?: 'any' | 'unknown';
|
|
101
|
-
/**
|
|
102
|
-
* Use TypeScript(`@kubb/plugin-ts`) to add type annotation.
|
|
103
|
-
*/
|
|
104
|
-
typed?: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Return Zod generated schema as type with z.infer<TYPE>
|
|
107
|
-
*/
|
|
108
|
-
typedSchema?: boolean;
|
|
109
|
-
/**
|
|
110
|
-
* Use of z.coerce.string() instead of z.string()
|
|
111
|
-
*/
|
|
112
|
-
coercion?: boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Path to Zod
|
|
115
|
-
* It will be used as `import { z } from '${importPath}'`.
|
|
116
|
-
* It allows both relative and absolute path.
|
|
117
|
-
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
118
|
-
* @default 'zod'
|
|
119
|
-
*/
|
|
120
|
-
importPath?: string;
|
|
121
|
-
};
|
|
122
|
-
type ResolvedOptions = {
|
|
123
|
-
extName: KubbFile.Extname | undefined;
|
|
124
|
-
transformers: NonNullable<Options['transformers']>;
|
|
125
|
-
exclude: Options['exclude'];
|
|
126
|
-
include: Options['include'];
|
|
127
|
-
override: Options['override'];
|
|
128
|
-
dateType: NonNullable<Options['dateType']>;
|
|
129
|
-
unknownType: NonNullable<Options['unknownType']>;
|
|
130
|
-
typed: NonNullable<Options['typed']>;
|
|
131
|
-
typedSchema: NonNullable<Options['typedSchema']>;
|
|
132
|
-
templates: NonNullable<Templates>;
|
|
133
|
-
mapper: NonNullable<Options['mapper']>;
|
|
134
|
-
importPath: NonNullable<Options['importPath']>;
|
|
135
|
-
coercion: NonNullable<Options['coercion']>;
|
|
136
|
-
};
|
|
137
|
-
type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
2
|
+
import { O as Options, P as PluginZod } from './types-ryu2n1NA.cjs';
|
|
3
|
+
import '@kubb/oas';
|
|
4
|
+
import '@kubb/plugin-oas';
|
|
138
5
|
|
|
139
6
|
declare const pluginZodName = "plugin-zod";
|
|
140
7
|
declare const pluginZod: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginZod>;
|
|
141
8
|
|
|
142
|
-
export {
|
|
9
|
+
export { PluginZod, pluginZod, pluginZodName };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,142 +1,9 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { ResolvePathOptions, Exclude, Include, Override, Schema } from '@kubb/plugin-oas';
|
|
6
|
-
import { O as Operations } from './Operations-BlQtRP31.js';
|
|
7
|
-
import '@kubb/react';
|
|
8
|
-
import 'react';
|
|
9
|
-
|
|
10
|
-
type Templates = {
|
|
11
|
-
operations?: typeof Operations.templates | false;
|
|
12
|
-
};
|
|
13
|
-
type Options = {
|
|
14
|
-
output?: {
|
|
15
|
-
/**
|
|
16
|
-
* Relative path to save the Zod schemas.
|
|
17
|
-
* When output is a file it will save all models inside that file else it will create a file per schema item.
|
|
18
|
-
* @default 'zod'
|
|
19
|
-
*/
|
|
20
|
-
path: string;
|
|
21
|
-
/**
|
|
22
|
-
* Name to be used for the `export * as {{exportAs}} from './'`
|
|
23
|
-
*/
|
|
24
|
-
exportAs?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Add an extension to the generated imports and exports, default it will not use an extension
|
|
27
|
-
*/
|
|
28
|
-
extName?: KubbFile.Extname;
|
|
29
|
-
/**
|
|
30
|
-
* Define what needs to exported, here you can also disable the export of barrel files
|
|
31
|
-
* @default `'barrel'`
|
|
32
|
-
*/
|
|
33
|
-
exportType?: 'barrel' | 'barrelNamed' | false;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Group the Zod schemas based on the provided name.
|
|
37
|
-
*/
|
|
38
|
-
group?: {
|
|
39
|
-
/**
|
|
40
|
-
* Tag will group based on the operation tag inside the Swagger file
|
|
41
|
-
*/
|
|
42
|
-
type: 'tag';
|
|
43
|
-
/**
|
|
44
|
-
* Relative path to save the grouped Zod schemas.
|
|
45
|
-
*
|
|
46
|
-
* `{{tag}}` will be replaced by the current tagName.
|
|
47
|
-
* @example `${output}/{{tag}}Controller` => `zod/PetController`
|
|
48
|
-
* @default `${output}/{{tag}}Controller`
|
|
49
|
-
*/
|
|
50
|
-
output?: string;
|
|
51
|
-
/**
|
|
52
|
-
* Name to be used for the `export * as {{exportAs}} from './`
|
|
53
|
-
* @default `"{{tag}}Schemas"`
|
|
54
|
-
*/
|
|
55
|
-
exportAs?: string;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
59
|
-
*/
|
|
60
|
-
exclude?: Array<Exclude>;
|
|
61
|
-
/**
|
|
62
|
-
* Array containing include parameters to include tags/operations/methods/paths.
|
|
63
|
-
*/
|
|
64
|
-
include?: Array<Include>;
|
|
65
|
-
/**
|
|
66
|
-
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
67
|
-
*/
|
|
68
|
-
override?: Array<Override<ResolvedOptions>>;
|
|
69
|
-
transformers?: {
|
|
70
|
-
/**
|
|
71
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
72
|
-
*/
|
|
73
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
74
|
-
/**
|
|
75
|
-
* Receive schema and baseName(propertName) and return FakerMeta array
|
|
76
|
-
* TODO TODO add docs
|
|
77
|
-
* @beta
|
|
78
|
-
*/
|
|
79
|
-
schema?: (props: {
|
|
80
|
-
schema?: SchemaObject;
|
|
81
|
-
name?: string;
|
|
82
|
-
parentName?: string;
|
|
83
|
-
}, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
84
|
-
};
|
|
85
|
-
mapper?: Record<string, string>;
|
|
86
|
-
/**
|
|
87
|
-
* Make it possible to override one of the templates
|
|
88
|
-
*/
|
|
89
|
-
templates?: Partial<Templates>;
|
|
90
|
-
/**
|
|
91
|
-
* Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
|
|
92
|
-
* False will fallback on a simple z.string() format
|
|
93
|
-
* @default 'string' 'stringOffset' will become the default in Kubb v3
|
|
94
|
-
*/
|
|
95
|
-
dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
96
|
-
/**
|
|
97
|
-
* Which type to use when the Swagger/OpenAPI file is not providing more information
|
|
98
|
-
* @default 'any'
|
|
99
|
-
*/
|
|
100
|
-
unknownType?: 'any' | 'unknown';
|
|
101
|
-
/**
|
|
102
|
-
* Use TypeScript(`@kubb/plugin-ts`) to add type annotation.
|
|
103
|
-
*/
|
|
104
|
-
typed?: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Return Zod generated schema as type with z.infer<TYPE>
|
|
107
|
-
*/
|
|
108
|
-
typedSchema?: boolean;
|
|
109
|
-
/**
|
|
110
|
-
* Use of z.coerce.string() instead of z.string()
|
|
111
|
-
*/
|
|
112
|
-
coercion?: boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Path to Zod
|
|
115
|
-
* It will be used as `import { z } from '${importPath}'`.
|
|
116
|
-
* It allows both relative and absolute path.
|
|
117
|
-
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
118
|
-
* @default 'zod'
|
|
119
|
-
*/
|
|
120
|
-
importPath?: string;
|
|
121
|
-
};
|
|
122
|
-
type ResolvedOptions = {
|
|
123
|
-
extName: KubbFile.Extname | undefined;
|
|
124
|
-
transformers: NonNullable<Options['transformers']>;
|
|
125
|
-
exclude: Options['exclude'];
|
|
126
|
-
include: Options['include'];
|
|
127
|
-
override: Options['override'];
|
|
128
|
-
dateType: NonNullable<Options['dateType']>;
|
|
129
|
-
unknownType: NonNullable<Options['unknownType']>;
|
|
130
|
-
typed: NonNullable<Options['typed']>;
|
|
131
|
-
typedSchema: NonNullable<Options['typedSchema']>;
|
|
132
|
-
templates: NonNullable<Templates>;
|
|
133
|
-
mapper: NonNullable<Options['mapper']>;
|
|
134
|
-
importPath: NonNullable<Options['importPath']>;
|
|
135
|
-
coercion: NonNullable<Options['coercion']>;
|
|
136
|
-
};
|
|
137
|
-
type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
2
|
+
import { O as Options, P as PluginZod } from './types-ryu2n1NA.js';
|
|
3
|
+
import '@kubb/oas';
|
|
4
|
+
import '@kubb/plugin-oas';
|
|
138
5
|
|
|
139
6
|
declare const pluginZodName = "plugin-zod";
|
|
140
7
|
declare const pluginZod: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginZod>;
|
|
141
8
|
|
|
142
|
-
export {
|
|
9
|
+
export { PluginZod, pluginZod, pluginZodName };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./chunk-XCGVHLYD.js";
|
|
5
|
-
export {
|
|
6
|
-
pluginZod,
|
|
7
|
-
pluginZodName
|
|
8
|
-
};
|
|
1
|
+
export { pluginZod, pluginZodName } from './chunk-KMSM5GLX.js';
|
|
2
|
+
import './chunk-UONLSRDV.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
9
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
|
|
2
|
+
import { SchemaObject } from '@kubb/oas';
|
|
3
|
+
import { ResolvePathOptions, Exclude, Include, Override, Schema, Generator } from '@kubb/plugin-oas';
|
|
4
|
+
|
|
5
|
+
type Options = {
|
|
6
|
+
/**
|
|
7
|
+
* @default 'zod'
|
|
8
|
+
*/
|
|
9
|
+
output?: Output;
|
|
10
|
+
/**
|
|
11
|
+
* Group the Zod schemas based on the provided name.
|
|
12
|
+
*/
|
|
13
|
+
group?: Group;
|
|
14
|
+
/**
|
|
15
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
16
|
+
*/
|
|
17
|
+
exclude?: Array<Exclude>;
|
|
18
|
+
/**
|
|
19
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
20
|
+
*/
|
|
21
|
+
include?: Array<Include>;
|
|
22
|
+
/**
|
|
23
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
24
|
+
*/
|
|
25
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
26
|
+
/**
|
|
27
|
+
* Path to Zod
|
|
28
|
+
* It will be used as `import { z } from '${importPath}'`.
|
|
29
|
+
* It allows both relative and absolute path.
|
|
30
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
31
|
+
* @default 'zod'
|
|
32
|
+
*/
|
|
33
|
+
importPath?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
|
|
36
|
+
* False will fallback on a simple z.string() format
|
|
37
|
+
* @default 'string' 'stringOffset' will become the default in Kubb v3
|
|
38
|
+
*/
|
|
39
|
+
dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
40
|
+
/**
|
|
41
|
+
* Which type to use when the Swagger/OpenAPI file is not providing more information
|
|
42
|
+
* @default 'any'
|
|
43
|
+
*/
|
|
44
|
+
unknownType?: 'any' | 'unknown';
|
|
45
|
+
/**
|
|
46
|
+
* Use TypeScript(`@kubb/plugin-ts`) to add type annotation.
|
|
47
|
+
*/
|
|
48
|
+
typed?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Return Zod generated schema as type with z.infer<TYPE>
|
|
51
|
+
*/
|
|
52
|
+
inferred?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Use of z.coerce.string() instead of z.string()
|
|
55
|
+
*/
|
|
56
|
+
coercion?: boolean;
|
|
57
|
+
operations?: boolean;
|
|
58
|
+
mapper?: Record<string, string>;
|
|
59
|
+
transformers?: {
|
|
60
|
+
/**
|
|
61
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
62
|
+
*/
|
|
63
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
64
|
+
/**
|
|
65
|
+
* Receive schema and baseName(propertName) and return FakerMeta array
|
|
66
|
+
* TODO TODO add docs
|
|
67
|
+
* @beta
|
|
68
|
+
*/
|
|
69
|
+
schema?: (props: {
|
|
70
|
+
schema?: SchemaObject;
|
|
71
|
+
name?: string;
|
|
72
|
+
parentName?: string;
|
|
73
|
+
}, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Define some generators next to the zod generators
|
|
77
|
+
*/
|
|
78
|
+
generators?: Array<Generator<PluginZod>>;
|
|
79
|
+
};
|
|
80
|
+
type ResolvedOptions = {
|
|
81
|
+
output: Output;
|
|
82
|
+
override: NonNullable<Options['override']>;
|
|
83
|
+
transformers: NonNullable<Options['transformers']>;
|
|
84
|
+
dateType: NonNullable<Options['dateType']>;
|
|
85
|
+
unknownType: NonNullable<Options['unknownType']>;
|
|
86
|
+
typed: NonNullable<Options['typed']>;
|
|
87
|
+
inferred: NonNullable<Options['inferred']>;
|
|
88
|
+
mapper: NonNullable<Options['mapper']>;
|
|
89
|
+
importPath: NonNullable<Options['importPath']>;
|
|
90
|
+
coercion: NonNullable<Options['coercion']>;
|
|
91
|
+
operations: NonNullable<Options['coercion']>;
|
|
92
|
+
};
|
|
93
|
+
type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
94
|
+
|
|
95
|
+
export type { Options as O, PluginZod as P };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
|
|
2
|
+
import { SchemaObject } from '@kubb/oas';
|
|
3
|
+
import { ResolvePathOptions, Exclude, Include, Override, Schema, Generator } from '@kubb/plugin-oas';
|
|
4
|
+
|
|
5
|
+
type Options = {
|
|
6
|
+
/**
|
|
7
|
+
* @default 'zod'
|
|
8
|
+
*/
|
|
9
|
+
output?: Output;
|
|
10
|
+
/**
|
|
11
|
+
* Group the Zod schemas based on the provided name.
|
|
12
|
+
*/
|
|
13
|
+
group?: Group;
|
|
14
|
+
/**
|
|
15
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
16
|
+
*/
|
|
17
|
+
exclude?: Array<Exclude>;
|
|
18
|
+
/**
|
|
19
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
20
|
+
*/
|
|
21
|
+
include?: Array<Include>;
|
|
22
|
+
/**
|
|
23
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
24
|
+
*/
|
|
25
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
26
|
+
/**
|
|
27
|
+
* Path to Zod
|
|
28
|
+
* It will be used as `import { z } from '${importPath}'`.
|
|
29
|
+
* It allows both relative and absolute path.
|
|
30
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
31
|
+
* @default 'zod'
|
|
32
|
+
*/
|
|
33
|
+
importPath?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
|
|
36
|
+
* False will fallback on a simple z.string() format
|
|
37
|
+
* @default 'string' 'stringOffset' will become the default in Kubb v3
|
|
38
|
+
*/
|
|
39
|
+
dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
40
|
+
/**
|
|
41
|
+
* Which type to use when the Swagger/OpenAPI file is not providing more information
|
|
42
|
+
* @default 'any'
|
|
43
|
+
*/
|
|
44
|
+
unknownType?: 'any' | 'unknown';
|
|
45
|
+
/**
|
|
46
|
+
* Use TypeScript(`@kubb/plugin-ts`) to add type annotation.
|
|
47
|
+
*/
|
|
48
|
+
typed?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Return Zod generated schema as type with z.infer<TYPE>
|
|
51
|
+
*/
|
|
52
|
+
inferred?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Use of z.coerce.string() instead of z.string()
|
|
55
|
+
*/
|
|
56
|
+
coercion?: boolean;
|
|
57
|
+
operations?: boolean;
|
|
58
|
+
mapper?: Record<string, string>;
|
|
59
|
+
transformers?: {
|
|
60
|
+
/**
|
|
61
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
62
|
+
*/
|
|
63
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
64
|
+
/**
|
|
65
|
+
* Receive schema and baseName(propertName) and return FakerMeta array
|
|
66
|
+
* TODO TODO add docs
|
|
67
|
+
* @beta
|
|
68
|
+
*/
|
|
69
|
+
schema?: (props: {
|
|
70
|
+
schema?: SchemaObject;
|
|
71
|
+
name?: string;
|
|
72
|
+
parentName?: string;
|
|
73
|
+
}, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Define some generators next to the zod generators
|
|
77
|
+
*/
|
|
78
|
+
generators?: Array<Generator<PluginZod>>;
|
|
79
|
+
};
|
|
80
|
+
type ResolvedOptions = {
|
|
81
|
+
output: Output;
|
|
82
|
+
override: NonNullable<Options['override']>;
|
|
83
|
+
transformers: NonNullable<Options['transformers']>;
|
|
84
|
+
dateType: NonNullable<Options['dateType']>;
|
|
85
|
+
unknownType: NonNullable<Options['unknownType']>;
|
|
86
|
+
typed: NonNullable<Options['typed']>;
|
|
87
|
+
inferred: NonNullable<Options['inferred']>;
|
|
88
|
+
mapper: NonNullable<Options['mapper']>;
|
|
89
|
+
importPath: NonNullable<Options['importPath']>;
|
|
90
|
+
coercion: NonNullable<Options['coercion']>;
|
|
91
|
+
operations: NonNullable<Options['coercion']>;
|
|
92
|
+
};
|
|
93
|
+
type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
94
|
+
|
|
95
|
+
export type { Options as O, PluginZod as P };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-zod",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.31",
|
|
4
4
|
"description": "Generator plugin-zod",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -25,14 +25,16 @@
|
|
|
25
25
|
"require": "./dist/index.cjs",
|
|
26
26
|
"default": "./dist/index.cjs"
|
|
27
27
|
},
|
|
28
|
+
"./generators": {
|
|
29
|
+
"import": "./dist/generators.js",
|
|
30
|
+
"require": "./dist/generators.cjs",
|
|
31
|
+
"default": "./dist/generators.cjs"
|
|
32
|
+
},
|
|
28
33
|
"./components": {
|
|
29
34
|
"import": "./dist/components.js",
|
|
30
35
|
"require": "./dist/components.cjs",
|
|
31
36
|
"default": "./dist/components.cjs"
|
|
32
37
|
},
|
|
33
|
-
"./oas": {
|
|
34
|
-
"types": "./dist/oas.d.ts"
|
|
35
|
-
},
|
|
36
38
|
"./package.json": "./package.json",
|
|
37
39
|
"./*": "./*"
|
|
38
40
|
},
|
|
@@ -44,8 +46,8 @@
|
|
|
44
46
|
"components": [
|
|
45
47
|
"./dist/components.d.ts"
|
|
46
48
|
],
|
|
47
|
-
"
|
|
48
|
-
"./dist/
|
|
49
|
+
"generators": [
|
|
50
|
+
"./dist/generators.d.ts"
|
|
49
51
|
]
|
|
50
52
|
}
|
|
51
53
|
},
|
|
@@ -56,25 +58,21 @@
|
|
|
56
58
|
"!/**/__tests__/**"
|
|
57
59
|
],
|
|
58
60
|
"dependencies": {
|
|
59
|
-
"@kubb/
|
|
60
|
-
"@kubb/
|
|
61
|
-
"@kubb/
|
|
62
|
-
"@kubb/
|
|
63
|
-
"@kubb/plugin-
|
|
64
|
-
"@kubb/
|
|
65
|
-
"@kubb/
|
|
61
|
+
"@kubb/fs": "3.0.0-alpha.31",
|
|
62
|
+
"@kubb/oas": "3.0.0-alpha.31",
|
|
63
|
+
"@kubb/parser-ts": "3.0.0-alpha.31",
|
|
64
|
+
"@kubb/plugin-oas": "3.0.0-alpha.31",
|
|
65
|
+
"@kubb/plugin-ts": "3.0.0-alpha.31",
|
|
66
|
+
"@kubb/core": "3.0.0-alpha.31",
|
|
67
|
+
"@kubb/react": "3.0.0-alpha.31"
|
|
66
68
|
},
|
|
67
69
|
"devDependencies": {
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"tsup": "^8.2.4",
|
|
72
|
-
"@kubb/config-biome": "3.0.0-alpha.3",
|
|
73
|
-
"@kubb/config-ts": "3.0.0-alpha.3",
|
|
74
|
-
"@kubb/config-tsup": "3.0.0-alpha.3"
|
|
70
|
+
"tsup": "^8.3.0",
|
|
71
|
+
"@kubb/config-ts": "3.0.0-alpha.31",
|
|
72
|
+
"@kubb/config-tsup": "3.0.0-alpha.31"
|
|
75
73
|
},
|
|
76
74
|
"peerDependencies": {
|
|
77
|
-
"@kubb/react": "3.0.0-alpha.
|
|
75
|
+
"@kubb/react": "3.0.0-alpha.31"
|
|
78
76
|
},
|
|
79
77
|
"engines": {
|
|
80
78
|
"node": ">=20"
|