This repository has been archived by the owner on Jan 4, 2024. It is now read-only.
forked from Adyen/adyen-java-api-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
171 lines (151 loc) · 7.15 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
openapi-generator-version:=6.0.1
openapi-generator-url:=https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$(openapi-generator-version)/openapi-generator-cli-$(openapi-generator-version).jar
openapi-generator-jar:=target/openapi-generator-cli.jar
openapi-generator-cli:=java -jar $(openapi-generator-jar)
generator:=java
library:=jersey3
modelGen:=acswebhooks balancecontrol balanceplatform binlookup checkout dataprotection legalentitymanagement management payment payout posterminalmanagement recurring transfers storedvalue configurationwebhooks reportwebhooks transferwebhooks managementwebhooks disputes transactionwebhooks
models:=src/main/java/com/adyen/model
output:=target/out
# Generate models (for each service)
models: $(modelGen)
balancecontrol: spec=BalanceControlService-v1
balancecontrol: smallServiceName=BalanceControlApi
binlookup: spec=BinLookupService-v54
binlookup: smallServiceName=BinLookupApi
checkout: spec=CheckoutService-v71
dataprotection: spec=DataProtectionService-v1
dataprotection: smallServiceName=DataProtectionApi
storedvalue: spec=StoredValueService-v46
storedvalue: smallServiceName=StoredValueApi
posterminalmanagement: spec=TfmAPIService-v1
posterminalmanagement: smallServiceName=PosTerminalManagementApi
payment: spec=PaymentService-v68
payment: smallServiceName=PaymentApi
recurring: spec=RecurringService-v68
recurring: smallServiceName=RecurringApi
payout: spec=PayoutService-v68
management: spec=ManagementService-v3
balanceplatform: spec=BalancePlatformService-v2
transfers: spec=TransferService-v4
legalentitymanagement: spec=LegalEntityService-v3
# Classic Platforms
marketpayaccount: spec=AccountService-v6
marketpayaccount: smallServiceName=ClassicPlatformAccountApi
marketpayfund: spec=FundService-v6
marketpayfund: smallServiceName=ClassicPlatformFundApi
marketpayconfiguration: spec=NotificationConfigurationService-v6
marketpayconfiguration: smallServiceName=ClassicPlatformConfigurationApi
marketpayhop: spec=HopService-v6
marketpayhop: smallServiceName=ClassicPlatformHopApi
marketpaywebhooks: spec=MarketPayNotificationService-v6
# Balance Webhooks
acswebhooks: spec=BalancePlatformAcsNotification-v1
configurationwebhooks: spec=BalancePlatformConfigurationNotification-v1
reportwebhooks: spec=BalancePlatformReportNotification-v1
transferwebhooks: spec=BalancePlatformTransferNotification-v4
transactionwebhooks: spec=BalancePlatformTransactionNotification-v4
# Management Webhooks
managementwebhooks: spec=ManagementNotificationService-v3
# Disputes
disputes: spec=DisputeService-v30
disputes: smallServiceName=DisputesApi
$(modelGen): target/spec $(openapi-generator-jar)
rm -rf $(models)/$@ $(output)
$(openapi-generator-cli) generate \
-i target/spec/json/$(spec).json \
-g $(generator) \
-t templates \
-o $(output) \
--reserved-words-mappings configuration=configuration \
--ignore-file-override ./.openapi-generator-ignore \
--skip-validate-spec \
--model-package $(subst /,.,com.adyen.model.$@) \
--library $(library) \
--global-property modelDocs=false \
--global-property modelTests=false \
--inline-schema-name-mappings PaymentRequest_paymentMethod=CheckoutPaymentMethod \
--inline-schema-name-mappings DonationPaymentRequest_paymentMethod=DonationPaymentMethod \
--additional-properties=dateLibrary=java8 \
--additional-properties=openApiNullable=false \
--additional-properties=resourceClass=$(resourceClass)Resource
mv $(output)/$(models)/$@ $(models)/$@
mv $(output)/$(models)/JSON.java $(models)/$@
# Full service + models automation
bigServices:=balanceplatform checkout payout management legalentitymanagement transfers
singleFileServices:=balancecontrol binlookup dataprotection storedvalue posterminalmanagement recurring payment disputes
services: $(bigServices) $(singleFileServices)
$(bigServices): target/spec $(openapi-generator-jar)
rm -rf $(models)/$@ $(output)
rm -rf src/main/java/com/adyen/service/$@ $(output)
$(openapi-generator-cli) generate \
-i target/spec/json/$(spec).json \
-g $(generator) \
-t templates \
-o $(output) \
--reserved-words-mappings configuration=configuration \
--ignore-file-override ./.openapi-generator-ignore \
--skip-validate-spec \
--model-package $(subst /,.,com.adyen.model.$@) \
--library $(library) \
--api-package com.adyen.service.$@ \
--api-name-suffix Api \
--global-property modelDocs=false \
--global-property modelTests=false \
--inline-schema-name-mappings PaymentRequest_paymentMethod=CheckoutPaymentMethod \
--inline-schema-name-mappings DonationPaymentRequest_paymentMethod=DonationPaymentMethod \
--additional-properties=dateLibrary=java8 \
--additional-properties=openApiNullable=false
mv $(output)/$(models)/$@ $(models)/$@
mv $(output)/src/main/java/com/adyen/service/JSON.java $(models)/$@
mv $(output)/src/main/java/com/adyen/service/$@ src/main/java/com/adyen/service/$@
$(singleFileServices): target/spec $(openapi-generator-jar)
jq -e 'del(.paths[][].tags)' target/spec/json/$(spec).json > target/spec/json/$(spec).tmp
mv target/spec/json/$(spec).tmp target/spec/json/$(spec).json
rm -rf $(models)/$@ $(output)
rm -rf src/main/java/com/adyen/service/$@ $(output)
$(openapi-generator-cli) generate \
-i target/spec/json/$(spec).json \
-g $(generator) \
-c templates/libraries/jersey3/config.yaml \
-o $(output) \
--reserved-words-mappings configuration=configuration \
--ignore-file-override ./.openapi-generator-ignore \
--skip-validate-spec \
--model-package $(subst /,.,com.adyen.model.$@) \
--library $(library) \
--additional-properties customApi=$@ \
--api-package com.adyen.service \
--api-name-suffix Api \
--global-property modelDocs=false \
--global-property modelTests=false \
--inline-schema-name-mappings PaymentRequest_paymentMethod=CheckoutPaymentMethod \
--inline-schema-name-mappings DonationPaymentRequest_paymentMethod=DonationPaymentMethod \
--additional-properties=dateLibrary=java8 \
--additional-properties=openApiNullable=false \
--additional-properties=smallServiceName=$(smallServiceName)
mv $(output)/$(models)/$@ $(models)/$@
mv $(output)/src/main/java/com/adyen/JSON.java $(models)/$@
mv $(output)/src/main/java/com/adyen/service/*Single.java src/main/java/com/adyen/service/$(smallServiceName).java
# Checkout spec (and patch version)
target/spec:
git clone https://github.com/Adyen/adyen-openapi.git target/spec
perl -i -pe's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' target/spec/json/*.json
# Extract templates (copy them for modifications)
templates: $(openapi-generator-jar)
$(openapi-generator-cli) author template -g $(generator) --library $(library) -o target/templates
# Download the generator
$(openapi-generator-jar):
wget --quiet -o /dev/null $(openapi-generator-url) -O $(openapi-generator-jar)
# Discard generated artifacts and changed models
clean:
rm -rf $(output)
git checkout $(models)
git clean -f -d $(models)
## Releases
version:
perl -lne 'print "currentVersion=$$1" if /version>(.+?)<\/version/' < pom.xml | head -1 >> "$$GITHUB_OUTPUT"
version_files:=pom.xml src/main/java/com/adyen/Client.java README.md
bump:
perl -i -pe 's/$$ENV{"CURRENT_VERSION"}/$$ENV{"NEXT_VERSION"}/' $(version_files)
.PHONY: templates models $(services) version bump