Skip to content

Commit eed64e1

Browse files
committed
maintain old operation name
1 parent ff3da10 commit eed64e1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/utils/postProcessServiceOperations.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@ import type { Operation } from '../client/interfaces/Operation';
22
import type { Service } from '../client/interfaces/Service';
33
import { flatMap } from './flatMap';
44

5+
function removeServicenameAndLowercase(text: string, searchString: string) {
6+
if (text.toLowerCase().startsWith(searchString.toLowerCase())) {
7+
const modifiedText = text.slice(searchString.length);
8+
const firstChar = modifiedText.charAt(0).toLowerCase();
9+
return firstChar + modifiedText.slice(1);
10+
}
11+
return text;
12+
}
13+
514
export const postProcessServiceOperations = (service: Service): Operation[] => {
615
const names = new Map<string, number>();
716

817
return service.operations.map(operation => {
918
const clone = { ...operation };
1019

20+
clone.name = removeServicenameAndLowercase(clone.name, service.name);
21+
1122
// Parse the service parameters and results, very similar to how we parse
1223
// properties of models. These methods will extend the type if needed.
1324
clone.imports.push(...flatMap(clone.parameters, parameter => parameter.imports));

0 commit comments

Comments
 (0)