@kubb/plugin-oas 4.31.3 → 4.31.5

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/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"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":";;;;;;;;;AAIA,SAAgB,YAAY,WAAgC;AAC1D,QAAO;EACL,UAAU,gBAAgB,IAAI,gBAAgB,UAAU,gBAAgB;EACxE,UAAU,YAAY,IAAI,YAAY,UAAU,YAAY;EAC5D,UAAU,QAAQ,UAAU,IAAI,QAAQ,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,QAFa,gBAAgB,WAAW,MAAM,eAAe,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,QACA,aAKE,EAAE,EACe;AACrB,KAAI,CAAC,mBAAmB,CAAC,gBAAgB,OAAO,cAAc,CA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;;;;;;;;;;ACzErD,SAAgB,WAAW,EAAE,KAAK,aAAa,WAAW;CAAC;CAAW;CAAiB;CAAY,EAAE,sBAAyD;AAC5J,QAAO,IAAI,WAAW;EACpB;EACA;EACA;EACD,CAAC;;;;;;;;;AChCJ,SAAgB,kBAAkB,QAAsB,QAA+C;AACrG,KAAI,CAAC,UAAU,CAAC,OAAO,WACrB,QAAO;CAGT,MAAM,wBAA6C,EAAE;CACrD,MAAM,sBAAgC,EAAE;AAGxC,QAAO,QAAQ,OAAO,WAAW,CAAC,SAAS,CAAC,cAAc,oBAAoB;EAC5E,IAAI,kBAAkB;AAEtB,MAAI,WAAW,YACb,mBAAkB,aAAa,UAAU,aAAa;WAC7C,CAAC,eAAe,aAAa,CAEtC,mBAAkB,aAAa,UAAU,aAAa;AAGxD,wBAAsB,mBAAmB;GACzC;AAGF,KAAI,MAAM,QAAQ,OAAO,SAAS,CAChC,QAAO,SAAS,SAAS,iBAAiB;EACxC,IAAI,kBAAkB;AAEtB,MAAI,WAAW,YACb,mBAAkB,aAAa,UAAU,aAAa;WAC7C,CAAC,eAAe,aAAa,CACtC,mBAAkB,aAAa,UAAU,aAAa;AAGxD,sBAAoB,KAAK,gBAAgB;GACzC;AAIJ,QAAO;EACL,GAAG;EACH,YAAY;EACZ,GAAI,oBAAoB,SAAS,KAAK,EAAE,UAAU,qBAAqB;EACxE;;;;;;AAOH,SAAgB,kBAAkB,YAA6B;CAC7D,MAAM,YAAY,WAAW,aAAa;AAC1C,QAAO,UAAU,SAAS,aAAa,IAAI,UAAU,SAAS,cAAc,IAAI,UAAU,SAAS,eAAe"}
1
+ {"version":3,"file":"utils.js","names":[],"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 allEntries: Array<[string, string]> = []\n let hasTransformation = false\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 allEntries.push([originalName, transformedName])\n\n if (transformedName !== originalName) {\n hasTransformation = true\n }\n })\n\n // When using explicit casing and there are transformations, include ALL params so that\n // mappedParams contains every parameter (not just the ones whose names changed).\n // This prevents params with already-camelCase names (e.g. 'page', 'search') from being\n // silently dropped when other params in the same schema do need transformation.\n if (options.casing === 'camelcase' && hasTransformation) {\n return Object.fromEntries(allEntries)\n }\n\n // When casing is not specified or no transformations are needed, only return changed entries\n const mapping: Record<string, string> = {}\n allEntries.forEach(([originalName, transformedName]) => {\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":";;;;;;;;;AAIA,SAAgB,YAAY,WAAgC;AAC1D,QAAO;EACL,UAAU,gBAAgB,IAAI,gBAAgB,UAAU,gBAAgB;EACxE,UAAU,YAAY,IAAI,YAAY,UAAU,YAAY;EAC5D,UAAU,QAAQ,UAAU,IAAI,QAAQ,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,QAFa,gBAAgB,WAAW,MAAM,eAAe,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,QACA,aAKE,EAAE,EACe;AACrB,KAAI,CAAC,mBAAmB,CAAC,gBAAgB,OAAO,cAAc,CAAC,gBAAgB,KAC7E,QAAO,EAAE;CAGX,MAAM,iBAAiB,MAAM,Q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ubb/plugin-oas",
3
- "version": "4.31.3",
3
+ "version": "4.31.5",
4
4
  "description": "OpenAPI Specification (OAS) plugin for Kubb, providing core functionality for parsing and processing OpenAPI/Swagger schemas for code generation.",
5
5
  "keywords": [
6
6
  "openapi",
@@ -83,8 +83,8 @@
83
83
  "dependencies": {
84
84
  "@kubb/react-fabric": "0.13.3",
85
85
  "remeda": "^2.33.6",
86
- "@kubb/core": "4.31.3",
87
- "@kubb/oas": "4.31.3"
86
+ "@kubb/core": "4.31.5",
87
+ "@kubb/oas": "4.31.5"
88
88
  },
89
89
  "peerDependencies": {
90
90
  "@kubb/react-fabric": "0.13.3"
@@ -1348,13 +1348,25 @@ export class SchemaGenerator<
1348
1348
  const schemaTasks = schemaEntries.map(([name, schemaObject]) =>
1349
1349
  schemaLimit(async () => {
1350
1350
  const options = this.#getOptions(name)
1351
- const tree = this.parse({ schema: schemaObject, name, parentName: null, rootName: name })
1351
+
1352
+ // Resolve schema if it's a $ref (can happen when the bundler deduplicates schemas
1353
+ // referenced from multiple external files). Without this, a $ref schema would be
1354
+ // parsed as a reference to itself, generating `z.lazy(() => schemaName)`.
1355
+ let resolvedSchemaObject = schemaObject
1356
+ if (isReference(schemaObject)) {
1357
+ const resolved = this.context.oas.get<OasTypes.SchemaObject>(schemaObject.$ref)
1358
+ if (resolved && !isReference(resolved)) {
1359
+ resolvedSchemaObject = resolved
1360
+ }
1361
+ }
1362
+
1363
+ const tree = this.parse({ schema: resolvedSchemaObject, name, parentName: null, rootName: name })
1352
1364
 
1353
1365
  if (generator.type === 'react') {
1354
1366
  await buildSchema(
1355
1367
  {
1356
1368
  name,
1357
- value: schemaObject,
1369
+ value: resolvedSchemaObject,
1358
1370
  tree,
1359
1371
  },
1360
1372
  {
@@ -1380,7 +1392,7 @@ export class SchemaGenerator<
1380
1392
  generator: this,
1381
1393
  schema: {
1382
1394
  name,
1383
- value: schemaObject,
1395
+ value: resolvedSchemaObject,
1384
1396
  tree,
1385
1397
  },
1386
1398
  plugin: {
@@ -86,7 +86,8 @@ export function getParamsMapping(
86
86
  return undefined
87
87
  }
88
88
 
89
- const mapping: Record<string, string> = {}
89
+ const allEntries: Array<[string, string]> = []
90
+ let hasTransformation = false
90
91
 
91
92
  Object.entries(operationSchema.schema.properties).forEach(([originalName]) => {
92
93
  let transformedName = originalName
@@ -99,7 +100,24 @@ export function getParamsMapping(
99
100
  transformedName = camelCase(originalName)
100
101
  }
101
102
 
102
- // Only add mapping if the names differ
103
+ allEntries.push([originalName, transformedName])
104
+
105
+ if (transformedName !== originalName) {
106
+ hasTransformation = true
107
+ }
108
+ })
109
+
110
+ // When using explicit casing and there are transformations, include ALL params so that
111
+ // mappedParams contains every parameter (not just the ones whose names changed).
112
+ // This prevents params with already-camelCase names (e.g. 'page', 'search') from being
113
+ // silently dropped when other params in the same schema do need transformation.
114
+ if (options.casing === 'camelcase' && hasTransformation) {
115
+ return Object.fromEntries(allEntries)
116
+ }
117
+
118
+ // When casing is not specified or no transformations are needed, only return changed entries
119
+ const mapping: Record<string, string> = {}
120
+ allEntries.forEach(([originalName, transformedName]) => {
103
121
  if (transformedName !== originalName) {
104
122
  mapping[originalName] = transformedName
105
123
  }