@kubb/adapter-oas 5.19.1 → 5.20.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.
package/dist/index.cjs CHANGED
@@ -21,7 +21,7 @@ var compatibility = {
21
21
  "node": ">=22.22"
22
22
  };
23
23
  // package.json
24
- var version = "5.19.1";
24
+ var version = "5.20.0";
25
25
  // src/constants.ts
26
26
  /**
27
27
  * Default parser options applied when no explicit options are provided.
@@ -2496,6 +2496,19 @@ function parseOperation({ operation, ...ctx }) {
2496
2496
  ...auth && { auth }
2497
2497
  });
2498
2498
  }
2499
+ /** Renames path parameters and their `{placeholder}` to the camelCase names from {@link Url.toParamNames}. */
2500
+ function camelCasePathParams(node) {
2501
+ if (!node.path || node.parameters.some((param) => param.in === "path" && param.style === "matrix")) return node;
2502
+ const names = _kubb_kit.Url.toParamNames(node.path);
2503
+ return {
2504
+ ...node,
2505
+ path: node.path.replace(/\{([^}]+)\}/g, (_match, name) => `{${names.get(name) ?? name}}`),
2506
+ parameters: node.parameters.map((param) => param.in === "path" && names.has(param.name) ? {
2507
+ ...param,
2508
+ name: names.get(param.name)
2509
+ } : param)
2510
+ };
2511
+ }
2499
2512
  // src/emit/createNode.ts
2500
2513
  /**
2501
2514
  * Builds a schema node from a converter's base context plus its type-specific fields. Every
@@ -3945,19 +3958,20 @@ const adapterOas = (0, _kubb_core.defineExtension)({
3945
3958
  compatibility,
3946
3959
  issues: "https://github.com/kubb-labs/kubb/issues"
3947
3960
  },
3948
- setup: ({ validate = true, contentType, server, discriminator = "preserve", enums = "inline", dateType = DEFAULT_PARSER_OPTIONS.dateType, integerType = DEFAULT_PARSER_OPTIONS.integerType, unknownType = DEFAULT_PARSER_OPTIONS.unknownType, enumSuffix = DEFAULT_PARSER_OPTIONS.enumSuffix, emptySchemaType = unknownType || DEFAULT_PARSER_OPTIONS.emptySchemaType }) => ({
3961
+ setup: ({ validate = true, contentType, server, discriminator = "preserve", enums = "inline", pathParamsCasing, dateType = DEFAULT_PARSER_OPTIONS.dateType, integerType = DEFAULT_PARSER_OPTIONS.integerType, unknownType = DEFAULT_PARSER_OPTIONS.unknownType, enumSuffix = DEFAULT_PARSER_OPTIONS.enumSuffix, emptySchemaType = unknownType || DEFAULT_PARSER_OPTIONS.emptySchemaType }) => ({
3949
3962
  validate,
3950
3963
  contentType,
3951
3964
  server,
3952
3965
  discriminator,
3953
3966
  enums,
3967
+ pathParamsCasing,
3954
3968
  dateType,
3955
3969
  integerType,
3956
3970
  unknownType,
3957
3971
  emptySchemaType,
3958
3972
  enumSuffix
3959
3973
  }),
3960
- build({ validate, contentType, server, discriminator, enums, ...parserOptions }) {
3974
+ build({ validate, contentType, server, discriminator, enums, pathParamsCasing, ...parserOptions }) {
3961
3975
  let parsedDocument = null;
3962
3976
  let sources = [];
3963
3977
  const pendingValidations = [];
@@ -3983,14 +3997,17 @@ const adapterOas = (0, _kubb_core.defineExtension)({
3983
3997
  if (discriminator === "propagate" && (schema.oneOf ?? schema.anyOf) && schema.discriminator?.propertyName) discriminatorParentNodes.push(node);
3984
3998
  }
3985
3999
  const discriminatorChildMap = discriminatorParentNodes.length > 0 ? buildDiscriminatorChildMap(discriminatorParentNodes) : null;
3986
- const operationNodes = getOperations(document, refs).map((operation) => parseOperation({
3987
- operation,
3988
- document,
3989
- refs,
3990
- contentType,
3991
- options: parserOptions,
3992
- parseSchema
3993
- }));
4000
+ const operationNodes = getOperations(document, refs).map((operation) => {
4001
+ const node = parseOperation({
4002
+ operation,
4003
+ document,
4004
+ refs,
4005
+ contentType,
4006
+ options: parserOptions,
4007
+ parseSchema
4008
+ });
4009
+ return pathParamsCasing === "camelcase" ? camelCasePathParams(node) : node;
4010
+ });
3994
4011
  const promotedEnums = enums === "root" ? collectInlineEnums([...parsedByName.values(), ...operationNodes], new Set(Object.keys(schemas))) : null;
3995
4012
  const aliasTargetOf = (name) => {
3996
4013
  const node = refAliasMap.get(name);