Skip to content

Commit

Permalink
[PW-7307] Gh pipeline and Makefile to generate Models (#668)
Browse files Browse the repository at this point in the history
* Added async support for local terminal API

* removed th tls1.2 configuration

* Added retrieve3ds2result endpoints + UT

* Added cardDetails Endpoint in checkout

* UT for carddetails endpoint

* fix integration test

* FiXIntEgrAtiOntEsT

* Revert "Added async support for local terminal API"

This reverts commit 21bd6d0.

* Revert "removed th tls1.2 configuration"

This reverts commit c45131f.

* create openapi templates for dotnet

* added Makefile

* trying out git makemodels

* add workflow

* add push

* 123456432

* merged templates in this branch && changed template to include DateConverter

* small change

* revert Checkout models

* Revert "FiXIntEgrAtiOntEsT"

This reverts commit dc5ad0a.

* Revert "fix integration test"

This reverts commit 72f7710.

* Revert "UT for carddetails endpoint"

This reverts commit abf0856.

* Revert "Added cardDetails Endpoint in checkout"

This reverts commit 0ac0211.

* Revert "Added retrieve3ds2result endpoints + UT"

This reverts commit 9c0156a.

* changed makefile

* small fix

* final commit

* remove last constructer param validation and headers fix

* cleanup

* change templates back to original

* changed Makefile to use jar instead of docker

* Update Makefile

Co-authored-by: Michael Paul <michael@michaelpaul.com.br>

* small fix

Co-authored-by: wouterboe <wouter.boereboom@adyen.com>
Co-authored-by: Michael Paul <michael@michaelpaul.com.br>
  • Loading branch information
3 people authored Dec 29, 2022
1 parent efb3e34 commit b0b432a
Show file tree
Hide file tree
Showing 26 changed files with 158 additions and 22 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: .NET Library Models

on: [ workflow_dispatch ]

jobs:
generate:
runs-on: ubuntu-latest
name: Generate Models
steps:
- uses: actions/checkout@v3
- run: make models
- name: Set PR variables
id: vars
run: |
cd build/spec
echo ::set-output name=pr_title::"Update models"
echo ::set-output name=pr_body::"OpenAPI spec or templates produced new models on $(date +%d-%m-%Y) \
by [commit](https://github.com/Adyen/adyen-openapi/commit/$(git rev-parse HEAD))."
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
committer: ${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}
author: ${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}
base: develop
branch: automation/models
body: ${{ steps.vars.outputs.pr_body }}
add-paths: |
Adyen/Model
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ TestResults/
.vagrant/
.idea/
*.user
target/
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/Action/IPaymentResponseAction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region License
#region License
/*
* ######
* ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/CreateCheckoutSessionRequest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence

//
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/CreateCheckoutSessionResponse.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence

//
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/DefaultPaymentMethodDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region License
#region License
// /*
// * ######
// * ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/Details/AndroidPayDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence
//
// ######
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/Details/BacsDirectDebitDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence
//
// ######
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/Details/CellulantDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence
//
// ######
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/Details/IPaymentMethodDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region License
#region License
/*
* ######
* ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/Details/KlarnaDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence
//
// ######
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/Details/MasterpassDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence
//
// ######
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/Details/MobilePayDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence
//
// ######
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/Details/PayPalDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence
//
// ######
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/Details/PayUUpiDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence
//
// ######
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/Details/UpiDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence
//
// ######
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/Details/WeChatPayDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence
//
// ######
// ######
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence
//
// ######
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/FraudCheckResult.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region License
#region License
// /*
// * ######
// * ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/FraudCheckResultContainer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region License
#region License
/*
* ######
* ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/Mandate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence

//
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/PaymentDetailsResponse.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence

//
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/PaymentMethodIssuer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence

//
// ######
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/PersonalDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region License
#region License
//
// ######
// ######
Expand Down
68 changes: 68 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
openapi-generator-version:=6.2.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:=csharp
services:=
models:=Adyen/Model
output:=target/out

# Generate models (for each service)
models: $(services)

Binlookup: spec=BinLookupService-v52
Checkout: spec=CheckoutService-v69
StoredValue: spec=StoredValueService-v46
TerminalManagement: spec=TfmAPIService-v1
Payments: spec=PaymentService-v68
Recurring: spec=RecurringService-v68
Payouts: spec=PayoutService-v68
Management: spec=ManagementService-v1
LegalEntityManagement: spec=LegalEntityService-v2
BalancePlatform: spec=BalancePlatformService-v2
PlatformsAccount: spec=AccountService-v6
PlatformsFund: spec=FundService-v6
PlatformsNotificationConfiguration: spec=NotificationConfigurationService-v6
PlatformsHostedOnboardingPage: spec=HopService-v6
Transfer: spec=TransferService-v3

$(services): target/spec $(openapi-generator-jar)
rm -rf $(models)/$@ $(output)
$(openapi-generator-cli) generate \
-i target/spec/json/$(spec).json \
-g $(generator) \
-t templates/csharp \
-o $(output) \
--model-package $@ \
--reserved-words-mappings Version=Version \
--global-property modelDocs=false \
--global-property modelTests=false \
--global-property models,supportingFiles \
--additional-properties packageName=Adyen.Model
mkdir Adyen/Model/$@
mv target/out/src/Adyen.Model/$@/* Adyen/Model/$@
#adjust this build/src to another file when creating templates

# 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) -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)


.PHONY: templates models $(services)
38 changes: 38 additions & 0 deletions templates/csharp/model.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{>partial_header}}
using System;
using System.Linq;
using System.IO;
using System.Text;
{{^netStandard}}
using System.Text.RegularExpressions;
{{/netStandard}}
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
{{#models}}
{{#model}}
{{#discriminator}}
using JsonSubTypes;
{{/discriminator}}
{{/model}}
{{/models}}
{{^netStandard}}
{{#generatePropertyChanged}}
using PropertyChanged;
using System.ComponentModel;
{{/generatePropertyChanged}}
using System.ComponentModel.DataAnnotations;
{{/netStandard}}
using OpenAPIDateConverter = {{packageName}}.Client.OpenAPIDateConverter;

namespace {{packageName}}.{{modelPackage}}
{
{{#models}}
{{#model}}
{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}}
{{/model}}
{{/models}}
}

0 comments on commit b0b432a

Please sign in to comment.