@@ -3,10 +3,11 @@ import * as lodash from "lodash";
33import pino from "pino" ;
44import { OpenAPIV3 } from "openapi-types" ;
55import { N8NINodeProperties } from "./SchemaToINodeProperties" ;
6- import { IOperationParser , N8NOperationParser } from "./OperationParser" ;
6+ import { DefaultOperationParser , IOperationParser } from "./OperationParser" ;
77import { OptionsByResourceMap } from "./n8n/OptionsByResourceMap" ;
88import { INodeProperties } from "n8n-workflow" ;
99import { replacePathVarsToParameter } from "./n8n/utils" ;
10+ import { DefaultResourceParser , IResourceParser } from "../ResourceParser" ;
1011
1112export class BaseOperationsCollector implements OpenAPIVisitor {
1213 public readonly _fields : INodeProperties [ ]
@@ -15,7 +16,8 @@ export class BaseOperationsCollector implements OpenAPIVisitor {
1516 private n8nNodeProperties : N8NINodeProperties ;
1617
1718 // Dependency injection light version
18- protected operationParser : IOperationParser = new N8NOperationParser ( )
19+ protected operationParser : IOperationParser = new DefaultOperationParser ( )
20+ protected resourceParser : IResourceParser = new DefaultResourceParser ( )
1921 private bindings : any
2022
2123 constructor ( logger : pino . Logger , doc : any ) {
@@ -73,12 +75,8 @@ export class BaseOperationsCollector implements OpenAPIVisitor {
7375 }
7476
7577 _visitOperation ( operation : OpenAPIV3 . OperationObject , context : OperationContext ) {
76- const tags = operation . tags ;
77- if ( ! tags || tags . length === 0 ) {
78- throw new Error ( `No tags found for operation '${ operation } '` ) ;
79- }
8078 const { option, fields : operationFields } = this . parseOperation ( operation , context ) ;
81- const resources = this . operationParser . getResources ( operation , context ) ;
79+ const resources = operation . tags ! ! . map ( ( tag : string ) => this . resourceParser . value ( { name : tag } ) )
8280 for ( const resourceName of resources ) {
8381 const fields = lodash . cloneDeep ( operationFields )
8482 const operationName = option . name ;
@@ -127,14 +125,12 @@ export class BaseOperationsCollector implements OpenAPIVisitor {
127125 protected parseOperation ( operation : OpenAPIV3 . OperationObject , context : OperationContext ) {
128126 const method = context . method
129127 const uri = context . pattern ;
130- const operationName = this . operationParser . getOperationName ( operation , context ) ;
131- const optionAction = this . operationParser . getOptionAction ( operation , context ) ;
132- const description = this . operationParser . getOptionDescription ( operation , context )
128+ const parser = this . operationParser
133129 const option = {
134- name : operationName ,
135- value : operationName ,
136- action : optionAction ,
137- description : description ,
130+ name : parser . name ( operation , context ) ,
131+ value : parser . value ( operation , context ) ,
132+ action : parser . action ( operation , context ) ,
133+ description : parser . description ( operation , context ) ,
138134 routing : {
139135 request : {
140136 method : method . toUpperCase ( ) ,
0 commit comments