@kubb/plugin-zod 3.0.0-alpha.1 → 3.0.0-alpha.11

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.
@@ -1,11 +1,21 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ 'use strict';
2
2
 
3
+ var chunkWDPKVCXH_cjs = require('./chunk-WDPKVCXH.cjs');
3
4
 
5
+ // src/components/index.ts
6
+ chunkWDPKVCXH_cjs.init_cjs_shims();
4
7
 
5
- var _chunk64Z35OF4cjs = require('./chunk-64Z35OF4.cjs');
6
-
7
-
8
-
9
-
10
- exports.OperationSchema = _chunk64Z35OF4cjs.OperationSchema; exports.Operations = _chunk64Z35OF4cjs.Operations; exports.Schema = _chunk64Z35OF4cjs.Schema;
8
+ Object.defineProperty(exports, "OperationSchema", {
9
+ enumerable: true,
10
+ get: function () { return chunkWDPKVCXH_cjs.OperationSchema; }
11
+ });
12
+ Object.defineProperty(exports, "Operations", {
13
+ enumerable: true,
14
+ get: function () { return chunkWDPKVCXH_cjs.Operations; }
15
+ });
16
+ Object.defineProperty(exports, "Schema", {
17
+ enumerable: true,
18
+ get: function () { return chunkWDPKVCXH_cjs.Schema; }
19
+ });
20
+ //# sourceMappingURL=components.cjs.map
11
21
  //# sourceMappingURL=components.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-zod/dist/components.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,0JAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-zod/dist/components.cjs"}
1
+ {"version":3,"sources":["../src/components/index.ts"],"names":["init_cjs_shims"],"mappings":";;;;;AAAAA,gCAAA,EAAA","file":"components.cjs","sourcesContent":["export { OperationSchema } from './OperationSchema.tsx'\nexport { Operations } from './Operations.tsx'\nexport { Schema } from './Schema.tsx'\n"]}
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
- export { O as Operations } from './Operations-BlQtRP31.cjs';
2
+ export { O as Operations } from './Operations-BG26e_MW.cjs';
3
3
  import '@kubb/oas';
4
- import '@kubb/react';
4
+ import '@kubb/react/types';
5
5
 
6
6
  type Props$1 = {
7
7
  description?: string;
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
- export { O as Operations } from './Operations-BlQtRP31.js';
2
+ export { O as Operations } from './Operations-BG26e_MW.js';
3
3
  import '@kubb/oas';
4
- import '@kubb/react';
4
+ import '@kubb/react/types';
5
5
 
6
6
  type Props$1 = {
7
7
  description?: string;
@@ -1,11 +1,7 @@
1
- import {
2
- OperationSchema,
3
- Operations,
4
- Schema
5
- } from "./chunk-V6DUT3EA.js";
6
- export {
7
- OperationSchema,
8
- Operations,
9
- Schema
10
- };
1
+ import { init_esm_shims } from './chunk-Z5LNW4XC.js';
2
+ export { OperationSchema, Operations, Schema } from './chunk-Z5LNW4XC.js';
3
+
4
+ // src/components/index.ts
5
+ init_esm_shims();
6
+ //# sourceMappingURL=components.js.map
11
7
  //# sourceMappingURL=components.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/components/index.ts"],"names":[],"mappings":";;;;AAAA,cAAA,EAAA","file":"components.js","sourcesContent":["export { OperationSchema } from './OperationSchema.tsx'\nexport { Operations } from './Operations.tsx'\nexport { Schema } from './Schema.tsx'\n"]}
package/dist/index.cjs CHANGED
@@ -1,9 +1,17 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ 'use strict';
2
2
 
3
+ var chunkWDPKVCXH_cjs = require('./chunk-WDPKVCXH.cjs');
3
4
 
4
- var _chunk64Z35OF4cjs = require('./chunk-64Z35OF4.cjs');
5
+ // src/index.ts
6
+ chunkWDPKVCXH_cjs.init_cjs_shims();
5
7
 
6
-
7
-
8
- exports.pluginZod = _chunk64Z35OF4cjs.pluginZod; exports.pluginZodName = _chunk64Z35OF4cjs.pluginZodName;
8
+ Object.defineProperty(exports, "pluginZod", {
9
+ enumerable: true,
10
+ get: function () { return chunkWDPKVCXH_cjs.pluginZod; }
11
+ });
12
+ Object.defineProperty(exports, "pluginZodName", {
13
+ enumerable: true,
14
+ get: function () { return chunkWDPKVCXH_cjs.pluginZodName; }
15
+ });
16
+ //# sourceMappingURL=index.cjs.map
9
17
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-zod/dist/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,yGAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-zod/dist/index.cjs"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["init_cjs_shims"],"mappings":";;;;;AAAAA,gCAAA,EAAA","file":"index.cjs","sourcesContent":["export { pluginZod, pluginZodName } from './plugin.ts'\nexport type { PluginZod } from './types.ts'\n"]}
package/dist/index.d.cts CHANGED
@@ -3,8 +3,8 @@ import { PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
3
3
  import * as KubbFile from '@kubb/fs/types';
4
4
  import { SchemaObject } from '@kubb/oas';
5
5
  import { ResolvePathOptions, Exclude, Include, Override, Schema } from '@kubb/plugin-oas';
6
- import { O as Operations } from './Operations-BlQtRP31.cjs';
7
- import '@kubb/react';
6
+ import { O as Operations } from './Operations-BG26e_MW.cjs';
7
+ import '@kubb/react/types';
8
8
  import 'react';
9
9
 
10
10
  type Templates = {
package/dist/index.d.ts CHANGED
@@ -3,8 +3,8 @@ import { PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
3
3
  import * as KubbFile from '@kubb/fs/types';
4
4
  import { SchemaObject } from '@kubb/oas';
5
5
  import { ResolvePathOptions, Exclude, Include, Override, Schema } from '@kubb/plugin-oas';
6
- import { O as Operations } from './Operations-BlQtRP31.js';
7
- import '@kubb/react';
6
+ import { O as Operations } from './Operations-BG26e_MW.js';
7
+ import '@kubb/react/types';
8
8
  import 'react';
9
9
 
10
10
  type Templates = {
package/dist/index.js CHANGED
@@ -1,9 +1,7 @@
1
- import {
2
- pluginZod,
3
- pluginZodName
4
- } from "./chunk-V6DUT3EA.js";
5
- export {
6
- pluginZod,
7
- pluginZodName
8
- };
1
+ import { init_esm_shims } from './chunk-Z5LNW4XC.js';
2
+ export { pluginZod, pluginZodName } from './chunk-Z5LNW4XC.js';
3
+
4
+ // src/index.ts
5
+ init_esm_shims();
6
+ //# sourceMappingURL=index.js.map
9
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,cAAA,EAAA","file":"index.js","sourcesContent":["export { pluginZod, pluginZodName } from './plugin.ts'\nexport type { PluginZod } from './types.ts'\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-zod",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-alpha.11",
4
4
  "description": "Generator plugin-zod",
5
5
  "keywords": [
6
6
  "typescript",
@@ -56,25 +56,25 @@
56
56
  "!/**/__tests__/**"
57
57
  ],
58
58
  "dependencies": {
59
- "@kubb/core": "3.0.0-alpha.1",
60
- "@kubb/fs": "3.0.0-alpha.1",
61
- "@kubb/oas": "3.0.0-alpha.1",
62
- "@kubb/parser-ts": "3.0.0-alpha.1",
63
- "@kubb/plugin-oas": "3.0.0-alpha.1",
64
- "@kubb/react": "3.0.0-alpha.1",
65
- "@kubb/types": "3.0.0-alpha.1"
59
+ "@kubb/core": "3.0.0-alpha.11",
60
+ "@kubb/fs": "3.0.0-alpha.11",
61
+ "@kubb/oas": "3.0.0-alpha.11",
62
+ "@kubb/parser-ts": "3.0.0-alpha.11",
63
+ "@kubb/plugin-oas": "3.0.0-alpha.11",
64
+ "@kubb/react": "3.0.0-alpha.11",
65
+ "@kubb/types": "3.0.0-alpha.11"
66
66
  },
67
67
  "devDependencies": {
68
- "@types/react": "^18.3.4",
68
+ "@types/react": "^18.3.5",
69
69
  "prettier": "^3.3.3",
70
70
  "react": "^18.3.1",
71
71
  "tsup": "^8.2.4",
72
- "@kubb/config-biome": "3.0.0-alpha.1",
73
- "@kubb/config-ts": "3.0.0-alpha.1",
74
- "@kubb/config-tsup": "3.0.0-alpha.1"
72
+ "@kubb/config-biome": "3.0.0-alpha.11",
73
+ "@kubb/config-ts": "3.0.0-alpha.11",
74
+ "@kubb/config-tsup": "3.0.0-alpha.11"
75
75
  },
76
76
  "peerDependencies": {
77
- "@kubb/react": "3.0.0-alpha.1"
77
+ "@kubb/react": "3.0.0-alpha.11"
78
78
  },
79
79
  "engines": {
80
80
  "node": ">=20"
@@ -1,31 +1,22 @@
1
- import type { SchemaObject } from '@kubb/oas'
2
- import { SchemaGenerator as Generator } from '@kubb/plugin-oas'
3
- import type { SchemaMethodResult } from '@kubb/plugin-oas'
4
- import { Oas } from '@kubb/plugin-oas/components'
5
- import { App, createRoot } from '@kubb/react'
1
+ import { createReactGenerator } from '@kubb/plugin-oas'
2
+ import { OperationSchema } from './components/OperationSchema.tsx'
3
+ import { Operations } from './components/Operations.tsx'
6
4
  import { Schema } from './components/Schema.tsx'
7
- import type { FileMeta, PluginZod } from './types.ts'
5
+ import type { PluginZod } from './types.ts'
8
6
 
9
- export class SchemaGenerator extends Generator<PluginZod['resolvedOptions'], PluginZod> {
10
- async schema(name: string, schema: SchemaObject, options: PluginZod['resolvedOptions']): SchemaMethodResult<FileMeta> {
11
- const { oas, pluginManager, plugin, mode, output } = this.context
7
+ export const zodParser = createReactGenerator<PluginZod>({
8
+ name: 'plugin-zod',
9
+ Operations({ options }) {
10
+ if (!options.templates.operations) {
11
+ return null
12
+ }
12
13
 
13
- const root = createRoot({
14
- logger: pluginManager.logger,
15
- })
16
-
17
- const tree = this.parse({ schema, name })
18
-
19
- root.render(
20
- <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>
21
- <Oas oas={oas}>
22
- <Oas.Schema name={name} value={schema} tree={tree}>
23
- <Schema.File />
24
- </Oas.Schema>
25
- </Oas>
26
- </App>,
27
- )
28
-
29
- return root.files
30
- }
31
- }
14
+ return <Operations.File templates={options.templates.operations} />
15
+ },
16
+ Operation() {
17
+ return <OperationSchema.File />
18
+ },
19
+ Schema({ schema, name }) {
20
+ return <Schema.File />
21
+ },
22
+ })
@@ -1,9 +1,7 @@
1
- import { schemaKeywords } from '@kubb/plugin-oas'
1
+ import { SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'
2
2
  import { Oas } from '@kubb/plugin-oas/components'
3
3
  import { useOas, useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'
4
- import { File, Parser, useApp } from '@kubb/react'
5
-
6
- import { SchemaGenerator } from '../SchemaGenerator.tsx'
4
+ import { File, useApp } from '@kubb/react'
7
5
 
8
6
  import type { OperationSchema as OperationSchemaType } from '@kubb/plugin-oas'
9
7
  import type { ReactNode } from 'react'
@@ -47,20 +45,16 @@ OperationSchema.File = function ({}: FileProps): ReactNode {
47
45
 
48
46
  return (
49
47
  <Oas.Schema key={i} name={name} value={schema} tree={[...tree, optional ? { keyword: schemaKeywords.optional } : undefined].filter(Boolean)}>
50
- {mode === 'split' && <Oas.Schema.Imports extName={plugin.options.extName} />}
51
- <File.Source>
52
- <OperationSchema description={description} keysToOmit={keysToOmit} />
53
- </File.Source>
48
+ {mode === 'split' && <Oas.Schema.Imports isTypeOnly={false} />}
49
+ <OperationSchema description={description} keysToOmit={keysToOmit} />
54
50
  </Oas.Schema>
55
51
  )
56
52
  }
57
53
 
58
54
  return (
59
- <Parser language="typescript">
60
- <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
61
- <File.Import name={['z']} path={plugin.options.importPath} />
62
- {items.map(mapItem)}
63
- </File>
64
- </Parser>
55
+ <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
56
+ <File.Import name={['z']} path={plugin.options.importPath} />
57
+ {items.map(mapItem)}
58
+ </File>
65
59
  )
66
60
  }
@@ -1,9 +1,9 @@
1
1
  import { useOperationManager, useOperations } from '@kubb/plugin-oas/hooks'
2
- import { Const, File, Parser, useApp } from '@kubb/react'
2
+ import { Const, File, useApp } from '@kubb/react'
3
3
 
4
4
  import transformers from '@kubb/core/transformers'
5
5
  import type { HttpMethod, Operation } from '@kubb/oas'
6
- import type { KubbNode } from '@kubb/react'
6
+ import type { KubbNode } from '@kubb/react/types'
7
7
  import type { ComponentProps, ComponentType } from 'react'
8
8
  import type { FileMeta, PluginZod } from '../types.ts'
9
9
 
@@ -46,12 +46,16 @@ function Template({ operationsName, pathsName, operations }: TemplateProps): Kub
46
46
 
47
47
  return (
48
48
  <>
49
- <Const export name={operationsName} asConst>
50
- {`{${transformers.stringifyObject(operationsJSON)}}`}
51
- </Const>
52
- <Const export name={pathsName} asConst>
53
- {`{${transformers.stringifyObject(pathsJSON)}}`}
54
- </Const>
49
+ <File.Source name={operationsName} isExportable isIndexable>
50
+ <Const export name={operationsName} asConst>
51
+ {`{${transformers.stringifyObject(operationsJSON)}}`}
52
+ </Const>
53
+ </File.Source>
54
+ <File.Source name={pathsName} isExportable isIndexable>
55
+ <Const export name={pathsName} asConst>
56
+ {`{${transformers.stringifyObject(pathsJSON)}}`}
57
+ </Const>
58
+ </File.Source>
55
59
  </>
56
60
  )
57
61
  }
@@ -76,20 +80,18 @@ function RootTemplate({ children }: RootTemplateProps) {
76
80
 
77
81
  const file = pluginManager.getFile({ name: 'operations', extName: '.ts', pluginKey })
78
82
  const imports = Object.entries(transformedOperations)
79
- .map(([_key, { data, operation }], index) => {
83
+ .map(([key, { data, operation }]) => {
80
84
  const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean)
81
85
 
82
- return <File.Import key={index} extName={extName} name={names} root={file.path} path={getFile(operation).path} />
86
+ return <File.Import key={key} name={names} root={file.path} path={getFile(operation).path} />
83
87
  })
84
88
  .filter(Boolean)
85
89
 
86
90
  return (
87
- <Parser language="typescript">
88
- <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta} exportable={false}>
89
- {mode === 'split' && imports}
90
- <File.Source>{children}</File.Source>
91
- </File>
92
- </Parser>
91
+ <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
92
+ {mode === 'split' && imports}
93
+ {children}
94
+ </File>
93
95
  )
94
96
  }
95
97
 
@@ -46,15 +46,17 @@ export function Schema(props: Props): ReactNode {
46
46
 
47
47
  if (!tree.length) {
48
48
  return (
49
- <Const
50
- name={resolvedName}
51
- export
52
- JSDoc={{
53
- comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean),
54
- }}
55
- >
56
- undefined
57
- </Const>
49
+ <File.Source name={resolvedName} isExportable isIndexable>
50
+ <Const
51
+ name={resolvedName}
52
+ export
53
+ JSDoc={{
54
+ comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean),
55
+ }}
56
+ >
57
+ undefined
58
+ </Const>
59
+ </File.Source>
58
60
  )
59
61
  }
60
62
 
@@ -77,25 +79,29 @@ export function Schema(props: Props): ReactNode {
77
79
 
78
80
  return (
79
81
  <>
80
- <Const
81
- export
82
- name={resolvedName}
83
- JSDoc={{
84
- comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean),
85
- }}
86
- >
87
- {[
88
- output,
89
- keysToOmit?.length ? `${suffix}(z.object({ ${keysToOmit.map((key) => `${key}: z.never()`).join(',')} }))` : undefined,
90
- withTypeAnnotation && typeName ? ` as z.ZodType<${typeName}>` : '',
91
- ]
92
- .filter(Boolean)
93
- .join('') || ''}
94
- </Const>
82
+ <File.Source name={resolvedName} isExportable isIndexable>
83
+ <Const
84
+ export
85
+ name={resolvedName}
86
+ JSDoc={{
87
+ comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean),
88
+ }}
89
+ >
90
+ {[
91
+ output,
92
+ keysToOmit?.length ? `${suffix}(z.object({ ${keysToOmit.map((key) => `${key}: z.never()`).join(',')} }))` : undefined,
93
+ withTypeAnnotation && typeName ? ` as z.ZodType<${typeName}>` : '',
94
+ ]
95
+ .filter(Boolean)
96
+ .join('') || ''}
97
+ </Const>
98
+ </File.Source>
95
99
  {typedSchema && (
96
- <Type export name={resolvedTypeName}>
97
- {`z.infer<typeof ${resolvedName}>`}
98
- </Type>
100
+ <File.Source name={resolvedTypeName} isExportable isIndexable isTypeOnly>
101
+ <Type export name={resolvedTypeName}>
102
+ {`z.infer<typeof ${resolvedName}>`}
103
+ </Type>
104
+ </File.Source>
99
105
  )}
100
106
  </>
101
107
  )
@@ -110,25 +116,14 @@ Schema.File = function ({}: FileProps): ReactNode {
110
116
  options: { typed },
111
117
  },
112
118
  } = useApp<PluginZod>()
113
- const { tree, schema } = useSchema()
114
-
115
- const withData = tree.some(
116
- (schema) =>
117
- schema.keyword === schemaKeywords.array ||
118
- schema.keyword === schemaKeywords.and ||
119
- schema.keyword === schemaKeywords.object ||
120
- schema.keyword === schemaKeywords.union ||
121
- schema.keyword === schemaKeywords.tuple,
122
- )
119
+ const { schema } = useSchema()
123
120
 
124
121
  const withTypeAnnotation = !!typed
125
122
 
126
123
  return (
127
124
  <Oas.Schema.File output={pluginManager.config.output.path}>
128
125
  <Schema.Imports />
129
- <File.Source>
130
- <Schema withTypeAnnotation={withTypeAnnotation} description={schema?.description} />
131
- </File.Source>
126
+ <Schema withTypeAnnotation={withTypeAnnotation} description={schema?.description} />
132
127
  </Oas.Schema.File>
133
128
  )
134
129
  }
@@ -1,50 +1,53 @@
1
- export const operations = {
2
- 'get_pets-pet-id': {
3
- request: undefined,
1
+ export const operations = {"get_pets-pet-id": {
2
+ request: undefined,
4
3
  parameters: {
5
- path: undefined,
6
- query: undefined,
7
- header: undefined,
8
- },
4
+ path: undefined,
5
+ query: undefined,
6
+ header: undefined
7
+ },
9
8
  responses: {
10
- 200: GetPetsPetIdQueryResponse,
11
- default: GetPetsPetIdQueryResponse,
12
- },
13
- errors: {},
14
- },
15
- listPets: {
16
- request: undefined,
9
+ 200: getPetsPetIdQueryResponse,
10
+ default: getPetsPetIdQueryResponse
11
+ },
12
+ errors: {
13
+
14
+ }
15
+ },
16
+ "listPets": {
17
+ request: undefined,
17
18
  parameters: {
18
- path: undefined,
19
- query: ListPetsQueryParams,
20
- header: undefined,
21
- },
19
+ path: undefined,
20
+ query: listPetsQueryParams,
21
+ header: undefined
22
+ },
22
23
  responses: {
23
- 200: ListPetsQueryResponse,
24
- default: ListPetsQueryResponse,
25
- },
26
- errors: {},
27
- },
28
- createPets: {
29
- request: CreatePetsMutationRequest,
24
+ 200: listPetsQueryResponse,
25
+ default: listPetsQueryResponse
26
+ },
27
+ errors: {
28
+
29
+ }
30
+ },
31
+ "createPets": {
32
+ request: createPetsMutationRequest,
30
33
  parameters: {
31
- path: undefined,
32
- query: undefined,
33
- header: undefined,
34
- },
34
+ path: undefined,
35
+ query: undefined,
36
+ header: undefined
37
+ },
35
38
  responses: {
36
- 201: CreatePetsMutationResponse,
37
- default: CreatePetsMutationResponse,
38
- },
39
- errors: {},
40
- },
41
- } as const
42
- export const paths = {
43
- '/pets/{pet_id}': {
44
- get: operations['get_pets-pet-id'],
45
- },
46
- '/pets': {
47
- get: operations['listPets'],
48
- post: operations['createPets'],
49
- },
50
- } as const
39
+ 201: createPetsMutationResponse,
40
+ default: createPetsMutationResponse
41
+ },
42
+ errors: {
43
+
44
+ }
45
+ }} as const
46
+
47
+ export const paths = {"/pets/{pet_id}": {
48
+ get: operations["get_pets-pet-id"]
49
+ },
50
+ "/pets": {
51
+ get: operations["listPets"],
52
+ post: operations["createPets"]
53
+ }} as const
@@ -12,7 +12,11 @@ export const zodKeywordMapper = {
12
12
  .join('')
13
13
  },
14
14
  integer: (coercion?: boolean, min?: number, max?: number) => {
15
- return [coercion ? 'z.coerce.number()' : 'z.number()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]
15
+ return [
16
+ coercion ? 'z.coerce.number().int()' : 'z.number().int()',
17
+ min !== undefined ? `.min(${min})` : undefined,
18
+ max !== undefined ? `.max(${max})` : undefined,
19
+ ]
16
20
  .filter(Boolean)
17
21
  .join('')
18
22
  },
@@ -308,10 +312,14 @@ export function parse(parent: Schema | undefined, current: Schema, options: Pars
308
312
  return zodKeywordMapper.string(options.coercion)
309
313
  }
310
314
 
311
- if (isKeyword(current, schemaKeywords.number) || isKeyword(current, schemaKeywords.integer)) {
315
+ if (isKeyword(current, schemaKeywords.number)) {
312
316
  return zodKeywordMapper.number(options.coercion)
313
317
  }
314
318
 
319
+ if (isKeyword(current, schemaKeywords.integer)) {
320
+ return zodKeywordMapper.integer(options.coercion)
321
+ }
322
+
315
323
  if (isKeyword(current, schemaKeywords.min)) {
316
324
  return zodKeywordMapper.min(current.args)
317
325
  }