Skip to content

Commit d36a12b

Browse files
committed
shouldSkip
1 parent 6e72e73 commit d36a12b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/OperationParser.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ export interface IOperationParser {
1010
action(operation: OpenAPIV3.OperationObject, context: OperationContext): string
1111

1212
description(operation: OpenAPIV3.OperationObject, context: OperationContext): string
13+
14+
shouldSkip(operation: OpenAPIV3.OperationObject, context: OperationContext): boolean;
1315
}
1416

1517
export class DefaultOperationParser implements IOperationParser {
18+
shouldSkip(operation: OpenAPIV3.OperationObject, context: OperationContext): boolean {
19+
return !!operation.deprecated
20+
}
21+
1622
name(operation: OpenAPIV3.OperationObject, context: OperationContext): string {
1723
return lodash.startCase(operation.operationId)
1824
}

src/OperationsCollector.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ export class BaseOperationsCollector implements OpenAPIVisitor {
7676
}
7777

7878
_visitOperation(operation: OpenAPIV3.OperationObject, context: OperationContext) {
79+
if (this.operationParser.shouldSkip(operation, context)) {
80+
this.logger.info(this.bindings, 'Skipping operation')
81+
return
82+
}
7983
const {option, fields: operationFields} = this.parseOperation(operation, context);
8084
const resources = operation.tags!!.map((tag: string) => this.resourceParser.value({name: tag}))
8185
for (const resourceName of resources) {
@@ -150,13 +154,6 @@ export class BaseOperationsCollector implements OpenAPIVisitor {
150154
}
151155

152156
export class OperationsCollector extends BaseOperationsCollector {
153-
visitOperation(operation: OpenAPIV3.OperationObject, context: OperationContext) {
154-
if (operation.deprecated) {
155-
return;
156-
}
157-
super.visitOperation(operation, context);
158-
}
159-
160157
protected parseOperation(operation: OpenAPIV3.OperationObject, context: OperationContext) {
161158
const result = super.parseOperation(operation, context)
162159
const notice: INodeProperties = {

0 commit comments

Comments
 (0)