-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (65 loc) · 2.6 KB
/
openapi-generate.yaml
File metadata and controls
71 lines (65 loc) · 2.6 KB
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
on:
workflow_dispatch:
inputs:
api_spec_repo:
description: "API spec repository"
required: true
api_spec_path:
description: "The path to the api spec"
required: true
output_repo:
description: "The output repository"
required: true
output_model_path:
description: "The path of the models folder"
required: true
namespace_root_name:
description: "The C# namespace up to the models folder"
required: true
namespace_models_name:
description: "The remaining part of the C# namespace including the models folder"
required: true
secrets:
iw_github_container_token:
description: "A token with read/write permissions for the output repository"
required: true
jobs:
generate-models:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout Repo"
uses: "actions/checkout@v4"
with:
repository: "${{ github.event.inputs.api_spec_repo }}"
path: "./spec"
token: "${{ secrets.iw_github_container_token }}"
- name: "Checkout Repo"
uses: "actions/checkout@v4"
with:
repository: "${{ github.event.inputs.output_repo }}"
path: "./app"
token: "${{ secrets.iw_github_container_token }}"
- name: "Setup JDK 11"
uses: "actions/setup-java@v4"
with:
distribution: "temurin"
java-version: "11"
- name: "Generate .NET Model Classes"
run: |
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.6.0/openapi-generator-cli-7.6.0.jar -O openapi-generator-cli.jar
java -jar ./openapi-generator-cli.jar generate \
-i ./spec/${{ github.event.inputs.api_spec_path }} \
-g csharp \
-o ./out \
-p packageName=${{ github.event.inputs.namespace_root_name }} \
-p modelPackage=${{ github.event.inputs.namespace_models_name }} \
--global-property models
mkdir -p ./app/${{ github.event.inputs.output_model_path }}/
cp ./out/src/${{ github.event.inputs.namespace_root_name }}/${{ github.event.inputs.namespace_models_name }}/* ./app/${{ github.event.inputs.output_model_path }}/
cd ./app
git pull
git config --global user.name 'GitHub Action'
git config --global user.email 'action@github.com'
git add .
git commit -m "Generate and add models."
git push