Skip to content

Commit 1513bb9

Browse files
Feature/codegen automation (#57)
2 parents 9009f67 + cc54fee commit 1513bb9

75 files changed

Lines changed: 151 additions & 81 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This workflow should generate code based on the openapi.yaml and commit it to the branch.
2+
name: Update API Spec
3+
4+
# This workflow is triggered only when called by another workflow
5+
on:
6+
workflow_dispatch:
7+
push:
8+
paths:
9+
- 'api/openapi.yaml'
10+
11+
jobs:
12+
13+
generate:
14+
name: Generate code from OpenAPI spec
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Make Scripts Executable
23+
run: |
24+
chmod +x api/scripts/gen_docs.sh
25+
chmod +x api/scripts/gen_spring.sh
26+
chmod +x api/scripts/gen_typescript.sh
27+
chmod +x api/scripts/install_tools.sh
28+
chmod +x api/scripts/lint.sh
29+
30+
- name: Install Tools
31+
run: ./api/scripts/install_tools.sh
32+
shell: bash
33+
34+
- name: Lint
35+
run: ./api/scripts/lint.sh
36+
shell: bash
37+
38+
- name: Generate Docs
39+
run: ./api/scripts/gen_docs.sh
40+
shell: bash
41+
42+
- name: Generate Spring Code
43+
run: ./api/scripts/gen_spring.sh
44+
shell: bash
45+
46+
- name: Generate api.ts
47+
run: ./api/scripts/gen_typescript.sh
48+
shell: bash
49+
50+
- name: Setup Git
51+
run: |
52+
git config user.name "github-actions[bot]"
53+
git config user.email "github-actions[bot]@users.noreply.github.com"
54+
55+
- name: Stage Generated Code
56+
run: |
57+
git add server/matching/generated
58+
git add server/user/generated
59+
git add server/gateway/generated
60+
git add client/src/api.ts
61+
git add docs/api.html
62+
63+
- name: Commit & Push Generated Code
64+
run: |
65+
git commit -m "gen: generate code and documentation based on latest version of openapi.yaml"
66+
git push

api/scripts/gen_docs.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@
66
# fail if any single command fails
77
set -euo pipefail
88

9-
# lint openapi spec
10-
redocly lint api/openapi.yaml
11-
129
# generate documentation
1310
redocly build-docs api/openapi.yaml -o docs/api.html

api/scripts/gen_spring.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,9 @@
99
# - other:
1010
# - gradle
1111

12-
# echo linting
13-
echo "Linting api/openapi.yaml..."
14-
1512
# fail command if any part fails
1613
set -euo pipefail
1714

18-
# lint openapi spec
19-
redocly lint api/openapi.yaml
20-
2115
for path in matching user gateway; do
2216

2317
# echo generating code

api/scripts/gen_typescript.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
# - openapi-typescript
88
# - typescript
99

10-
# fail command if any part fails
11-
set -euo pipefail
12-
13-
# echo linting
14-
echo "Linting api/openapi.yaml..."
15-
1610
# lint openapi spec
1711
redocly lint api/openapi.yaml
1812

api/scripts/install_tools.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# fail command if any part fails
4+
set -euo pipefail
5+
6+
# install with npm
7+
npm install \
8+
@openapitools/openapi-generator-cli \
9+
@redocly/cli \
10+
openapi-typescript \
11+
typescript \
12+
-g

api/scripts/lint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# fail command if any part fails
4+
set -euo pipefail
5+
6+
# echo linting
7+
echo "Linting api/openapi.yaml..."
8+
9+
# lint openapi spec
10+
redocly lint api/openapi.yaml

server/gateway/generated/.openapi-generator/FILES

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.openapi-generator-ignore
21
README.md
32
pom.xml
43
src/main/java/org/openapitools/api/ApiUtil.java

server/gateway/generated/gradlew

100644100755
File mode changed.

server/gateway/generated/src/main/java/org/openapitools/api/GenAiApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import java.util.Optional;
3636
import javax.annotation.Generated;
3737

38-
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2025-06-27T17:54:11.100148917+02:00[Europe/Berlin]", comments = "Generator version: 7.14.0")
38+
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2025-06-27T17:32:34.144272061Z[Etc/UTC]", comments = "Generator version: 7.14.0")
3939
@Validated
4040
@Tag(name = "GenAI", description = "Paths belonging to the GenAI microservice")
4141
public interface GenAiApi {

server/gateway/generated/src/main/java/org/openapitools/api/MatchingApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import java.util.Optional;
4040
import javax.annotation.Generated;
4141

42-
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2025-06-27T17:54:11.100148917+02:00[Europe/Berlin]", comments = "Generator version: 7.14.0")
42+
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2025-06-27T17:32:34.144272061Z[Etc/UTC]", comments = "Generator version: 7.14.0")
4343
@Validated
4444
@Tag(name = "Matching", description = "Paths belonging to the Matching microservice")
4545
public interface MatchingApi {

0 commit comments

Comments
 (0)