Skip to content

Commit

Permalink
Merge pull request #663 from Stono/main
Browse files Browse the repository at this point in the history
Example
  • Loading branch information
mrlubos authored Jun 16, 2024
2 parents e46a91f + e01c612 commit 93d3d72
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wet-snakes-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hey-api/openapi-ts': minor
---

Add support for customising method names
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"editor.codeActionsOnSave": {
"source.organizeImports": "never",
"source.fixAll.eslint": "explicit"
},
"[typescript]": {
"editor.codeActionsOnSave": {
"source.organizeImports": "never"
}
},
"editor.quickSuggestions": {
"strings": true
},
Expand Down
4 changes: 4 additions & 0 deletions packages/openapi-ts/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ export interface ClientConfig {
* @default '{{name}}Service'
*/
name?: string;
/**
* Customise the method name of methods within the service
*/
methodNameBuilder?: (service: string, operationId: string) => string;
/**
* Use operation ID to generate operation names?
* @default true
Expand Down
4 changes: 3 additions & 1 deletion packages/openapi-ts/src/utils/write/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,9 @@ export const processService = (
accessLevel: 'public',
comment: toOperationComment(operation),
isStatic: config.name === undefined && config.client !== 'angular',
name: operation.name,
name: config.services.methodNameBuilder
? config.services.methodNameBuilder(operation.service, operation.name)
: operation.name,
parameters: toOperationParamType(client, operation),
returnType: isStandalone
? undefined
Expand Down

0 comments on commit 93d3d72

Please sign in to comment.