Skip to content

Commit a4519f7

Browse files
author
Matthew
committed
Added support for operation names
1 parent 93758f1 commit a4519f7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/openApi/v3/parser/getOperationName.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import camelCase from 'camelcase';
22

3+
const operations = ["create", "list", "retrieve", "delete", "update"]
4+
35
/**
46
* Convert the input value to a correct operation (method) classname.
57
* This will use the operation ID - if available - and otherwise fallback
68
* on a generated name from the URL
79
*/
810
export const getOperationName = (url: string, method: string, operationId?: string): string => {
911
if (operationId) {
12+
const popped = operationId.split("-").pop()
13+
if (popped && operations.includes(popped)) {
14+
return popped;
15+
}
1016
return camelCase(
1117
operationId
1218
.replace(/^[^a-zA-Z]+/g, '')

0 commit comments

Comments
 (0)