@@ -212,7 +212,71 @@ The default implementation you can find in [src/ResourceParser.ts](src/ResourceP
212212
213213## Operation
214214
215- tbd
215+ You can override the way how to extract ** Operation** from ** OpenAPI Operation** defining your custom
216+ ` IOperationParser ` :
217+
218+ ``` typescript
219+ import {IOperationParser } from ' @devlikeapro/n8n-openapi-node' ;
220+
221+ export class CustomOperationParser implements IOperationParser {
222+ shouldSkip(operation : OpenAPIV3 .OperationObject , context : OperationContext ): boolean {
223+ // By default it skips operation.deprecated
224+ // But we can include all operations
225+ return false
226+ }
227+
228+ name(operation : OpenAPIV3 .OperationObject , context : OperationContext ): string {
229+ if (operation [' X-Visible-Name' ]) {
230+ return operation [' X-Visible-Name' ];
231+ }
232+ return lodash .startCase (operation .operationId )
233+ }
234+
235+ value(operation : OpenAPIV3 .OperationObject , context : OperationContext ): string {
236+ return lodash .startCase (operation .operationId )
237+ }
238+
239+ action(operation : OpenAPIV3 .OperationObject , context : OperationContext ): string {
240+ // How operation is displayed in n8n when you select your node (right form)
241+ return operation .summary || this .name (operation , context )
242+ }
243+
244+ description(operation : OpenAPIV3 .OperationObject , context : OperationContext ): string {
245+ return operation .description || operation .summary || ' ' ;
246+ }
247+ }
248+ ```
249+
250+ Or you can use ` DefaultOperationParser ` and override only the methods you need:
251+
252+ ``` typescript
253+ import {DefaultOperationParser } from ' @devlikeapro/n8n-openapi-node' ;
254+
255+ export class CustomOperationParser extends DefaultOperationParser {
256+ name(operation : OpenAPIV3 .OperationObject , context : OperationContext ): string {
257+ // NestJS add operationId in format CatController_findOne
258+ let operationId: string = operation .operationId !! .split (' _' ).slice (1 ).join (' _' );
259+ if (! operationId ) {
260+ operationId = operation .operationId as string ;
261+ }
262+ return lodash .startCase (operationId );
263+ }
264+ }
265+ ```
266+
267+ Then you use it in ` N8NPropertiesBuilder ` in ` config.operation ` :
268+
269+ ``` typescript
270+ import {N8NPropertiesBuilder , N8NPropertiesBuilderConfig } from ' @devlikeapro/n8n-openapi-node' ;
271+ import * as doc from ' ./openapi.json' ;
272+ import {CustomOperationParser } from ' ./CustomOperationParser' ;
273+
274+ const config: N8NPropertiesBuilderConfig = {
275+ operation: new CustomOperationParser ()
276+ }
277+ const parser = new N8NPropertiesBuilder (doc , config );
278+ const properties = parser .build ()
279+ ```
216280
217281## Fields
218282
0 commit comments