Skip to content

Commit d687cdd

Browse files
authored
Merge pull request #2041 from alexvuka1/fix-operation-id-casing
fix: operationToId should convert case based on config
2 parents 6ec51d9 + 2755be9 commit d687cdd

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.changeset/witty-dolls-applaud.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/openapi-ts": patch
3+
---
4+
5+
fix(parser): respect `output.case` when generating operation id

packages/openapi-ts/src/openApi/shared/utils/operation.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,18 @@ export const operationToId = ({
3737
}): string => {
3838
let result: string;
3939

40+
const { output } = context.config;
41+
const targetCase =
42+
(output !== undefined && 'case' in output ? output.case : undefined) ??
43+
'camelCase';
44+
4045
if (
4146
id &&
4247
(!context.config.plugins['@hey-api/sdk'] ||
4348
context.config.plugins['@hey-api/sdk'].config.operationId)
4449
) {
4550
result = stringCase({
46-
case: 'camelCase',
51+
case: targetCase,
4752
value: sanitizeNamespaceIdentifier(id),
4853
});
4954
} else {
@@ -53,7 +58,7 @@ export const operationToId = ({
5358
.replace(/[/:+]/g, '-');
5459

5560
result = stringCase({
56-
case: 'camelCase',
61+
case: targetCase,
5762
value: `${method}-${pathWithoutPlaceholders}`,
5863
});
5964
}

0 commit comments

Comments
 (0)