@kubb/plugin-zod 3.0.0-alpha.8 → 3.0.0-alpha.9

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.
@@ -3,13 +3,13 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkTSJ74266cjs = require('./chunk-TSJ74266.cjs');
6
+ var _chunk57AHBVYKcjs = require('./chunk-57AHBVYK.cjs');
7
7
 
8
8
  // src/components/index.ts
9
- _chunkTSJ74266cjs.init_cjs_shims.call(void 0, );
9
+ _chunk57AHBVYKcjs.init_cjs_shims.call(void 0, );
10
10
 
11
11
 
12
12
 
13
13
 
14
- exports.OperationSchema = _chunkTSJ74266cjs.OperationSchema; exports.Operations = _chunkTSJ74266cjs.Operations; exports.Schema = _chunkTSJ74266cjs.Schema;
14
+ exports.OperationSchema = _chunk57AHBVYKcjs.OperationSchema; exports.Operations = _chunk57AHBVYKcjs.Operations; exports.Schema = _chunk57AHBVYKcjs.Schema;
15
15
  //# sourceMappingURL=components.cjs.map
@@ -3,7 +3,7 @@ import {
3
3
  Operations,
4
4
  Schema,
5
5
  init_esm_shims
6
- } from "./chunk-CD3EZWBX.js";
6
+ } from "./chunk-CUPQVLRZ.js";
7
7
 
8
8
  // src/components/index.ts
9
9
  init_esm_shims();
package/dist/index.cjs CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkTSJ74266cjs = require('./chunk-TSJ74266.cjs');
5
+ var _chunk57AHBVYKcjs = require('./chunk-57AHBVYK.cjs');
6
6
 
7
7
  // src/index.ts
8
- _chunkTSJ74266cjs.init_cjs_shims.call(void 0, );
8
+ _chunk57AHBVYKcjs.init_cjs_shims.call(void 0, );
9
9
 
10
10
 
11
11
 
12
- exports.pluginZod = _chunkTSJ74266cjs.pluginZod; exports.pluginZodName = _chunkTSJ74266cjs.pluginZodName;
12
+ exports.pluginZod = _chunk57AHBVYKcjs.pluginZod; exports.pluginZodName = _chunk57AHBVYKcjs.pluginZodName;
13
13
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  init_esm_shims,
3
3
  pluginZod,
4
4
  pluginZodName
5
- } from "./chunk-CD3EZWBX.js";
5
+ } from "./chunk-CUPQVLRZ.js";
6
6
 
7
7
  // src/index.ts
8
8
  init_esm_shims();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-zod",
3
- "version": "3.0.0-alpha.8",
3
+ "version": "3.0.0-alpha.9",
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.8",
60
- "@kubb/fs": "3.0.0-alpha.8",
61
- "@kubb/oas": "3.0.0-alpha.8",
62
- "@kubb/parser-ts": "3.0.0-alpha.8",
63
- "@kubb/plugin-oas": "3.0.0-alpha.8",
64
- "@kubb/react": "3.0.0-alpha.8",
65
- "@kubb/types": "3.0.0-alpha.8"
59
+ "@kubb/core": "3.0.0-alpha.9",
60
+ "@kubb/fs": "3.0.0-alpha.9",
61
+ "@kubb/oas": "3.0.0-alpha.9",
62
+ "@kubb/parser-ts": "3.0.0-alpha.9",
63
+ "@kubb/plugin-oas": "3.0.0-alpha.9",
64
+ "@kubb/react": "3.0.0-alpha.9",
65
+ "@kubb/types": "3.0.0-alpha.9"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/react": "^18.3.4",
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.8",
73
- "@kubb/config-ts": "3.0.0-alpha.8",
74
- "@kubb/config-tsup": "3.0.0-alpha.8"
72
+ "@kubb/config-biome": "3.0.0-alpha.9",
73
+ "@kubb/config-ts": "3.0.0-alpha.9",
74
+ "@kubb/config-tsup": "3.0.0-alpha.9"
75
75
  },
76
76
  "peerDependencies": {
77
- "@kubb/react": "3.0.0-alpha.8"
77
+ "@kubb/react": "3.0.0-alpha.9"
78
78
  },
79
79
  "engines": {
80
80
  "node": ">=20"
@@ -1,10 +1,10 @@
1
- import { createReactParser } from '@kubb/plugin-oas'
1
+ import { createReactGenerator } from '@kubb/plugin-oas'
2
+ import { OperationSchema } from './components/OperationSchema.tsx'
3
+ import { Operations } from './components/Operations.tsx'
2
4
  import { Schema } from './components/Schema.tsx'
3
5
  import type { PluginZod } from './types.ts'
4
- import { Operations } from './components/Operations.tsx'
5
- import { OperationSchema } from './components/OperationSchema.tsx'
6
6
 
7
- export const zodParser = createReactParser<PluginZod>({
7
+ export const zodParser = createReactGenerator<PluginZod>({
8
8
  name: 'plugin-zod',
9
9
  Operations({ options }) {
10
10
  if (!options.templates.operations) {
@@ -80,10 +80,10 @@ function RootTemplate({ children }: RootTemplateProps) {
80
80
 
81
81
  const file = pluginManager.getFile({ name: 'operations', extName: '.ts', pluginKey })
82
82
  const imports = Object.entries(transformedOperations)
83
- .map(([_key, { data, operation }], index) => {
83
+ .map(([key, { data, operation }]) => {
84
84
  const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean)
85
85
 
86
- return <File.Import key={index} name={names} root={file.path} path={getFile(operation).path} />
86
+ return <File.Import key={key} name={names} root={file.path} path={getFile(operation).path} />
87
87
  })
88
88
  .filter(Boolean)
89
89
 
@@ -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
  }