diff --git a/.github/workflows/models.yml b/.github/workflows/models.yml index b47a972..c1ccdf7 100644 --- a/.github/workflows/models.yml +++ b/.github/workflows/models.yml @@ -7,14 +7,9 @@ jobs: runs-on: ubuntu-latest name: Generate Models steps: - - name: Checkout - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - name: Generate models run: make models - - name: Overwrite current models - run: | - rm -rf src/typings/checkout - cp -r build/model src/typings/checkout - name: Create Pull Request uses: peter-evans/create-pull-request@v4 with: @@ -26,4 +21,4 @@ jobs: title: Update models body: OpenAPI spec or templates produced new models. add-paths: | - src/typings/checkout + src/typings diff --git a/Makefile b/Makefile index 11f07e9..7ff09cc 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,38 @@ -generator=typescript-node -openapi-generator-cli=docker run --rm -v ${PWD}:/local -w /local openapitools/openapi-generator-cli:v5.4.0 +generator:=typescript-node +openapi-generator-cli:=docker run --user $(shell id -u):$(shell id -g) --rm -v ${PWD}:/local -w /local openapitools/openapi-generator-cli:v5.4.0 +services:=checkout storedValue terminalManagement payments recurring -clean: - rm -rf build +# Generate models (for each service) +models: $(services) -# Extract templates (copy them for modifications) -.PHONY: templates -templates: - $(openapi-generator-cli) author template -g ${generator} -o build/templates/typescript +checkout: spec=CheckoutService-v69 +storedValue: spec=StoredValueService-v46 +terminalManagement: spec=TfmAPIService-v1 +payments: spec=PaymentService-v68 +recurring: spec=RecurringService-v68 -build/spec: - mkdir -p build/spec - -# Fetch spec files (git clone/submodule?) -build/spec/CheckoutService-v69.json: build/spec - wget https://raw.githubusercontent.com/Adyen/adyen-openapi/main/json/CheckoutService-v69.json -O build/spec/CheckoutService-v69.json - sed -i 's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/CheckoutService-v69.json - -models: build/spec/CheckoutService-v69.json +$(services): build/spec + rm -rf src/typings/$@ build/model $(openapi-generator-cli) generate \ - -i build/spec/CheckoutService-v69.json \ - -g ${generator} \ + -i build/spec/json/$(spec).json \ + -g $(generator) \ -t templates/typescript \ -o build \ - --global-property models,supportingFiles \ No newline at end of file + --global-property models,supportingFiles + mv build/model src/typings/$@ + +# Checkout spec (and patch version) +build/spec: + git clone https://github.com/Adyen/adyen-openapi.git build/spec + sed -i 's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/json/*.json + +# Extract templates (copy them for modifications) +templates: + $(openapi-generator-cli) author template -g $(generator) -o build/templates/typescript + +# Discard generated artifacts and changed models +clean: + git checkout src/typings + git clean -f -d src/typings + +.PHONY: templates models $(services) \ No newline at end of file diff --git a/README.md b/README.md index 96a0d59..42192c7 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ This is the officially supported NodeJS library for using Adyen's APIs. The Library supports all APIs under the following services: * [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v69/overview): Our latest integration for accepting online payments. Current supported version: **v69** -* [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v64/overview): Our classic integration for online payments. Current supported version: **v64** -* [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v49/overview): Endpoints for managing saved payment details. Current supported version: **68** +* [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v68/overview): Our classic integration for online payments. Current supported version: **v68** +* [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v68/overview): Endpoints for managing saved payment details. Current supported version: **v68** * [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v64/overview): Endpoints for sending funds to your customers. Current supported version: **v64** * [Platforms APIs](https://docs.adyen.com/platforms/api): Set of APIs when using Adyen for Platforms. * [Account API](https://docs.adyen.com/api-explorer/#/Account/v6/overview) Current supported version: **v6**