@kubb/plugin-zod 3.0.0-alpha.0 → 3.0.0-alpha.10

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 +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":["/home/runner/work/kubb/kubb/packages/plugin-zod/dist/components.cjs","../src/components/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACPA,8CAAA,CAAA;ADSA;AACE;AACA;AACA;AACF,0JAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-zod/dist/components.cjs","sourcesContent":[null,"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,8 +1,12 @@
1
1
  import {
2
2
  OperationSchema,
3
3
  Operations,
4
- Schema
5
- } from "./chunk-OXCOZC6T.js";
4
+ Schema,
5
+ init_esm_shims
6
+ } from "./chunk-CUPQVLRZ.js";
7
+
8
+ // src/components/index.ts
9
+ init_esm_shims();
6
10
  export {
7
11
  OperationSchema,
8
12
  Operations,
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/components/index.ts"],"sourcesContent":["export { OperationSchema } from './OperationSchema.tsx'\nexport { Operations } from './Operations.tsx'\nexport { Schema } from './Schema.tsx'\n"],"mappings":";;;;;;;;AAAA;","names":[]}
package/dist/index.cjs CHANGED
@@ -1,16 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunk7IAXQL4Tcjs = require('./chunk-7IAXQL4T.cjs');
5
-
6
- // src/index.ts
7
- var definePluginDefault = _chunk7IAXQL4Tcjs.pluginZod;
8
- var definePlugin = _chunk7IAXQL4Tcjs.pluginZod;
9
- var src_default = definePluginDefault;
10
4
 
5
+ var _chunk57AHBVYKcjs = require('./chunk-57AHBVYK.cjs');
11
6
 
7
+ // src/index.ts
8
+ _chunk57AHBVYKcjs.init_cjs_shims.call(void 0, );
12
9
 
13
10
 
14
11
 
15
- exports.default = src_default; exports.definePlugin = definePlugin; exports.pluginZod = _chunk7IAXQL4Tcjs.pluginZod; exports.pluginZodName = _chunk7IAXQL4Tcjs.pluginZodName;
12
+ exports.pluginZod = _chunk57AHBVYKcjs.pluginZod; exports.pluginZodName = _chunk57AHBVYKcjs.pluginZodName;
16
13
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-zod/dist/index.cjs","../src/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACGA,IAAM,oBAAA,EAAsB,2BAAA;AAIrB,IAAM,aAAA,EAAe,2BAAA;AAE5B,IAAO,YAAA,EAAQ,mBAAA;ADLf;AACE;AACA;AACA;AACA;AACF,6KAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-zod/dist/index.cjs","sourcesContent":[null,"import { pluginZod } from './plugin.ts'\n\nexport { pluginZod, pluginZodName } from './plugin.ts'\nexport type { PluginZod } from './types.ts'\n\n/**\n * @deprecated Use `import { pluginZod } from '@kubb/plugin-zod'` instead\n */\nconst definePluginDefault = pluginZod\n/**\n * @deprecated Use `import { pluginZod } from '@kubb/plugin-zod'` instead\n */\nexport const definePlugin = pluginZod\n\nexport default definePluginDefault\n"]}
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-zod/dist/index.cjs","../src/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,8CAAA,CAAA;ADQA;AACE;AACA;AACF,yGAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-zod/dist/index.cjs","sourcesContent":[null,"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 = {
@@ -135,22 +135,8 @@ type ResolvedOptions = {
135
135
  coercion: NonNullable<Options['coercion']>;
136
136
  };
137
137
  type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
138
- declare module '@kubb/core' {
139
- interface _Register {
140
- ['@kubb/plugin-zod']: PluginZod;
141
- }
142
- }
143
138
 
144
139
  declare const pluginZodName = "plugin-zod";
145
140
  declare const pluginZod: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginZod>;
146
141
 
147
- /**
148
- * @deprecated Use `import { pluginZod } from '@kubb/plugin-zod'` instead
149
- */
150
- declare const definePluginDefault: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginZod>;
151
- /**
152
- * @deprecated Use `import { pluginZod } from '@kubb/plugin-zod'` instead
153
- */
154
- declare const definePlugin: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginZod>;
155
-
156
- export { type PluginZod, definePluginDefault as default, definePlugin, pluginZod, pluginZodName };
142
+ export { type PluginZod, pluginZod, pluginZodName };
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 = {
@@ -135,22 +135,8 @@ type ResolvedOptions = {
135
135
  coercion: NonNullable<Options['coercion']>;
136
136
  };
137
137
  type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
138
- declare module '@kubb/core' {
139
- interface _Register {
140
- ['@kubb/plugin-zod']: PluginZod;
141
- }
142
- }
143
138
 
144
139
  declare const pluginZodName = "plugin-zod";
145
140
  declare const pluginZod: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginZod>;
146
141
 
147
- /**
148
- * @deprecated Use `import { pluginZod } from '@kubb/plugin-zod'` instead
149
- */
150
- declare const definePluginDefault: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginZod>;
151
- /**
152
- * @deprecated Use `import { pluginZod } from '@kubb/plugin-zod'` instead
153
- */
154
- declare const definePlugin: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginZod>;
155
-
156
- export { type PluginZod, definePluginDefault as default, definePlugin, pluginZod, pluginZodName };
142
+ export { type PluginZod, pluginZod, pluginZodName };
package/dist/index.js CHANGED
@@ -1,15 +1,12 @@
1
1
  import {
2
+ init_esm_shims,
2
3
  pluginZod,
3
4
  pluginZodName
4
- } from "./chunk-OXCOZC6T.js";
5
+ } from "./chunk-CUPQVLRZ.js";
5
6
 
6
7
  // src/index.ts
7
- var definePluginDefault = pluginZod;
8
- var definePlugin = pluginZod;
9
- var src_default = definePluginDefault;
8
+ init_esm_shims();
10
9
  export {
11
- src_default as default,
12
- definePlugin,
13
10
  pluginZod,
14
11
  pluginZodName
15
12
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { pluginZod } from './plugin.ts'\n\nexport { pluginZod, pluginZodName } from './plugin.ts'\nexport type { PluginZod } from './types.ts'\n\n/**\n * @deprecated Use `import { pluginZod } from '@kubb/plugin-zod'` instead\n */\nconst definePluginDefault = pluginZod\n/**\n * @deprecated Use `import { pluginZod } from '@kubb/plugin-zod'` instead\n */\nexport const definePlugin = pluginZod\n\nexport default definePluginDefault\n"],"mappings":";;;;;;AAQA,IAAM,sBAAsB;AAIrB,IAAM,eAAe;AAE5B,IAAO,cAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { pluginZod, pluginZodName } from './plugin.ts'\nexport type { PluginZod } from './types.ts'\n"],"mappings":";;;;;;;AAAA;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-zod",
3
- "version": "3.0.0-alpha.0",
3
+ "version": "3.0.0-alpha.10",
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.0",
60
- "@kubb/oas": "3.0.0-alpha.0",
61
- "@kubb/fs": "3.0.0-alpha.0",
62
- "@kubb/parser-ts": "3.0.0-alpha.0",
63
- "@kubb/plugin-oas": "3.0.0-alpha.0",
64
- "@kubb/react": "3.0.0-alpha.0",
65
- "@kubb/types": "3.0.0-alpha.0"
59
+ "@kubb/core": "3.0.0-alpha.10",
60
+ "@kubb/fs": "3.0.0-alpha.10",
61
+ "@kubb/oas": "3.0.0-alpha.10",
62
+ "@kubb/parser-ts": "3.0.0-alpha.10",
63
+ "@kubb/plugin-oas": "3.0.0-alpha.10",
64
+ "@kubb/react": "3.0.0-alpha.10",
65
+ "@kubb/types": "3.0.0-alpha.10"
66
66
  },
67
67
  "devDependencies": {
68
- "@types/react": "^18.3.3",
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.0",
73
- "@kubb/config-ts": "3.0.0-alpha.0",
74
- "@kubb/config-tsup": "3.0.0-alpha.0"
72
+ "@kubb/config-biome": "3.0.0-alpha.10",
73
+ "@kubb/config-ts": "3.0.0-alpha.10",
74
+ "@kubb/config-tsup": "3.0.0-alpha.10"
75
75
  },
76
76
  "peerDependencies": {
77
- "@kubb/react": "3.0.0-alpha.0"
77
+ "@kubb/react": "3.0.0-alpha.10"
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
package/src/index.ts CHANGED
@@ -1,15 +1,2 @@
1
- import { pluginZod } from './plugin.ts'
2
-
3
1
  export { pluginZod, pluginZodName } from './plugin.ts'
4
2
  export type { PluginZod } from './types.ts'
5
-
6
- /**
7
- * @deprecated Use `import { pluginZod } from '@kubb/plugin-zod'` instead
8
- */
9
- const definePluginDefault = pluginZod
10
- /**
11
- * @deprecated Use `import { pluginZod } from '@kubb/plugin-zod'` instead
12
- */
13
- export const definePlugin = pluginZod
14
-
15
- export default definePluginDefault
@@ -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
  }