@alagoni97/cli 0.72.1 → 0.72.3

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.
@@ -8,6 +8,7 @@ const utils_3 = require("../utils");
8
8
  const errors_1 = require("../../../errors");
9
9
  const utils_4 = require("../../../utils");
10
10
  const security_1 = require("../../../inputs/openapi/security");
11
+ const utils_5 = require("../../../inputs/openapi/utils");
11
12
  const HTTP_METHODS = [
12
13
  'get',
13
14
  'post',
@@ -83,7 +84,11 @@ function processOperation(pathItem, method, path, payloads, parameters) {
83
84
  if (!operation) {
84
85
  return undefined;
85
86
  }
86
- const operationId = getOperationId(operation, method, path);
87
+ const operationId = (0, utils_5.deriveOperationId)({
88
+ operationId: operation.operationId,
89
+ method,
90
+ path
91
+ });
87
92
  const hasBody = METHODS_WITH_BODY.includes(method);
88
93
  // Look up payloads
89
94
  const requestPayload = hasBody
@@ -120,9 +125,12 @@ function processOperation(pathItem, method, path, payloads, parameters) {
120
125
  // Extract operation metadata for JSDoc
121
126
  const description = operation.description ?? operation.summary;
122
127
  const deprecated = operation.deprecated === true;
123
- // Generate the HTTP client function
128
+ // Generate the HTTP client function.
129
+ // Use the operationId directly as the function name; the HTTP method is
130
+ // already encoded in synthesized ids (and meaningful in spec-provided ones),
131
+ // so prepending the method here would double the verb (e.g. getGetUser).
124
132
  return (0, http_1.renderHttpFetchClient)({
125
- subName: (0, utils_3.pascalCase)(operationId),
133
+ functionName: (0, utils_3.camelCase)(operationId),
126
134
  requestMessageModule: hasBody ? requestMessageModule : undefined,
127
135
  requestMessageType: hasBody ? requestMessageType : undefined,
128
136
  replyMessageModule,
@@ -154,15 +162,3 @@ function validateOpenAPIContext(context) {
154
162
  }
155
163
  return { openapiDocument };
156
164
  }
157
- /**
158
- * Gets the operation ID from an OpenAPI operation.
159
- * Falls back to generating one from method+path if not present.
160
- */
161
- function getOperationId(operation, method, path) {
162
- if (operation.operationId) {
163
- return operation.operationId;
164
- }
165
- // Generate from method + path
166
- const sanitizedPath = path.replace(/[^a-zA-Z0-9]/g, '');
167
- return `${method}${sanitizedPath}`;
168
- }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processOpenAPIHeaders = void 0;
4
4
  const utils_1 = require("../../../generators/typescript/utils");
5
+ const utils_2 = require("../utils");
5
6
  // Helper function to convert OpenAPI header schema to JSON Schema
6
7
  function convertHeaderSchemaToJsonSchema(header) {
7
8
  let schema;
@@ -44,8 +45,11 @@ function extractHeadersFromOperations(paths) {
44
45
  return param.in === 'header';
45
46
  });
46
47
  if (allParameters.length > 0) {
47
- const operationId = operationObj.operationId ??
48
- `${method}${pathKey.replace(/[^a-zA-Z0-9]/g, '')}`;
48
+ const operationId = (0, utils_2.deriveOperationId)({
49
+ operationId: operationObj.operationId,
50
+ method,
51
+ path: pathKey
52
+ });
49
53
  operationHeaders[operationId] = headerParams;
50
54
  }
51
55
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createOpenAPIGenerator = exports.createParameterSchema = exports.convertParameterSchemaToJsonSchema = exports.processOpenAPIParameters = void 0;
4
4
  const utils_1 = require("../../../generators/typescript/utils");
5
+ const utils_2 = require("../utils");
5
6
  const modelina_1 = require("@asyncapi/modelina");
6
7
  // Constants for OpenAPI parameter metadata keys
7
8
  const X_PARAMETER_LOCATION = 'x-parameter-location';
@@ -9,6 +10,15 @@ const X_PARAMETER_STYLE = 'x-parameter-style';
9
10
  const X_PARAMETER_EXPLODE = 'x-parameter-explode';
10
11
  const X_PARAMETER_ALLOW_RESERVED = 'x-parameter-allowReserved';
11
12
  const X_PARAMETER_COLLECTION_FORMAT = 'x-parameter-collectionFormat';
13
+ /**
14
+ * Map the raw OpenAPI parameter name to the constrained TypeScript property
15
+ * name rendered by Modelina, falling back to the raw name when the model does
16
+ * not expose the property.
17
+ */
18
+ function getConstrainedPropertyName({ model, parameterName }) {
19
+ const constrainedProperty = Object.values(model.properties).find((property) => property.unconstrainedPropertyName === parameterName);
20
+ return constrainedProperty?.propertyName ?? parameterName;
21
+ }
12
22
  // OpenAPI parameter processor
13
23
  function processOpenAPIParameters(openapiDocument) {
14
24
  const channelParameters = {};
@@ -21,8 +31,11 @@ function processOpenAPIParameters(openapiDocument) {
21
31
  return ['path', 'query'].includes(param.in);
22
32
  });
23
33
  if (filteredParams.length > 0) {
24
- const operationId = operationObj.operationId ??
25
- `${method}${pathKey.replace(/[^a-zA-Z0-9]/g, '')}`;
34
+ const operationId = (0, utils_2.deriveOperationId)({
35
+ operationId: operationObj.operationId,
36
+ method,
37
+ path: pathKey
38
+ });
26
39
  // Create schema for the parameters
27
40
  const parameterSchema = createParameterSchema(operationId, filteredParams, 'Parameters', pathKey);
28
41
  channelParameters[operationId] = {
@@ -134,11 +147,21 @@ function generateOpenAPIParameterMethods(model) {
134
147
  for (const [propName, propSchema] of Object.entries(properties)) {
135
148
  const paramConfig = processParameterSchema(propName, propSchema);
136
149
  if (paramConfig) {
150
+ const parameterConfig = {
151
+ name: paramConfig.name,
152
+ propertyName: getConstrainedPropertyName({
153
+ model,
154
+ parameterName: propName
155
+ }),
156
+ style: paramConfig.style,
157
+ explode: paramConfig.explode,
158
+ allowReserved: paramConfig.allowReserved
159
+ };
137
160
  if (paramConfig.location === 'path') {
138
- pathParams.push(paramConfig);
161
+ pathParams.push(parameterConfig);
139
162
  }
140
163
  else if (paramConfig.location === 'query') {
141
- queryParams.push(paramConfig);
164
+ queryParams.push(parameterConfig);
142
165
  }
143
166
  }
144
167
  }
@@ -292,11 +315,11 @@ getChannelWithParameters(basePath: string): string {
292
315
  * Generate serialization code for a single path parameter
293
316
  */
294
317
  function generatePathParameterSerialization(param) {
295
- const { name, style, explode, allowReserved } = param;
318
+ const { name, propertyName, style, explode, allowReserved } = param;
296
319
  const encoding = allowReserved ? '' : 'encodeURIComponent';
297
320
  return ` // Serialize path parameter: ${name} (style: ${style}, explode: ${explode})
298
- if (this.${name} !== undefined && this.${name} !== null) {
299
- const value = this.${name};
321
+ if (this.${propertyName} !== undefined && this.${propertyName} !== null) {
322
+ const value = this.${propertyName};
300
323
  ${generatePathSerializationLogic(name, style, explode, encoding)}
301
324
  }`;
302
325
  }
@@ -304,11 +327,11 @@ function generatePathParameterSerialization(param) {
304
327
  * Generate serialization code for a single query parameter
305
328
  */
306
329
  function generateQueryParameterSerialization(param) {
307
- const { name, style, explode, allowReserved } = param;
330
+ const { name, propertyName, style, explode, allowReserved } = param;
308
331
  const encoding = allowReserved ? '' : 'encodeURIComponent';
309
332
  return ` // Serialize query parameter: ${name} (style: ${style}, explode: ${explode})
310
- if (this.${name} !== undefined && this.${name} !== null) {
311
- const value = this.${name};
333
+ if (this.${propertyName} !== undefined && this.${propertyName} !== null) {
334
+ const value = this.${propertyName};
312
335
  ${generateQuerySerializationLogic(name, style, explode, encoding)}
313
336
  }`;
314
337
  }
@@ -486,7 +509,11 @@ function generateDeserializationMethods(pathParams, queryParams, model) {
486
509
  methods += generateUrlDeserializationMethod(queryParams, model);
487
510
  }
488
511
  // Generate static fromUrl method
489
- methods += generateFromUrlStaticMethod(pathParams, model);
512
+ methods += generateFromUrlStaticMethod({
513
+ pathParams,
514
+ hasQueryParams: queryParams.length > 0,
515
+ model
516
+ });
490
517
  return methods;
491
518
  }
492
519
  /**
@@ -523,7 +550,7 @@ ${paramDeserializations}
523
550
  /**
524
551
  * Generate static fromUrl method
525
552
  */
526
- function generateFromUrlStaticMethod(pathParams, model) {
553
+ function generateFromUrlStaticMethod({ pathParams, hasQueryParams, model }) {
527
554
  const properties = model.originalInput?.properties ?? {};
528
555
  const requiredParams = [];
529
556
  // Find required parameters to determine constructor defaults
@@ -537,11 +564,11 @@ function generateFromUrlStaticMethod(pathParams, model) {
537
564
  const pathParamExtraction = pathParams.length > 0 ? generatePathParameterExtraction(pathParams) : '';
538
565
  // Generate constructor arguments with path parameters first, then required non-path parameters
539
566
  const pathParamArgs = pathParams
540
- .map((param) => `${param.name}: pathParams.${param.name}`)
567
+ .map((param) => `${param.propertyName}: pathParams.${param.propertyName}`)
541
568
  .join(', ');
542
569
  const requiredNonPathParams = requiredParams.filter((param) => !pathParams.some((pathParam) => pathParam.name === param));
543
570
  const requiredParamArgs = requiredNonPathParams
544
- .map((param) => `${param}: default${(0, utils_1.pascalCase)(param)}`)
571
+ .map((param) => `${getConstrainedPropertyName({ model, parameterName: param })}: default${(0, utils_1.pascalCase)(param)}`)
545
572
  .join(', ');
546
573
  let constructorArgs = '';
547
574
  if (pathParamArgs && requiredParamArgs) {
@@ -565,6 +592,11 @@ function generateFromUrlStaticMethod(pathParams, model) {
565
592
  .map((param) => `, default${(0, utils_1.pascalCase)(param)}: ${getParameterType(properties[param])} = ${generateDefaultValue(properties[param], param)}`)
566
593
  .join('')
567
594
  : '';
595
+ // deserializeUrl only exists on the class when there are query parameters
596
+ const deserializeUrlCall = hasQueryParams
597
+ ? `
598
+ instance.deserializeUrl(url);`
599
+ : '';
568
600
  return `
569
601
 
570
602
  /**
@@ -576,8 +608,7 @@ ${paramDocs}
576
608
  */
577
609
  static fromUrl(url: string, basePath: string${functionParams}): ${model.type} {
578
610
  ${pathParamExtraction}
579
- const instance = new ${model.type}({ ${constructorArgs} });
580
- instance.deserializeUrl(url);
611
+ const instance = new ${model.type}({ ${constructorArgs} });${deserializeUrlCall}
581
612
  return instance;
582
613
  }`;
583
614
  }
@@ -598,7 +629,7 @@ function generateQueryParameterDeserialization(param, model) {
598
629
  const { name, style, explode } = param;
599
630
  const properties = model.originalInput?.properties ?? {};
600
631
  const propSchema = properties[name];
601
- const logicCode = generateQueryDeserializationLogic(name, style, explode, propSchema);
632
+ const logicCode = generateQueryDeserializationLogic({ param, propSchema });
602
633
  return ` // Deserialize query parameter: ${name} (style: ${style}, explode: ${explode})
603
634
  if (params.has('${name}')) {
604
635
  const value = params.get('${name}');
@@ -608,36 +639,60 @@ function generateQueryParameterDeserialization(param, model) {
608
639
  /**
609
640
  * Generate query parameter deserialization logic
610
641
  */
611
- function generateQueryDeserializationLogic(name, style, explode, propSchema) {
642
+ function generateQueryDeserializationLogic({ param, propSchema }) {
612
643
  const isArray = propSchema?.type === 'array' || propSchema?.items;
613
644
  const isBoolean = propSchema?.type === 'boolean';
614
645
  const isNumber = propSchema?.type === 'integer' || propSchema?.type === 'number';
615
646
  const paramType = getParameterType(propSchema);
616
- switch (style) {
647
+ switch (param.style) {
617
648
  case 'form':
618
- return generateFormStyleDeserializationLogic(name, explode, isArray, isBoolean, isNumber, paramType);
649
+ return generateFormStyleDeserializationLogic({
650
+ param,
651
+ isArray,
652
+ isBoolean,
653
+ isNumber,
654
+ paramType
655
+ });
619
656
  case 'spaceDelimited':
620
- return generateSpaceDelimitedDeserializationLogic(name, explode, isArray, isBoolean, isNumber, paramType);
657
+ return generateSpaceDelimitedDeserializationLogic({
658
+ param,
659
+ isArray,
660
+ isBoolean,
661
+ isNumber,
662
+ paramType
663
+ });
621
664
  case 'pipeDelimited':
622
- return generatePipeDelimitedDeserializationLogic(name, explode, isArray, isBoolean, isNumber, paramType);
665
+ return generatePipeDelimitedDeserializationLogic({
666
+ param,
667
+ isArray,
668
+ isBoolean,
669
+ isNumber,
670
+ paramType
671
+ });
623
672
  case 'deepObject':
624
- return generateDeepObjectDeserializationLogic(name, isBoolean, isNumber, paramType);
673
+ return generateDeepObjectDeserializationLogic({
674
+ param,
675
+ isBoolean,
676
+ isNumber,
677
+ paramType
678
+ });
625
679
  default:
626
- throw new Error(`Unsupported style: ${style}`);
680
+ throw new Error(`Unsupported style: ${param.style}`);
627
681
  }
628
682
  }
629
683
  /**
630
684
  * Generate deserialization logic for form style
631
685
  */
632
- function generateFormStyleDeserializationLogic(name, explode, isArray, isBoolean, isNumber, paramType) {
686
+ function generateFormStyleDeserializationLogic({ param, isArray, isBoolean, isNumber, paramType }) {
687
+ const { name, propertyName, explode } = param;
633
688
  if (isArray && !explode) {
634
689
  const typecast = paramType.includes('[]') ? ` as ${paramType}` : '';
635
690
  return `if (value === '') {
636
- this.${name} = [];
691
+ this.${propertyName} = [];
637
692
  } else if (value) {
638
693
  // Split by comma and decode
639
694
  const decodedValues = value.split(',').map(val => decodeURIComponent(val.trim()));
640
- this.${name} = decodedValues${typecast};
695
+ this.${propertyName} = decodedValues${typecast};
641
696
  }`;
642
697
  }
643
698
  else if (isArray && explode) {
@@ -645,13 +700,13 @@ function generateFormStyleDeserializationLogic(name, explode, isArray, isBoolean
645
700
  return `const allValues = params.getAll('${name}');
646
701
  if (allValues.length > 0) {
647
702
  const decodedValues = allValues.map(val => decodeURIComponent(val));
648
- this.${name} = decodedValues${typecast};
703
+ this.${propertyName} = decodedValues${typecast};
649
704
  }`;
650
705
  }
651
706
  else if (isBoolean) {
652
707
  return `if (value) {
653
708
  const decodedValue = decodeURIComponent(value);
654
- this.${name} = decodedValue.toLowerCase() === 'true';
709
+ this.${propertyName} = decodedValue.toLowerCase() === 'true';
655
710
  }`;
656
711
  }
657
712
  else if (isNumber) {
@@ -659,7 +714,7 @@ function generateFormStyleDeserializationLogic(name, explode, isArray, isBoolean
659
714
  const decodedValue = decodeURIComponent(value);
660
715
  const numValue = Number(decodedValue);
661
716
  if (!isNaN(numValue)) {
662
- this.${name} = numValue;
717
+ this.${propertyName} = numValue;
663
718
  }
664
719
  }`;
665
720
  }
@@ -668,45 +723,58 @@ function generateFormStyleDeserializationLogic(name, explode, isArray, isBoolean
668
723
  : '';
669
724
  return `if (value) {
670
725
  const decodedValue = decodeURIComponent(value);
671
- this.${name} = decodedValue${typecast};
726
+ this.${propertyName} = decodedValue${typecast};
672
727
  }`;
673
728
  }
674
729
  /**
675
730
  * Generate deserialization logic for space delimited style
676
731
  */
677
- function generateSpaceDelimitedDeserializationLogic(name, explode, isArray, isBoolean, isNumber, paramType) {
678
- if (isArray && !explode) {
732
+ function generateSpaceDelimitedDeserializationLogic({ param, isArray, isBoolean, isNumber, paramType }) {
733
+ if (isArray && !param.explode) {
679
734
  const typecast = paramType.includes('[]') ? ` as ${paramType}` : '';
680
735
  return `if (value === '') {
681
- this.${name} = [];
736
+ this.${param.propertyName} = [];
682
737
  } else if (value) {
683
738
  // Split by space and decode
684
739
  const decodedValues = value.split(' ').map(val => decodeURIComponent(val.trim()));
685
- this.${name} = decodedValues${typecast};
740
+ this.${param.propertyName} = decodedValues${typecast};
686
741
  }`;
687
742
  }
688
- return generateFormStyleDeserializationLogic(name, explode, isArray, isBoolean, isNumber, paramType);
743
+ return generateFormStyleDeserializationLogic({
744
+ param,
745
+ isArray,
746
+ isBoolean,
747
+ isNumber,
748
+ paramType
749
+ });
689
750
  }
690
751
  /**
691
752
  * Generate deserialization logic for pipe delimited style
692
753
  */
693
- function generatePipeDelimitedDeserializationLogic(name, explode, isArray, isBoolean, isNumber, paramType) {
694
- if (isArray && !explode) {
754
+ function generatePipeDelimitedDeserializationLogic({ param, isArray, isBoolean, isNumber, paramType }) {
755
+ if (isArray && !param.explode) {
695
756
  const typecast = paramType.includes('[]') ? ` as ${paramType}` : '';
696
757
  return `if (value === '') {
697
- this.${name} = [];
758
+ this.${param.propertyName} = [];
698
759
  } else if (value) {
699
760
  // Split by pipe and decode
700
761
  const decodedValues = value.split('|').map(val => decodeURIComponent(val.trim()));
701
- this.${name} = decodedValues${typecast};
762
+ this.${param.propertyName} = decodedValues${typecast};
702
763
  }`;
703
764
  }
704
- return generateFormStyleDeserializationLogic(name, explode, isArray, isBoolean, isNumber, paramType);
765
+ return generateFormStyleDeserializationLogic({
766
+ param,
767
+ isArray,
768
+ isBoolean,
769
+ isNumber,
770
+ paramType
771
+ });
705
772
  }
706
773
  /**
707
774
  * Generate deserialization logic for deep object style
708
775
  */
709
- function generateDeepObjectDeserializationLogic(name, isBoolean, isNumber, paramType) {
776
+ function generateDeepObjectDeserializationLogic({ param, paramType }) {
777
+ const { name, propertyName } = param;
710
778
  const nameLength = name.length + 1;
711
779
  const typecast = paramType !== 'any' && paramType !== 'any | undefined'
712
780
  ? ` as ${paramType.replace(' | undefined', '')}`
@@ -720,7 +788,7 @@ function generateDeepObjectDeserializationLogic(name, isBoolean, isNumber, param
720
788
  }
721
789
  }
722
790
  if (Object.keys(deepObjectParams).length > 0) {
723
- this.${name} = deepObjectParams${typecast};
791
+ this.${propertyName} = deepObjectParams${typecast};
724
792
  }`;
725
793
  }
726
794
  /**
@@ -787,7 +855,7 @@ function generateExtractPathParametersMethod(pathParams, model) {
787
855
  const paramType = getParameterType(propSchema);
788
856
  const typecast = paramType !== 'string' ? ` as ${paramType}` : '';
789
857
  return ` case '${param.name}':
790
- result.${param.name} = ${conversion}${typecast};
858
+ result.${param.propertyName} = ${conversion}${typecast};
791
859
  break;`;
792
860
  })
793
861
  .join('\n');
@@ -799,7 +867,7 @@ function generateExtractPathParametersMethod(pathParams, model) {
799
867
  * @param basePath The base path template (e.g., '/pet/findByStatus/{status}/{categoryId}')
800
868
  * @returns Object containing extracted path parameter values
801
869
  */
802
- private static extractPathParameters(url: string, basePath: string): { ${pathParams.map((p) => `${p.name}: ${getParameterType(properties[p.name])}`).join(', ')} } {
870
+ private static extractPathParameters(url: string, basePath: string): { ${pathParams.map((p) => `${p.propertyName}: ${getParameterType(properties[p.name])}`).join(', ')} } {
803
871
  // Remove query string from URL for path matching
804
872
  const urlPath = url.split('?')[0];
805
873
 
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processOpenAPIPayloads = void 0;
4
4
  const utils_1 = require("../../../generators/typescript/utils");
5
5
  const utils_2 = require("../../../utils");
6
+ const utils_3 = require("../utils");
6
7
  // Constants
7
8
  const JSON_SCHEMA_DRAFT_07 = 'http://json-schema.org/draft-07/schema';
8
9
  // Helper function to extract schema from OpenAPI 2.0 response
@@ -98,8 +99,11 @@ function extractPayloadsFromOperations(paths) {
98
99
  continue;
99
100
  }
100
101
  const operationObj = operation;
101
- const operationId = operationObj.operationId ??
102
- `${method}${pathKey.replace(/[^a-zA-Z0-9]/g, '')}`;
102
+ const operationId = (0, utils_3.deriveOperationId)({
103
+ operationId: operationObj.operationId,
104
+ method,
105
+ path: pathKey
106
+ });
103
107
  // Extract request payload schema
104
108
  let requestSchema = null;
105
109
  // Check if this is OpenAPI 2.0 vs 3.x based on the structure
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateOpenAPITypes = void 0;
4
+ const utils_1 = require("../utils");
4
5
  async function generateOpenAPITypes(openapiDocument, generator) {
5
6
  const paths = openapiDocument.paths ?? {};
6
7
  const allPaths = Object.keys(paths);
@@ -22,8 +23,11 @@ async function generateOpenAPITypes(openapiDocument, generator) {
22
23
  if (operationObj &&
23
24
  typeof operationObj === 'object' &&
24
25
  method !== 'parameters') {
25
- const operationId = operationObj.operationId ??
26
- `${method}${pathStr.replace(/[^a-zA-Z0-9]/g, '')}`;
26
+ const operationId = (0, utils_1.deriveOperationId)({
27
+ operationId: operationObj.operationId,
28
+ method,
29
+ path: pathStr
30
+ });
27
31
  operationIds.push(operationId);
28
32
  operationIdToPathMap[operationId] = pathStr;
29
33
  pathOperationIds.push(operationId);
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Derive the operation identifier used to correlate payloads, parameters,
3
+ * headers and channel functions for a single OpenAPI operation.
4
+ *
5
+ * When the spec provides an `operationId` it is used verbatim so generated
6
+ * names stay predictable. Otherwise a name is synthesized from the HTTP method
7
+ * and path segments, preserving word boundaries so it can be cased cleanly
8
+ * (e.g. `GET /v2/connect/{referenceId}` -> `getV2ConnectReferenceId`) instead
9
+ * of collapsing into an uncasable blob (`getv2connectreferenceId`).
10
+ */
11
+ export declare function deriveOperationId({ operationId, method, path }: {
12
+ operationId?: string;
13
+ method: string;
14
+ path: string;
15
+ }): string;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deriveOperationId = void 0;
4
+ /**
5
+ * Shared helpers for deriving stable identifiers from OpenAPI operations.
6
+ */
7
+ const modelina_1 = require("@asyncapi/modelina");
8
+ /**
9
+ * Derive the operation identifier used to correlate payloads, parameters,
10
+ * headers and channel functions for a single OpenAPI operation.
11
+ *
12
+ * When the spec provides an `operationId` it is used verbatim so generated
13
+ * names stay predictable. Otherwise a name is synthesized from the HTTP method
14
+ * and path segments, preserving word boundaries so it can be cased cleanly
15
+ * (e.g. `GET /v2/connect/{referenceId}` -> `getV2ConnectReferenceId`) instead
16
+ * of collapsing into an uncasable blob (`getv2connectreferenceId`).
17
+ */
18
+ function deriveOperationId({ operationId, method, path }) {
19
+ if (operationId) {
20
+ return operationId;
21
+ }
22
+ const segments = path
23
+ .split('/')
24
+ .map((segment) => segment.replace(/[{}]/g, ''))
25
+ .filter((segment) => segment.length > 0);
26
+ return modelina_1.FormatHelpers.toCamelCase([method, ...segments].join(' '));
27
+ }
28
+ exports.deriveOperationId = deriveOperationId;
@@ -506,5 +506,5 @@
506
506
  ]
507
507
  }
508
508
  },
509
- "version": "0.72.1"
509
+ "version": "0.72.3"
510
510
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alagoni97/cli",
3
3
  "description": "CLI to work with code generation in any environment",
4
- "version": "0.72.1",
4
+ "version": "0.72.3",
5
5
  "bin": {
6
6
  "codegen": "./bin/run.mjs"
7
7
  },