@kubb/plugin-zod 3.0.0-alpha.18 → 3.0.0-alpha.19

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.
@@ -7,8 +7,11 @@ import type { PluginZod } from '../types'
7
7
 
8
8
  export const operationsGenerator = createReactGenerator<PluginZod>({
9
9
  name: 'operations',
10
- Operations({ operations, options }) {
11
- const { pluginManager } = useApp<PluginZod>()
10
+ Operations({ operations }) {
11
+ const {
12
+ pluginManager,
13
+ plugin: { output },
14
+ } = useApp<PluginZod>()
12
15
  const { getFile, groupSchemasByName } = useOperationManager()
13
16
 
14
17
  const name = 'operations'
@@ -25,7 +28,7 @@ export const operationsGenerator = createReactGenerator<PluginZod>({
25
28
  .filter(Boolean)
26
29
 
27
30
  return (
28
- <File baseName={file.baseName} path={file.path} meta={file.meta}>
31
+ <File baseName={file.baseName} path={file.path} meta={file.meta} banner={output?.banner} footer={output?.footer}>
29
32
  {imports}
30
33
  <Operations name={name} operations={transformedOperations} />
31
34
  </File>
@@ -69,7 +69,7 @@ export const zodGenerator = createReactGenerator<PluginZod>({
69
69
  }
70
70
 
71
71
  return (
72
- <File baseName={file.baseName} path={file.path} meta={file.meta}>
72
+ <File baseName={file.baseName} path={file.path} meta={file.meta} banner={plugin.output?.banner} footer={plugin.output?.footer}>
73
73
  <File.Import name={['z']} path={plugin.options.importPath} />
74
74
  {operationSchemas.map(mapOperationSchema)}
75
75
  </File>
@@ -77,7 +77,12 @@ export const zodGenerator = createReactGenerator<PluginZod>({
77
77
  },
78
78
  Schema({ schema, options }) {
79
79
  const { coercion, inferred, typed, mapper, importPath } = options
80
+
80
81
  const { getName, getFile, getImports } = useSchemaManager()
82
+ const {
83
+ plugin: { output },
84
+ } = useApp<PluginZod>()
85
+
81
86
  const imports = getImports(schema.tree)
82
87
 
83
88
  const zod = {
@@ -92,7 +97,7 @@ export const zodGenerator = createReactGenerator<PluginZod>({
92
97
  }
93
98
 
94
99
  return (
95
- <File baseName={zod.file.baseName} path={zod.file.path} meta={zod.file.meta}>
100
+ <File baseName={zod.file.baseName} path={zod.file.path} meta={zod.file.meta} banner={output?.banner} footer={output?.footer}>
96
101
  <File.Import name={['z']} path={importPath} />
97
102
  {typed && <File.Import isTypeOnly root={zod.file.path} path={type.file.path} name={[type.name]} />}
98
103
  {imports.map((imp, index) => (
package/src/types.ts CHANGED
@@ -1,30 +1,12 @@
1
- import type { Plugin, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
- import type * as KubbFile from '@kubb/fs/types'
1
+ import type { Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
3
2
  import type { SchemaObject } from '@kubb/oas'
4
3
  import type { Exclude, Include, Override, ResolvePathOptions, Schema } from '@kubb/plugin-oas'
5
4
 
6
5
  export type Options = {
7
- output?: {
8
- /**
9
- * Relative path to save the Zod schemas.
10
- * When output is a file it will save all models inside that file else it will create a file per schema item.
11
- * @default 'zod'
12
- */
13
- path: string
14
- /**
15
- * Name to be used for the `export * as {{exportAs}} from './'`
16
- */
17
- exportAs?: string
18
- /**
19
- * Add an extension to the generated imports and exports, default it will not use an extension
20
- */
21
- extName?: KubbFile.Extname
22
- /**
23
- * Define what needs to exported, here you can also disable the export of barrel files
24
- * @default `'barrel'`
25
- */
26
- exportType?: 'barrel' | 'barrelNamed' | false
27
- }
6
+ /**
7
+ * @default 'zod'
8
+ */
9
+ output?: Output
28
10
  /**
29
11
  * Group the Zod schemas based on the provided name.
30
12
  */