Skip to content

Commit cbe6807

Browse files
committed
Make defaults better
1 parent 9ab929a commit cbe6807

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/OperationParser.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,16 @@ export class DefaultOperationParser implements IOperationParser {
4343
}
4444

4545
name(operation: OpenAPIV3.OperationObject, context: OperationContext): string {
46-
return lodash.startCase(operation.operationId)
46+
if (operation.operationId) {
47+
return lodash.startCase(operation.operationId)
48+
}
49+
return context.method.toUpperCase() + " " + context.pattern
4750
}
4851

4952
value(operation: OpenAPIV3.OperationObject, context: OperationContext): string {
50-
return lodash.startCase(operation.operationId)
53+
let name = this.name(operation, context)
54+
// replace all non-alphanumeric characters with '-'
55+
return name.replace(/[^a-zA-Z0-9]/g, '-');
5156
}
5257

5358
action(operation: OpenAPIV3.OperationObject, context: OperationContext): string {

0 commit comments

Comments
 (0)