@@ -2,6 +2,8 @@ import {N8NPropertiesBuilder, N8NPropertiesBuilderConfig} from "../src/N8NProper
22import { OperationsCollector } from "../src/OperationsCollector" ;
33import { OpenAPIV3 } from "openapi-types" ;
44import { OperationContext } from "../src/openapi/OpenAPIVisitor" ;
5+ import { DefaultOperationParser } from "../src/OperationParser" ;
6+ import * as lodash from "lodash" ;
57
68function sessionFirst ( a : any , b : any ) {
79 if ( a . name === 'session' ) {
@@ -13,6 +15,28 @@ function sessionFirst(a: any, b: any) {
1315 return 0 ;
1416}
1517
18+ export class WAHAOperationParser extends DefaultOperationParser {
19+ name ( operation : OpenAPIV3 . OperationObject , context : OperationContext ) : string {
20+ let operationId : string = operation . operationId ! ! . split ( '_' ) . slice ( 1 ) . join ( '_' ) ;
21+ if ( ! operationId ) {
22+ operationId = operation . operationId as string
23+ }
24+ return lodash . startCase ( operationId )
25+ }
26+
27+ value ( operation : OpenAPIV3 . OperationObject , context : OperationContext ) : string {
28+ return this . name ( operation , context )
29+ }
30+
31+ action ( operation : OpenAPIV3 . OperationObject , context : OperationContext ) : string {
32+ return operation . summary || this . name ( operation , context )
33+ }
34+
35+ description ( operation : OpenAPIV3 . OperationObject , context : OperationContext ) : string {
36+ return operation . description || operation . summary || '' ;
37+ }
38+ }
39+
1640export class WAHAOperationsCollector extends OperationsCollector {
1741 parseFields ( operation : OpenAPIV3 . OperationObject , context : OperationContext ) {
1842 const fields = super . parseFields ( operation , context ) ;
@@ -25,6 +49,7 @@ test('waha.json', () => {
2549 const doc = require ( './examples/waha.json' ) ;
2650 const config : N8NPropertiesBuilderConfig = {
2751 OperationsCollector : WAHAOperationsCollector ,
52+ operation : new WAHAOperationParser ( ) ,
2853 }
2954 const parser = new N8NPropertiesBuilder ( doc , config ) ;
3055 const result = parser . build ( )
0 commit comments