@kubb/plugin-oas 4.20.3 → 4.21.0

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,9 +1,21 @@
1
1
  import { t as __name } from "./chunk-iVr_oF3V.js";
2
- import { C as Plugin, D as AsyncEventEmitter, O as KubbEvents, S as Output, T as ResolveNameParams, _ as contentType, b as Config, d as HttpMethod, g as SchemaObject, h as Operation, i as SchemaKeywordMapper, k as BaseGenerator, t as Schema, u as Oas, v as FileMetaBase, w as PluginFactoryOptions, x as Group, y as PluginManager } from "./SchemaMapper-DnWpiVfW.js";
2
+ import { _ as contentType, d as HttpMethod, g as SchemaObject, h as Operation, i as SchemaKeywordMapper, t as Schema, u as Oas } from "./SchemaMapper-CmwW1HVs.js";
3
+ import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
3
4
  import { Fabric } from "@kubb/react-fabric";
4
5
  import { KubbFile } from "@kubb/fabric-core/types";
5
6
  import { FabricReactNode } from "@kubb/react-fabric/types";
6
7
 
8
+ //#region ../core/src/utils/AsyncEventEmitter.d.ts
9
+ declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
10
+ #private;
11
+ constructor(maxListener?: number);
12
+ emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
13
+ on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
14
+ onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
15
+ off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
16
+ removeAll(): void;
17
+ }
18
+ //#endregion
7
19
  //#region ../core/src/utils/FunctionParams.d.ts
8
20
  type FunctionParamsASTWithoutType = {
9
21
  name?: string;
@@ -36,6 +48,22 @@ type FunctionParamsASTWithType = {
36
48
  */
37
49
  type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
38
50
  //#endregion
51
+ //#region ../core/src/types.d.ts
52
+ declare global {
53
+ namespace Kubb {
54
+ interface PluginContext {}
55
+ }
56
+ }
57
+ /**
58
+ * Config used in `kubb.config.ts`
59
+ *
60
+ * @example
61
+ * import { defineConfig } from '@kubb/core'
62
+ * export default defineConfig({
63
+ * ...
64
+ * })
65
+ */
66
+ //#endregion
39
67
  //#region src/types.d.ts
40
68
  type GetOasOptions = {
41
69
  validate?: boolean;
@@ -212,7 +240,7 @@ type ByContentType = {
212
240
  type: 'contentType';
213
241
  pattern: string | RegExp;
214
242
  };
215
- type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
243
+ type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
216
244
  type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
217
245
  type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
218
246
  options: Partial<TOptions>;
@@ -227,7 +255,7 @@ type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.Fi
227
255
  type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
228
256
  fabric: Fabric;
229
257
  oas: Oas;
230
- exclude: Array<Exclude> | undefined;
258
+ exclude: Array<Exclude$1> | undefined;
231
259
  include: Array<Include> | undefined;
232
260
  override: Array<Override<TOptions>> | undefined;
233
261
  contentType: contentType | undefined;
@@ -387,5 +415,5 @@ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
387
415
  };
388
416
  declare function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions>;
389
417
  //#endregion
390
- export { Resolver as C, ResolvePathOptions as S, Options as _, createReactGenerator as a, Ref as b, SchemaGeneratorBuildOptions as c, OperationGenerator as d, OperationMethodResult as f, OperationSchemas as g, OperationSchema as h, ReactGenerator as i, SchemaGeneratorOptions as l, Include as m, createGenerator as n, GetSchemaGeneratorOptions as o, Exclude as p, Generator as r, SchemaGenerator as s, CoreGenerator as t, SchemaMethodResult as u, Override as v, FunctionParamsAST as w, Refs as x, PluginOas as y };
391
- //# sourceMappingURL=createGenerator-D30QUDWi.d.ts.map
418
+ export { Resolver as C, ResolvePathOptions as S, Options as _, createReactGenerator as a, Ref as b, SchemaGeneratorBuildOptions as c, OperationGenerator as d, OperationMethodResult as f, OperationSchemas as g, OperationSchema as h, ReactGenerator as i, SchemaGeneratorOptions as l, Include as m, createGenerator as n, GetSchemaGeneratorOptions as o, Exclude$1 as p, Generator as r, SchemaGenerator as s, CoreGenerator as t, SchemaMethodResult as u, Override as v, FunctionParamsAST as w, Refs as x, PluginOas as y };
419
+ //# sourceMappingURL=createGenerator-Cd10rV1T.d.ts.map
@@ -1,8 +1,20 @@
1
- import { A as __name, C as Plugin, D as AsyncEventEmitter, O as KubbEvents, S as Output, T as ResolveNameParams, _ as contentType, b as Config, d as HttpMethod, g as SchemaObject, h as Operation, i as SchemaKeywordMapper, k as BaseGenerator, t as Schema, u as Oas, v as FileMetaBase, w as PluginFactoryOptions, x as Group, y as PluginManager } from "./SchemaMapper-DmB5NyNo.cjs";
1
+ import { _ as contentType, d as HttpMethod, g as SchemaObject, h as Operation, i as SchemaKeywordMapper, t as Schema, u as Oas, v as __name } from "./SchemaMapper-CE2wt2cR.cjs";
2
+ import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
2
3
  import { KubbFile } from "@kubb/fabric-core/types";
3
4
  import { Fabric } from "@kubb/react-fabric";
4
5
  import { FabricReactNode } from "@kubb/react-fabric/types";
5
6
 
7
+ //#region ../core/src/utils/AsyncEventEmitter.d.ts
8
+ declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
9
+ #private;
10
+ constructor(maxListener?: number);
11
+ emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
12
+ on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
13
+ onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
14
+ off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
15
+ removeAll(): void;
16
+ }
17
+ //#endregion
6
18
  //#region ../core/src/utils/FunctionParams.d.ts
7
19
  type FunctionParamsASTWithoutType = {
8
20
  name?: string;
@@ -35,6 +47,22 @@ type FunctionParamsASTWithType = {
35
47
  */
36
48
  type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
37
49
  //#endregion
50
+ //#region ../core/src/types.d.ts
51
+ declare global {
52
+ namespace Kubb {
53
+ interface PluginContext {}
54
+ }
55
+ }
56
+ /**
57
+ * Config used in `kubb.config.ts`
58
+ *
59
+ * @example
60
+ * import { defineConfig } from '@kubb/core'
61
+ * export default defineConfig({
62
+ * ...
63
+ * })
64
+ */
65
+ //#endregion
38
66
  //#region src/types.d.ts
39
67
  type GetOasOptions = {
40
68
  validate?: boolean;
@@ -211,7 +239,7 @@ type ByContentType = {
211
239
  type: 'contentType';
212
240
  pattern: string | RegExp;
213
241
  };
214
- type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
242
+ type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
215
243
  type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
216
244
  type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
217
245
  options: Partial<TOptions>;
@@ -226,7 +254,7 @@ type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.Fi
226
254
  type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
227
255
  fabric: Fabric;
228
256
  oas: Oas;
229
- exclude: Array<Exclude> | undefined;
257
+ exclude: Array<Exclude$1> | undefined;
230
258
  include: Array<Include> | undefined;
231
259
  override: Array<Override<TOptions>> | undefined;
232
260
  contentType: contentType | undefined;
@@ -386,5 +414,5 @@ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
386
414
  };
387
415
  declare function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions>;
388
416
  //#endregion
389
- export { Resolver as C, ResolvePathOptions as S, Options as _, createReactGenerator as a, Ref as b, SchemaGeneratorBuildOptions as c, OperationGenerator as d, OperationMethodResult as f, OperationSchemas as g, OperationSchema as h, ReactGenerator as i, SchemaGeneratorOptions as l, Include as m, createGenerator as n, GetSchemaGeneratorOptions as o, Exclude as p, Generator as r, SchemaGenerator as s, CoreGenerator as t, SchemaMethodResult as u, Override as v, FunctionParamsAST as w, Refs as x, PluginOas as y };
390
- //# sourceMappingURL=createGenerator-1nstUihJ.d.cts.map
417
+ export { Resolver as C, ResolvePathOptions as S, Options as _, createReactGenerator as a, Ref as b, SchemaGeneratorBuildOptions as c, OperationGenerator as d, OperationMethodResult as f, OperationSchemas as g, OperationSchema as h, ReactGenerator as i, SchemaGeneratorOptions as l, Include as m, createGenerator as n, GetSchemaGeneratorOptions as o, Exclude$1 as p, Generator as r, SchemaGenerator as s, CoreGenerator as t, SchemaMethodResult as u, Override as v, FunctionParamsAST as w, Refs as x, PluginOas as y };
418
+ //# sourceMappingURL=createGenerator-DfYQQtRa.d.cts.map
@@ -1,5 +1,5 @@
1
- import { A as __name } from "./SchemaMapper-DmB5NyNo.cjs";
2
- import { a as createReactGenerator, n as createGenerator, r as Generator, t as CoreGenerator, y as PluginOas } from "./createGenerator-1nstUihJ.cjs";
1
+ import { v as __name } from "./SchemaMapper-CE2wt2cR.cjs";
2
+ import { a as createReactGenerator, n as createGenerator, r as Generator, t as CoreGenerator, y as PluginOas } from "./createGenerator-DfYQQtRa.cjs";
3
3
 
4
4
  //#region src/generators/jsonGenerator.d.ts
5
5
  declare const jsonGenerator: CoreGenerator<PluginOas>;
@@ -1,6 +1,6 @@
1
1
  import { t as __name } from "./chunk-iVr_oF3V.js";
2
- import "./SchemaMapper-DnWpiVfW.js";
3
- import { a as createReactGenerator, n as createGenerator, r as Generator, t as CoreGenerator, y as PluginOas } from "./createGenerator-D30QUDWi.js";
2
+ import "./SchemaMapper-CmwW1HVs.js";
3
+ import { a as createReactGenerator, n as createGenerator, r as Generator, t as CoreGenerator, y as PluginOas } from "./createGenerator-Cd10rV1T.js";
4
4
 
5
5
  //#region src/generators/jsonGenerator.d.ts
6
6
  declare const jsonGenerator: CoreGenerator<PluginOas>;
package/dist/hooks.d.cts CHANGED
@@ -1,5 +1,6 @@
1
- import { A as __name, C as Plugin, T as ResolveNameParams, h as Operation, u as Oas, v as FileMetaBase, w as PluginFactoryOptions } from "./SchemaMapper-DmB5NyNo.cjs";
2
- import { d as OperationGenerator, g as OperationSchemas } from "./createGenerator-1nstUihJ.cjs";
1
+ import { h as Operation, u as Oas, v as __name } from "./SchemaMapper-CE2wt2cR.cjs";
2
+ import { d as OperationGenerator, g as OperationSchemas } from "./createGenerator-DfYQQtRa.cjs";
3
+ import { FileMetaBase, Plugin, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
3
4
  import { KubbFile } from "@kubb/fabric-core/types";
4
5
 
5
6
  //#region src/hooks/useOas.d.ts
package/dist/hooks.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { t as __name } from "./chunk-iVr_oF3V.js";
2
- import { C as Plugin, T as ResolveNameParams, h as Operation, u as Oas, v as FileMetaBase, w as PluginFactoryOptions } from "./SchemaMapper-DnWpiVfW.js";
3
- import { d as OperationGenerator, g as OperationSchemas } from "./createGenerator-D30QUDWi.js";
2
+ import { h as Operation, u as Oas } from "./SchemaMapper-CmwW1HVs.js";
3
+ import { d as OperationGenerator, g as OperationSchemas } from "./createGenerator-Cd10rV1T.js";
4
+ import { FileMetaBase, Plugin, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
4
5
  import { KubbFile } from "@kubb/fabric-core/types";
5
6
 
6
7
  //#region src/hooks/useOas.d.ts
package/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
- import { A as __name, C as Plugin, E as UserPluginWithLifeCycle, a as SchemaMapper, b as Config, c as schemaKeywords, g as SchemaObject, h as Operation, i as SchemaKeywordMapper, n as SchemaKeyword, o as SchemaTree, r as SchemaKeywordBase, s as isKeyword, t as Schema, w as PluginFactoryOptions } from "./SchemaMapper-DmB5NyNo.cjs";
2
- import { C as Resolver, S as ResolvePathOptions, _ as Options, a as createReactGenerator$1, b as Ref, c as SchemaGeneratorBuildOptions, d as OperationGenerator, f as OperationMethodResult, g as OperationSchemas, h as OperationSchema, i as ReactGenerator, l as SchemaGeneratorOptions, m as Include, n as createGenerator$1, o as GetSchemaGeneratorOptions, p as Exclude, r as Generator$1, s as SchemaGenerator, u as SchemaMethodResult, v as Override, x as Refs, y as PluginOas } from "./createGenerator-1nstUihJ.cjs";
1
+ import { a as SchemaMapper, c as schemaKeywords, g as SchemaObject, h as Operation, i as SchemaKeywordMapper, n as SchemaKeyword, o as SchemaTree, r as SchemaKeywordBase, s as isKeyword, t as Schema, v as __name } from "./SchemaMapper-CE2wt2cR.cjs";
2
+ import { C as Resolver, S as ResolvePathOptions, _ as Options, a as createReactGenerator$1, b as Ref, c as SchemaGeneratorBuildOptions, d as OperationGenerator, f as OperationMethodResult, g as OperationSchemas, h as OperationSchema, i as ReactGenerator, l as SchemaGeneratorOptions, m as Include, n as createGenerator$1, o as GetSchemaGeneratorOptions, p as Exclude, r as Generator$1, s as SchemaGenerator, u as SchemaMethodResult, v as Override, x as Refs, y as PluginOas } from "./createGenerator-DfYQQtRa.cjs";
3
+ import * as _kubb_core0 from "@kubb/core";
4
+ import { Config, Plugin, PluginFactoryOptions } from "@kubb/core";
3
5
  import { Fabric } from "@kubb/react-fabric";
4
6
 
5
7
  //#region src/createParser.d.ts
@@ -121,7 +123,7 @@ declare function findSchemaKeyword<K$1 extends keyof SchemaKeywordMapper>(siblin
121
123
  //#endregion
122
124
  //#region src/plugin.d.ts
123
125
  declare const pluginOasName = "plugin-oas";
124
- declare const pluginOas: (options?: Options | undefined) => UserPluginWithLifeCycle<PluginOas>;
126
+ declare const pluginOas: (options?: Options | undefined) => _kubb_core0.UserPluginWithLifeCycle<PluginOas>;
125
127
  //#endregion
126
128
  //#region src/utils.d.ts
127
129
  type BuildOperationsOptions<TOptions extends PluginFactoryOptions> = {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { t as __name } from "./chunk-iVr_oF3V.js";
2
- import { C as Plugin, E as UserPluginWithLifeCycle, a as SchemaMapper, b as Config, c as schemaKeywords, g as SchemaObject, h as Operation, i as SchemaKeywordMapper, n as SchemaKeyword, o as SchemaTree, r as SchemaKeywordBase, s as isKeyword, t as Schema, w as PluginFactoryOptions } from "./SchemaMapper-DnWpiVfW.js";
3
- import { C as Resolver, S as ResolvePathOptions, _ as Options, a as createReactGenerator$1, b as Ref, c as SchemaGeneratorBuildOptions, d as OperationGenerator, f as OperationMethodResult, g as OperationSchemas, h as OperationSchema, i as ReactGenerator, l as SchemaGeneratorOptions, m as Include, n as createGenerator$1, o as GetSchemaGeneratorOptions, p as Exclude, r as Generator$1, s as SchemaGenerator, u as SchemaMethodResult, v as Override, x as Refs, y as PluginOas } from "./createGenerator-D30QUDWi.js";
2
+ import { a as SchemaMapper, c as schemaKeywords, g as SchemaObject, h as Operation, i as SchemaKeywordMapper, n as SchemaKeyword, o as SchemaTree, r as SchemaKeywordBase, s as isKeyword, t as Schema } from "./SchemaMapper-CmwW1HVs.js";
3
+ import { C as Resolver, S as ResolvePathOptions, _ as Options, a as createReactGenerator$1, b as Ref, c as SchemaGeneratorBuildOptions, d as OperationGenerator, f as OperationMethodResult, g as OperationSchemas, h as OperationSchema, i as ReactGenerator, l as SchemaGeneratorOptions, m as Include, n as createGenerator$1, o as GetSchemaGeneratorOptions, p as Exclude, r as Generator$1, s as SchemaGenerator, u as SchemaMethodResult, v as Override, x as Refs, y as PluginOas } from "./createGenerator-Cd10rV1T.js";
4
+ import * as _kubb_core0 from "@kubb/core";
5
+ import { Config, Plugin, PluginFactoryOptions } from "@kubb/core";
4
6
  import { Fabric } from "@kubb/react-fabric";
5
7
 
6
8
  //#region src/createParser.d.ts
@@ -122,7 +124,7 @@ declare function findSchemaKeyword<K$1 extends keyof SchemaKeywordMapper>(siblin
122
124
  //#endregion
123
125
  //#region src/plugin.d.ts
124
126
  declare const pluginOasName = "plugin-oas";
125
- declare const pluginOas: (options?: Options | undefined) => UserPluginWithLifeCycle<PluginOas>;
127
+ declare const pluginOas: (options?: Options | undefined) => _kubb_core0.UserPluginWithLifeCycle<PluginOas>;
126
128
  //#endregion
127
129
  //#region src/utils.d.ts
128
130
  type BuildOperationsOptions<TOptions extends PluginFactoryOptions> = {
package/dist/mocks.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as __name, t as Schema } from "./SchemaMapper-DmB5NyNo.cjs";
1
+ import { t as Schema, v as __name } from "./SchemaMapper-CE2wt2cR.cjs";
2
2
 
3
3
  //#region src/mocks/schemas.d.ts
4
4
  declare const schemas: {
package/dist/mocks.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./chunk-iVr_oF3V.js";
2
- import { t as Schema } from "./SchemaMapper-DnWpiVfW.js";
2
+ import { t as Schema } from "./SchemaMapper-CmwW1HVs.js";
3
3
 
4
4
  //#region src/mocks/schemas.d.ts
5
5
  declare const schemas: {
package/dist/utils.cjs CHANGED
@@ -3,6 +3,7 @@ const require_SchemaGenerator = require('./SchemaGenerator-m8ILeAM0.cjs');
3
3
  const require_SchemaMapper = require('./SchemaMapper-CzH82C7C.cjs');
4
4
  const require_getFooter = require('./getFooter-C_dFbEs9.cjs');
5
5
  let _kubb_core_transformers = require("@kubb/core/transformers");
6
+ _kubb_core_transformers = require_chunk.__toESM(_kubb_core_transformers);
6
7
  let _kubb_core_utils = require("@kubb/core/utils");
7
8
  let _kubb_oas = require("@kubb/oas");
8
9
 
@@ -40,15 +41,16 @@ function getImports(tree) {
40
41
  * @deprecated
41
42
  * TODO move to operationManager hook
42
43
  */
43
- function getASTParams(operationSchema, { typed = false, override } = {}) {
44
+ function getASTParams(operationSchema, { typed = false, casing, override } = {}) {
44
45
  if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) return [];
45
46
  const requiredFields = Array.isArray(operationSchema.schema.required) ? operationSchema.schema.required : [];
46
47
  return Object.entries(operationSchema.schema.properties).map(([name]) => {
48
+ const accessName = casing === "camelcase" ? (0, _kubb_core_transformers.camelCase)(name) : name;
47
49
  const data = {
48
50
  name,
49
51
  enabled: !!name,
50
52
  required: requiredFields.includes(name),
51
- type: typed ? `${operationSchema.name}["${name}"]` : void 0
53
+ type: typed ? `${operationSchema.name}["${accessName}"]` : void 0
52
54
  };
53
55
  return override ? override(data) : data;
54
56
  });
@@ -56,8 +58,9 @@ function getASTParams(operationSchema, { typed = false, override } = {}) {
56
58
  function getPathParams(operationSchema, options = {}) {
57
59
  return getASTParams(operationSchema, options).reduce((acc, curr) => {
58
60
  if (curr.name && curr.enabled) {
59
- let name = (0, _kubb_core_transformers.isValidVarName)(curr.name) ? curr.name : (0, _kubb_core_transformers.camelCase)(curr.name);
61
+ let name = curr.name;
60
62
  if (options.casing === "camelcase") name = (0, _kubb_core_transformers.camelCase)(name);
63
+ else if (!(0, _kubb_core_transformers.isValidVarName)(name)) name = (0, _kubb_core_transformers.camelCase)(name);
61
64
  acc[name] = {
62
65
  default: curr.default,
63
66
  type: curr.type,
@@ -67,6 +70,21 @@ function getPathParams(operationSchema, options = {}) {
67
70
  return acc;
68
71
  }, {});
69
72
  }
73
+ /**
74
+ * Get a mapping of camelCase parameter names to their original names
75
+ * Used for mapping function parameters to backend parameter names
76
+ */
77
+ function getParamsMapping(operationSchema, options = {}) {
78
+ if (!operationSchema || !operationSchema.schema.properties) return;
79
+ const mapping = {};
80
+ Object.entries(operationSchema.schema.properties).forEach(([originalName]) => {
81
+ let transformedName = originalName;
82
+ if (options.casing === "camelcase") transformedName = (0, _kubb_core_transformers.camelCase)(originalName);
83
+ else if (!(0, _kubb_core_transformers.isValidVarName)(originalName)) transformedName = (0, _kubb_core_transformers.camelCase)(originalName);
84
+ if (transformedName !== originalName) mapping[originalName] = transformedName;
85
+ });
86
+ return Object.keys(mapping).length > 0 ? mapping : void 0;
87
+ }
70
88
 
71
89
  //#endregion
72
90
  //#region src/utils/getSchemas.ts
@@ -92,10 +110,49 @@ function getSchemas({ oas, contentType, includes = [
92
110
  }
93
111
 
94
112
  //#endregion
113
+ //#region src/utils/paramsCasing.ts
114
+ /**
115
+ * Apply casing transformation to schema properties
116
+ * Only transforms property names, not nested schemas
117
+ */
118
+ function applyParamsCasing(schema, casing) {
119
+ if (!casing || !schema.properties) return schema;
120
+ const transformedProperties = {};
121
+ const transformedRequired = [];
122
+ Object.entries(schema.properties).forEach(([originalName, propertySchema]) => {
123
+ let transformedName = originalName;
124
+ if (casing === "camelcase") transformedName = _kubb_core_transformers.default.camelCase(originalName);
125
+ else if (!(0, _kubb_core_transformers.isValidVarName)(originalName)) transformedName = _kubb_core_transformers.default.camelCase(originalName);
126
+ transformedProperties[transformedName] = propertySchema;
127
+ });
128
+ if (Array.isArray(schema.required)) schema.required.forEach((originalName) => {
129
+ let transformedName = originalName;
130
+ if (casing === "camelcase") transformedName = _kubb_core_transformers.default.camelCase(originalName);
131
+ else if (!(0, _kubb_core_transformers.isValidVarName)(originalName)) transformedName = _kubb_core_transformers.default.camelCase(originalName);
132
+ transformedRequired.push(transformedName);
133
+ });
134
+ return {
135
+ ...schema,
136
+ properties: transformedProperties,
137
+ ...transformedRequired.length > 0 && { required: transformedRequired }
138
+ };
139
+ }
140
+ /**
141
+ * Check if this schema is a parameter schema (pathParams, queryParams, or headerParams)
142
+ * Only these should be transformed, not response/data/body
143
+ */
144
+ function isParameterSchema(schemaName) {
145
+ const lowerName = schemaName.toLowerCase();
146
+ return lowerName.includes("pathparams") || lowerName.includes("queryparams") || lowerName.includes("headerparams");
147
+ }
148
+
149
+ //#endregion
150
+ exports.applyParamsCasing = applyParamsCasing;
95
151
  exports.getBanner = require_getFooter.getBanner;
96
152
  exports.getComments = getComments;
97
153
  exports.getFooter = require_getFooter.getFooter;
98
154
  exports.getImports = getImports;
155
+ exports.getParamsMapping = getParamsMapping;
99
156
  exports.getPathParams = getPathParams;
100
157
  exports.getSchemaFactory = require_SchemaGenerator.getSchemaFactory;
101
158
  exports.getSchemas = getSchemas;
@@ -105,4 +162,5 @@ Object.defineProperty(exports, 'isOptional', {
105
162
  return _kubb_oas.isOptional;
106
163
  }
107
164
  });
165
+ exports.isParameterSchema = isParameterSchema;
108
166
  //# sourceMappingURL=utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":["URLPath","SchemaGenerator","schemaKeywords"],"sources":["../src/utils/getComments.ts","../src/utils/getImports.ts","../src/utils/getParams.ts","../src/utils/getSchemas.ts"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .flatMap((text) => {\n // Split by newlines to preserve line breaks in JSDoc\n // Trim each line individually to remove leading/trailing whitespace\n return text.split(/\\r?\\n/).map((line) => line.trim())\n })\n .filter(Boolean)\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport type { Schema } from '../SchemaMapper'\nimport { schemaKeywords } from '../SchemaMapper'\n\n/**\n * Get imports from a schema tree by extracting all ref schemas that are importable\n */\nexport function getImports(tree: Array<Schema>): Array<KubbFile.Import> {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n return refs\n ?.map((item) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n }\n })\n .filter(Boolean)\n}\n","import { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react-fabric/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n const requiredFields = Array.isArray(operationSchema.schema.required) ? operationSchema.schema.required : []\n\n return Object.entries(operationSchema.schema.properties).map(([name]: [string, OasTypes.SchemaObject]) => {\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: requiredFields.includes(name),\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name)\n\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n","import type { contentType, Oas, OasTypes } from '@kubb/oas'\n\nexport type GetSchemasResult = {\n schemas: Record<string, OasTypes.SchemaObject>\n /**\n * Mapping from original component name to resolved name after collision handling\n * e.g., { 'Order': 'OrderSchema', 'variant': 'variant2' }\n */\n nameMapping: Map<string, string>\n}\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n /**\n * Whether to resolve name collisions with suffixes.\n * If not provided, uses oas.options.collisionDetection\n * @default false (from oas.options or fallback)\n */\n collisionDetection?: boolean\n}\n\n/**\n * Collect schemas from OpenAPI components (schemas, responses, requestBodies)\n * and return them in dependency order along with name mapping for collision resolution.\n *\n * This function is a wrapper around the oas.getSchemas() method for backward compatibility.\n * New code should use oas.getSchemas() directly.\n *\n * @deprecated Use oas.getSchemas() instead\n */\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'], collisionDetection }: GetSchemasProps): GetSchemasResult {\n return oas.getSchemas({\n contentType,\n includes,\n collisionDetection,\n })\n}\n"],"mappings":";;;;;;;;;AAIA,SAAgB,YAAY,WAAgC;AAC1D,QAAO;EACL,UAAU,gBAAgB,IAAI,gBAAgB,UAAU,gBAAgB;EACxE,UAAU,YAAY,IAAI,YAAY,UAAU,YAAY;EAC5D,UAAU,QAAQ,UAAU,IAAIA,yBAAQ,UAAU,KAAK,CAAC,IAAI;EAC5D,UAAU,cAAc,IAAI;EAC7B,CACE,OAAO,QAAQ,CACf,SAAS,SAAS;AAGjB,SAAO,KAAK,MAAM,QAAQ,CAAC,KAAK,SAAS,KAAK,MAAM,CAAC;GACrD,CACD,OAAO,QAAQ;;;;;;;;ACTpB,SAAgB,WAAW,MAA6C;AAGtE,QAFaC,wCAAgB,WAAW,MAAMC,oCAAe,IAAI,EAG7D,KAAK,SAAS;AACd,MAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAChC;AAGF,SAAO;GACL,MAAM,CAAC,KAAK,KAAK,KAAK;GACtB,MAAM,KAAK,KAAK;GACjB;GACD,CACD,OAAO,QAAQ;;;;;;;;;;ACZpB,SAAgB,aACd,iBACA,EACE,QAAQ,OACR,aAIE,EAAE,EACe;AACrB,KAAI,CAAC,mBAAmB,CAAC,gBAAgB,OAAO,cAAc,CAAC,gBAAgB,KAC7E,QAAO,EAAE;CAGX,MAAM,iBAAiB,MAAM,QAAQ,gBAAgB,OAAO,SAAS,GAAG,gBAAgB,OAAO,WAAW,EAAE;AAE5G,QAAO,OAAO,QAAQ,gBAAgB,OAAO,WAAW,CAAC,KAAK,CAAC,UAA2C;EACxG,MAAM,OAA0B;GAC9B;GACA,SAAS,CAAC,CAAC;GACX,UAAU,eAAe,SAAS,KAAK;GACvC,MAAM,QAAQ,GAAG,gBAAgB,KAAK,IAAI,KAAK,MAAM;GACtD;AAED,SAAO,WAAW,SAAS,KAAK,GAAG;GACnC;;AAGJ,SAAgB,cACd,iBACA,UAII,EAAE,EACN;AACA,QAAO,aAAa,iBAAiB,QAAQ,CAAC,QAAQ,KAAK,SAAS;AAClE,MAAI,KAAK,QAAQ,KAAK,SAAS;GAC7B,IAAI,mDAAsB,KAAK,KAAK,GAAG,KAAK,8CAAiB,KAAK,KAAK;AAEvE,OAAI,QAAQ,WAAW,YACrB,+CAAiB,KAAK;AAGxB,OAAI,QAAQ;IACV,SAAS,KAAK;IACd,MAAM,KAAK;IACX,UAAU,CAAC,KAAK;IACjB;;AAGH,SAAO;IACN,EAAE,CAAW;;;;;;;;;;;;;;AC5BlB,SAAgB,WAAW,EAAE,KAAK,aAAa,WAAW;CAAC;CAAW;CAAiB;CAAY,EAAE,sBAAyD;AAC5J,QAAO,IAAI,WAAW;EACpB;EACA;EACA;EACD,CAAC"}
1
+ {"version":3,"file":"utils.cjs","names":["URLPath","SchemaGenerator","schemaKeywords","transformers"],"sources":["../src/utils/getComments.ts","../src/utils/getImports.ts","../src/utils/getParams.ts","../src/utils/getSchemas.ts","../src/utils/paramsCasing.ts"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .flatMap((text) => {\n // Split by newlines to preserve line breaks in JSDoc\n // Trim each line individually to remove leading/trailing whitespace\n return text.split(/\\r?\\n/).map((line) => line.trim())\n })\n .filter(Boolean)\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport type { Schema } from '../SchemaMapper'\nimport { schemaKeywords } from '../SchemaMapper'\n\n/**\n * Get imports from a schema tree by extracting all ref schemas that are importable\n */\nexport function getImports(tree: Array<Schema>): Array<KubbFile.Import> {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n return refs\n ?.map((item) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n }\n })\n .filter(Boolean)\n}\n","import { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react-fabric/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n casing,\n override,\n }: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n const requiredFields = Array.isArray(operationSchema.schema.required) ? operationSchema.schema.required : []\n\n return Object.entries(operationSchema.schema.properties).map(([name]: [string, OasTypes.SchemaObject]) => {\n // Use camelCase name for indexed access if casing is enabled\n const accessName = casing === 'camelcase' ? camelCase(name) : name\n\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: requiredFields.includes(name),\n type: typed ? `${operationSchema.name}[\"${accessName}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = curr.name\n\n // Only transform to camelCase if explicitly requested\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n } else if (!isValidVarName(name)) {\n // If not valid variable name and casing not set, still need to make it valid\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n\n/**\n * Get a mapping of camelCase parameter names to their original names\n * Used for mapping function parameters to backend parameter names\n */\nexport function getParamsMapping(\n operationSchema: OperationSchema | undefined,\n options: {\n casing?: 'camelcase'\n } = {},\n): Record<string, string> | undefined {\n if (!operationSchema || !operationSchema.schema.properties) {\n return undefined\n }\n\n const mapping: Record<string, string> = {}\n\n Object.entries(operationSchema.schema.properties).forEach(([originalName]) => {\n let transformedName = originalName\n\n // Only transform to camelCase if explicitly requested\n if (options.casing === 'camelcase') {\n transformedName = camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n // If not valid variable name and casing not set, still need to make it valid\n transformedName = camelCase(originalName)\n }\n\n // Only add mapping if the names differ\n if (transformedName !== originalName) {\n mapping[originalName] = transformedName\n }\n })\n\n return Object.keys(mapping).length > 0 ? mapping : undefined\n}\n","import type { contentType, Oas, OasTypes } from '@kubb/oas'\n\nexport type GetSchemasResult = {\n schemas: Record<string, OasTypes.SchemaObject>\n /**\n * Mapping from original component name to resolved name after collision handling\n * e.g., { 'Order': 'OrderSchema', 'variant': 'variant2' }\n */\n nameMapping: Map<string, string>\n}\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n /**\n * Whether to resolve name collisions with suffixes.\n * If not provided, uses oas.options.collisionDetection\n * @default false (from oas.options or fallback)\n */\n collisionDetection?: boolean\n}\n\n/**\n * Collect schemas from OpenAPI components (schemas, responses, requestBodies)\n * and return them in dependency order along with name mapping for collision resolution.\n *\n * This function is a wrapper around the oas.getSchemas() method for backward compatibility.\n * New code should use oas.getSchemas() directly.\n *\n * @deprecated Use oas.getSchemas() instead\n */\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'], collisionDetection }: GetSchemasProps): GetSchemasResult {\n return oas.getSchemas({\n contentType,\n includes,\n collisionDetection,\n })\n}\n","import transformers, { isValidVarName } from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\n\n/**\n * Apply casing transformation to schema properties\n * Only transforms property names, not nested schemas\n */\nexport function applyParamsCasing(schema: SchemaObject, casing: 'camelcase' | undefined): SchemaObject {\n if (!casing || !schema.properties) {\n return schema\n }\n\n const transformedProperties: Record<string, any> = {}\n const transformedRequired: string[] = []\n\n // Transform property names\n Object.entries(schema.properties).forEach(([originalName, propertySchema]) => {\n let transformedName = originalName\n\n if (casing === 'camelcase') {\n transformedName = transformers.camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n // If not valid variable name, make it valid\n transformedName = transformers.camelCase(originalName)\n }\n\n transformedProperties[transformedName] = propertySchema\n })\n\n // Transform required field names\n if (Array.isArray(schema.required)) {\n schema.required.forEach((originalName) => {\n let transformedName = originalName\n\n if (casing === 'camelcase') {\n transformedName = transformers.camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n transformedName = transformers.camelCase(originalName)\n }\n\n transformedRequired.push(transformedName)\n })\n }\n\n // Return a new schema with transformed properties and required fields\n return {\n ...schema,\n properties: transformedProperties,\n ...(transformedRequired.length > 0 && { required: transformedRequired }),\n } as SchemaObject\n}\n\n/**\n * Check if this schema is a parameter schema (pathParams, queryParams, or headerParams)\n * Only these should be transformed, not response/data/body\n */\nexport function isParameterSchema(schemaName: string): boolean {\n const lowerName = schemaName.toLowerCase()\n return lowerName.includes('pathparams') || lowerName.includes('queryparams') || lowerName.includes('headerparams')\n}\n"],"mappings":"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"}
package/dist/utils.d.cts CHANGED
@@ -1,5 +1,6 @@
1
- import { A as __name, S as Output, _ as contentType, b as Config, f as OasTypes, g as SchemaObject, h as Operation, l as isOptional, m as OpenAPIV3_1, p as OpenAPIV3, t as Schema, u as Oas } from "./SchemaMapper-DmB5NyNo.cjs";
2
- import { h as OperationSchema, w as FunctionParamsAST } from "./createGenerator-1nstUihJ.cjs";
1
+ import { _ as contentType, f as OasTypes, g as SchemaObject, h as Operation, l as isOptional, m as OpenAPIV3_1, p as OpenAPIV3, t as Schema, u as Oas, v as __name } from "./SchemaMapper-CE2wt2cR.cjs";
2
+ import { h as OperationSchema, w as FunctionParamsAST } from "./createGenerator-DfYQQtRa.cjs";
3
+ import { Config, Output } from "@kubb/core";
3
4
  import { KubbFile } from "@kubb/fabric-core/types";
4
5
  import { Params } from "@kubb/react-fabric/types";
5
6
 
@@ -40,6 +41,13 @@ declare function getPathParams(operationSchema: OperationSchema | undefined, opt
40
41
  casing?: 'camelcase';
41
42
  override?: (data: FunctionParamsAST) => FunctionParamsAST;
42
43
  }): Params;
44
+ /**
45
+ * Get a mapping of camelCase parameter names to their original names
46
+ * Used for mapping function parameters to backend parameter names
47
+ */
48
+ declare function getParamsMapping(operationSchema: OperationSchema | undefined, options?: {
49
+ casing?: 'camelcase';
50
+ }): Record<string, string> | undefined;
43
51
  //#endregion
44
52
  //#region src/utils/getSchemaFactory.d.ts
45
53
  /**
@@ -104,5 +112,17 @@ declare function getSchemas({
104
112
  collisionDetection
105
113
  }: GetSchemasProps): GetSchemasResult;
106
114
  //#endregion
107
- export { getBanner, getComments, getFooter, getImports, getPathParams, getSchemaFactory, getSchemas, isOptional };
115
+ //#region src/utils/paramsCasing.d.ts
116
+ /**
117
+ * Apply casing transformation to schema properties
118
+ * Only transforms property names, not nested schemas
119
+ */
120
+ declare function applyParamsCasing(schema: SchemaObject, casing: 'camelcase' | undefined): SchemaObject;
121
+ /**
122
+ * Check if this schema is a parameter schema (pathParams, queryParams, or headerParams)
123
+ * Only these should be transformed, not response/data/body
124
+ */
125
+ declare function isParameterSchema(schemaName: string): boolean;
126
+ //#endregion
127
+ export { applyParamsCasing, getBanner, getComments, getFooter, getImports, getParamsMapping, getPathParams, getSchemaFactory, getSchemas, isOptional, isParameterSchema };
108
128
  //# sourceMappingURL=utils.d.cts.map
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { t as __name } from "./chunk-iVr_oF3V.js";
2
- import { S as Output, _ as contentType, b as Config, f as OasTypes, g as SchemaObject, h as Operation, l as isOptional, m as OpenAPIV3_1, p as OpenAPIV3, t as Schema, u as Oas } from "./SchemaMapper-DnWpiVfW.js";
3
- import { h as OperationSchema, w as FunctionParamsAST } from "./createGenerator-D30QUDWi.js";
2
+ import { _ as contentType, f as OasTypes, g as SchemaObject, h as Operation, l as isOptional, m as OpenAPIV3_1, p as OpenAPIV3, t as Schema, u as Oas } from "./SchemaMapper-CmwW1HVs.js";
3
+ import { h as OperationSchema, w as FunctionParamsAST } from "./createGenerator-Cd10rV1T.js";
4
+ import { Config, Output } from "@kubb/core";
4
5
  import { KubbFile } from "@kubb/fabric-core/types";
5
6
  import { Params } from "@kubb/react-fabric/types";
6
7
 
@@ -41,6 +42,13 @@ declare function getPathParams(operationSchema: OperationSchema | undefined, opt
41
42
  casing?: 'camelcase';
42
43
  override?: (data: FunctionParamsAST) => FunctionParamsAST;
43
44
  }): Params;
45
+ /**
46
+ * Get a mapping of camelCase parameter names to their original names
47
+ * Used for mapping function parameters to backend parameter names
48
+ */
49
+ declare function getParamsMapping(operationSchema: OperationSchema | undefined, options?: {
50
+ casing?: 'camelcase';
51
+ }): Record<string, string> | undefined;
44
52
  //#endregion
45
53
  //#region src/utils/getSchemaFactory.d.ts
46
54
  /**
@@ -105,5 +113,17 @@ declare function getSchemas({
105
113
  collisionDetection
106
114
  }: GetSchemasProps): GetSchemasResult;
107
115
  //#endregion
108
- export { getBanner, getComments, getFooter, getImports, getPathParams, getSchemaFactory, getSchemas, isOptional };
116
+ //#region src/utils/paramsCasing.d.ts
117
+ /**
118
+ * Apply casing transformation to schema properties
119
+ * Only transforms property names, not nested schemas
120
+ */
121
+ declare function applyParamsCasing(schema: SchemaObject, casing: 'camelcase' | undefined): SchemaObject;
122
+ /**
123
+ * Check if this schema is a parameter schema (pathParams, queryParams, or headerParams)
124
+ * Only these should be transformed, not response/data/body
125
+ */
126
+ declare function isParameterSchema(schemaName: string): boolean;
127
+ //#endregion
128
+ export { applyParamsCasing, getBanner, getComments, getFooter, getImports, getParamsMapping, getPathParams, getSchemaFactory, getSchemas, isOptional, isParameterSchema };
109
129
  //# sourceMappingURL=utils.d.ts.map
package/dist/utils.js CHANGED
@@ -2,7 +2,7 @@ import { t as __name } from "./chunk-iVr_oF3V.js";
2
2
  import { a as getSchemaFactory, t as SchemaGenerator } from "./SchemaGenerator-B3d6gOW8.js";
3
3
  import { n as schemaKeywords } from "./SchemaMapper-D-GETHNf.js";
4
4
  import { n as getBanner, t as getFooter } from "./getFooter-flVUU6wg.js";
5
- import { camelCase, isValidVarName } from "@kubb/core/transformers";
5
+ import transformers, { camelCase, isValidVarName } from "@kubb/core/transformers";
6
6
  import { URLPath } from "@kubb/core/utils";
7
7
  import { isOptional } from "@kubb/oas";
8
8
 
@@ -40,15 +40,16 @@ function getImports(tree) {
40
40
  * @deprecated
41
41
  * TODO move to operationManager hook
42
42
  */
43
- function getASTParams(operationSchema, { typed = false, override } = {}) {
43
+ function getASTParams(operationSchema, { typed = false, casing, override } = {}) {
44
44
  if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) return [];
45
45
  const requiredFields = Array.isArray(operationSchema.schema.required) ? operationSchema.schema.required : [];
46
46
  return Object.entries(operationSchema.schema.properties).map(([name]) => {
47
+ const accessName = casing === "camelcase" ? camelCase(name) : name;
47
48
  const data = {
48
49
  name,
49
50
  enabled: !!name,
50
51
  required: requiredFields.includes(name),
51
- type: typed ? `${operationSchema.name}["${name}"]` : void 0
52
+ type: typed ? `${operationSchema.name}["${accessName}"]` : void 0
52
53
  };
53
54
  return override ? override(data) : data;
54
55
  });
@@ -56,8 +57,9 @@ function getASTParams(operationSchema, { typed = false, override } = {}) {
56
57
  function getPathParams(operationSchema, options = {}) {
57
58
  return getASTParams(operationSchema, options).reduce((acc, curr) => {
58
59
  if (curr.name && curr.enabled) {
59
- let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name);
60
+ let name = curr.name;
60
61
  if (options.casing === "camelcase") name = camelCase(name);
62
+ else if (!isValidVarName(name)) name = camelCase(name);
61
63
  acc[name] = {
62
64
  default: curr.default,
63
65
  type: curr.type,
@@ -67,6 +69,21 @@ function getPathParams(operationSchema, options = {}) {
67
69
  return acc;
68
70
  }, {});
69
71
  }
72
+ /**
73
+ * Get a mapping of camelCase parameter names to their original names
74
+ * Used for mapping function parameters to backend parameter names
75
+ */
76
+ function getParamsMapping(operationSchema, options = {}) {
77
+ if (!operationSchema || !operationSchema.schema.properties) return;
78
+ const mapping = {};
79
+ Object.entries(operationSchema.schema.properties).forEach(([originalName]) => {
80
+ let transformedName = originalName;
81
+ if (options.casing === "camelcase") transformedName = camelCase(originalName);
82
+ else if (!isValidVarName(originalName)) transformedName = camelCase(originalName);
83
+ if (transformedName !== originalName) mapping[originalName] = transformedName;
84
+ });
85
+ return Object.keys(mapping).length > 0 ? mapping : void 0;
86
+ }
70
87
 
71
88
  //#endregion
72
89
  //#region src/utils/getSchemas.ts
@@ -92,5 +109,42 @@ function getSchemas({ oas, contentType, includes = [
92
109
  }
93
110
 
94
111
  //#endregion
95
- export { getBanner, getComments, getFooter, getImports, getPathParams, getSchemaFactory, getSchemas, isOptional };
112
+ //#region src/utils/paramsCasing.ts
113
+ /**
114
+ * Apply casing transformation to schema properties
115
+ * Only transforms property names, not nested schemas
116
+ */
117
+ function applyParamsCasing(schema, casing) {
118
+ if (!casing || !schema.properties) return schema;
119
+ const transformedProperties = {};
120
+ const transformedRequired = [];
121
+ Object.entries(schema.properties).forEach(([originalName, propertySchema]) => {
122
+ let transformedName = originalName;
123
+ if (casing === "camelcase") transformedName = transformers.camelCase(originalName);
124
+ else if (!isValidVarName(originalName)) transformedName = transformers.camelCase(originalName);
125
+ transformedProperties[transformedName] = propertySchema;
126
+ });
127
+ if (Array.isArray(schema.required)) schema.required.forEach((originalName) => {
128
+ let transformedName = originalName;
129
+ if (casing === "camelcase") transformedName = transformers.camelCase(originalName);
130
+ else if (!isValidVarName(originalName)) transformedName = transformers.camelCase(originalName);
131
+ transformedRequired.push(transformedName);
132
+ });
133
+ return {
134
+ ...schema,
135
+ properties: transformedProperties,
136
+ ...transformedRequired.length > 0 && { required: transformedRequired }
137
+ };
138
+ }
139
+ /**
140
+ * Check if this schema is a parameter schema (pathParams, queryParams, or headerParams)
141
+ * Only these should be transformed, not response/data/body
142
+ */
143
+ function isParameterSchema(schemaName) {
144
+ const lowerName = schemaName.toLowerCase();
145
+ return lowerName.includes("pathparams") || lowerName.includes("queryparams") || lowerName.includes("headerparams");
146
+ }
147
+
148
+ //#endregion
149
+ export { applyParamsCasing, getBanner, getComments, getFooter, getImports, getParamsMapping, getPathParams, getSchemaFactory, getSchemas, isOptional, isParameterSchema };
96
150
  //# sourceMappingURL=utils.js.map