Skip to content

Commit ce16178

Browse files
committed
Add OperationName Shortening
1 parent 4667e47 commit ce16178

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/openApi/v2/parser/getOperation.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export function getOperation(
2525
const operationNameFallback = `${method}${serviceName}`;
2626
const operationName = getOperationName(op.operationId || operationNameFallback);
2727
const operationPath = getOperationPath(url);
28-
2928
// Create a new operation object for this method.
3029
const operation: Operation = {
3130
service: serviceName,

src/openApi/v2/parser/getOperationName.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,22 @@ import camelCase from 'camelcase';
66
* the most popular Javascript and Typescript writing style.
77
*/
88
export function getOperationName(value: string): string {
9-
const clean = value
9+
let clean = value
1010
.replace(/^[^a-zA-Z]+/g, '')
1111
.replace(/[^\w\-]+/g, '-')
1212
.trim();
13+
14+
if (clean.startsWith('List')) {
15+
clean = 'List';
16+
} else if (clean.startsWith('Fetch')) {
17+
clean = 'Fetch';
18+
} else if (clean.startsWith('Create')) {
19+
clean = 'Create';
20+
} else if (clean.startsWith('Update')) {
21+
clean = 'Update';
22+
} else if (clean.startsWith('Remove')) {
23+
clean = 'Remove';
24+
}
25+
1326
return camelCase(clean);
1427
}

0 commit comments

Comments
 (0)