Skip to content

Commit 4462341

Browse files
authored
feat: support activities (#43)
1 parent 9b0307f commit 4462341

File tree

9 files changed

+1451
-0
lines changed

9 files changed

+1451
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
rule:
2+
kind: user_type
3+
inside:
4+
kind: parameter
5+
regex: freeCancellationEndDateTime
6+
stopBy:
7+
kind: class_declaration
8+
regex: Builder
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
rule:
2+
kind: user_type
3+
pattern: $TYPE
4+
inside:
5+
any:
6+
- kind: class_parameter
7+
regex: freeCancellationEndDateTime
8+
- kind: nullable_type
9+
inside:
10+
kind: class_parameter
11+
regex: freeCancellationEndDateTime
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
rule:
2+
kind: user_type
3+
inside:
4+
kind: parameter
5+
regex: dateTime
6+
stopBy:
7+
kind: class_declaration
8+
regex: Builder
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
rule:
2+
kind: user_type
3+
pattern: $TYPE
4+
inside:
5+
any:
6+
- kind: class_parameter
7+
regex: dateTime
8+
- kind: nullable_type
9+
inside:
10+
kind: class_parameter
11+
regex: dateTime

customizations/generator/openapi/src/main/resources/post-processor/src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {NonCancellableDateTimeRangeProcessor} from './processors/non-cancellable
55
import {PenaltyRuleProcessor} from './processors/penalty-rule-processor';
66
import {VendorLocationDetailsProcessor} from './processors/vendor-location-details-processor';
77
import {GetCarsListingsOperationParamsProcessor} from './processors/get-cars-listings-operation-params-processor';
8+
import {ActivitiesCancellationPolicyProcessor} from './processors/activities-cancellation-policy-processor';
9+
import {AvailableTimeSlotProcessor} from './processors/available-time-slot-processor';
810

911
import * as path from 'path';
1012

@@ -34,4 +36,10 @@ switch (fileName) {
3436
case 'GetCarsListingsOperationParams':
3537
new GetCarsListingsOperationParamsProcessor().process(filePath);
3638
break;
39+
case 'ActivitiesCancellationPolicy':
40+
new ActivitiesCancellationPolicyProcessor().process(filePath);
41+
break;
42+
case 'AvailableTimeSlot':
43+
new AvailableTimeSlotProcessor().process(filePath);
44+
break;
3745
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {Edit, NapiConfig, SgNode} from '@ast-grep/napi';
2+
import {Processor} from './processor';
3+
import {RuleFunction} from './shared.types';
4+
5+
export class ActivitiesCancellationPolicyProcessor extends Processor {
6+
rules: RuleFunction[];
7+
id: String = 'activities-cancellation-policy';
8+
9+
constructor() {
10+
super();
11+
this.rules = [
12+
this.changeClassParamType,
13+
this.changeBuilderMethodParamType,
14+
].map(rule => rule.bind(this));
15+
}
16+
17+
changeClassParamType(root: SgNode): Edit[] {
18+
const config = this.readRule('change-class-param-type');
19+
20+
return root.findAll(config).map(node => {
21+
return node.replace('java.time.LocalDateTime');
22+
});
23+
}
24+
25+
changeBuilderMethodParamType(root: SgNode): Edit[] {
26+
const config = this.readRule('change-builder-method-param-type');
27+
28+
return root.findAll(config).map(node => {
29+
return node.replace('java.time.LocalDateTime');
30+
});
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {Edit, NapiConfig, SgNode} from '@ast-grep/napi';
2+
import {Processor} from './processor';
3+
import {RuleFunction} from './shared.types';
4+
5+
export class AvailableTimeSlotProcessor extends Processor {
6+
rules: RuleFunction[];
7+
id: String = 'available-time-slot';
8+
9+
constructor() {
10+
super();
11+
this.rules = [
12+
this.changeClassParamType,
13+
this.changeBuilderMethodParamType,
14+
].map(rule => rule.bind(this));
15+
}
16+
17+
changeClassParamType(root: SgNode): Edit[] {
18+
const config = this.readRule('change-class-param-type');
19+
20+
return root.findAll(config).map(node => {
21+
return node.replace('java.time.LocalDateTime');
22+
});
23+
}
24+
25+
changeBuilderMethodParamType(root: SgNode): Edit[] {
26+
const config = this.readRule('change-builder-method-param-type');
27+
28+
return root.findAll(config).map(node => {
29+
return node.replace('java.time.LocalDateTime');
30+
});
31+
}
32+
}

specs/openapi-merge.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
"dispute": {
2121
"prefix": "Sdp"
2222
}
23+
},
24+
{
25+
"inputFile": "./xap-activity.specs.yaml",
26+
"dispute": {
27+
"prefix": "Activities"
28+
}
2329
}
2430
],
2531
"output": "./specs.yaml"

0 commit comments

Comments
 (0)