@kubb/swagger-ts 2.0.0-alpha.8 → 2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/swagger-ts",
3
- "version": "2.0.0-alpha.8",
3
+ "version": "2.0.0-alpha.9",
4
4
  "description": "Generator swagger-ts",
5
5
  "keywords": [
6
6
  "typescript",
@@ -25,11 +25,6 @@
25
25
  "require": "./dist/index.cjs",
26
26
  "default": "./dist/index.cjs"
27
27
  },
28
- "./hooks": {
29
- "import": "./dist/hooks.js",
30
- "require": "./dist/hooks.cjs",
31
- "default": "./dist/hooks.cjs"
32
- },
33
28
  "./package.json": "./package.json",
34
29
  "./*": "./*"
35
30
  },
@@ -45,9 +40,9 @@
45
40
  "dependencies": {
46
41
  "change-case": "^4.1.2",
47
42
  "typescript": "rc",
48
- "@kubb/core": "2.0.0-alpha.8",
49
- "@kubb/swagger": "2.0.0-alpha.8",
50
- "@kubb/parser": "2.0.0-alpha.8"
43
+ "@kubb/core": "2.0.0-alpha.9",
44
+ "@kubb/swagger": "2.0.0-alpha.9",
45
+ "@kubb/parser": "2.0.0-alpha.9"
51
46
  },
52
47
  "devDependencies": {
53
48
  "eslint": "^8.53.0",
package/src/index.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { definePlugin } from './plugin.ts'
2
2
 
3
- export * from './plugin.ts'
4
- export { resolve } from './resolve.ts'
3
+ export { definePlugin, pluginKey, pluginName } from './plugin.ts'
5
4
  export * from './types.ts'
6
5
 
7
6
  export default definePlugin
package/src/plugin.ts CHANGED
@@ -61,10 +61,14 @@ export const definePlugin = createPlugin<PluginOptions>((options) => {
61
61
 
62
62
  return path.resolve(root, output, baseName)
63
63
  },
64
- resolveName(name) {
64
+ resolveName(name, type) {
65
65
  const resolvedName = pascalCase(name, { delimiter: '', stripRegexp: /[^A-Z0-9$]/gi, transform: pascalCaseTransformMerge })
66
66
 
67
- return transformers?.name?.(resolvedName) || resolvedName
67
+ if (type) {
68
+ return transformers?.name?.(resolvedName, type) || resolvedName
69
+ }
70
+
71
+ return resolvedName
68
72
  },
69
73
  async writeFile(source, writePath) {
70
74
  if (!writePath.endsWith('.ts') || !source) {
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { KubbPlugin, PluginFactoryOptions } from '@kubb/core'
1
+ import type { KubbPlugin, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
2
  import type { Exclude, Include, Override, ResolvePathOptions } from '@kubb/swagger'
3
3
 
4
4
  export type Options = {
@@ -61,14 +61,15 @@ export type Options = {
61
61
  optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined'
62
62
  transformers?: {
63
63
  /**
64
- * Override the name of the TypeScript type that is getting generated, this will also override the name of the file.
64
+ * Customize the names based on the type that is provided by the plugin.
65
65
  */
66
- name?: (name: string) => string
66
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string
67
67
  }
68
68
  }
69
69
 
70
70
  export type FileMeta = {
71
71
  pluginKey?: KubbPlugin['key']
72
+ name?: string
72
73
  tag?: string
73
74
  }
74
75