Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Java API Client for Intelligence Service's OpenAPI Specifications #106

Merged
merged 64 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
7cc84b9
Add GitHub Action workflow
milesha Sep 26, 2024
3604d0f
Merge branch 'develop' into feature/generate-java-client
milesha Sep 30, 2024
96ec9b1
Add generate-java-client
milesha Sep 30, 2024
c0e1119
Store the OpenAPI specifications
milesha Sep 30, 2024
5deb2b0
Fix of FastAPI start
milesha Sep 30, 2024
754c24d
Update devDependencies
milesha Sep 30, 2024
237b891
Update
milesha Sep 30, 2024
a1050a9
Add OpenAPI specification storage
milesha Sep 30, 2024
9e3484c
Delete unnecassary code
milesha Sep 30, 2024
87aae81
Update Git WorkFlow
milesha Sep 30, 2024
9d573cb
Update with right config
milesha Oct 1, 2024
93fb222
Add Java Client
milesha Oct 1, 2024
bc719d1
Upgrade to com.squareup.okio:okio-jvm:3.4.0
milesha Oct 1, 2024
c4f2b44
Add support of the .env file
milesha Oct 1, 2024
4e8098c
Update check-api-client.yml
milesha Oct 1, 2024
27ef5d2
Change the openapi version
milesha Oct 1, 2024
59702a7
Add model configuration for .env
milesha Oct 1, 2024
c2709a6
Change titile
milesha Oct 1, 2024
b862557
Update dependencies
milesha Oct 1, 2024
62ace3f
Delete unused code
milesha Oct 1, 2024
baa1660
Re-name generate function
milesha Oct 1, 2024
955cbeb
Update model config
milesha Oct 1, 2024
987e08e
Format
milesha Oct 1, 2024
cf72601
Change .env usage
milesha Oct 1, 2024
e24285c
Add specification generation
milesha Oct 2, 2024
f496e69
Delete comma crushing the build
milesha Oct 2, 2024
6828d36
Add allow_unicode
milesha Oct 2, 2024
ca11127
Merge branch 'develop' into feature/generate-java-client
milesha Oct 2, 2024
62b7f2d
Delete Java client from the wrong directory
milesha Oct 13, 2024
b2a9513
Add java client gen as a plugin
milesha Oct 14, 2024
be9df1c
Add shx
milesha Oct 23, 2024
edfae58
Add tmp for java client generation
milesha Oct 23, 2024
b181b79
Delete open-api get plugin
milesha Oct 23, 2024
2a92119
Restructure file
milesha Oct 23, 2024
ad55776
Delete unused code
milesha Oct 23, 2024
40b566e
Add generated docs
milesha Oct 25, 2024
4693f32
Fix maven app start error
milesha Oct 25, 2024
e86e211
Merge branch 'develop' into feature/generate-java-client
milesha Oct 25, 2024
475cd01
Add generate all
milesha Oct 25, 2024
ebf90c2
Merge develop
milesha Oct 29, 2024
ddd12be
Restructure and fix bugs
milesha Oct 29, 2024
0a3c1c4
Add new GitHub workflow
milesha Oct 29, 2024
14fba4a
Update generated docs
milesha Oct 29, 2024
98cc49b
Merge branch 'develop' into feature/generate-java-client
milesha Oct 29, 2024
591d1c9
Add Webconfig
milesha Oct 29, 2024
52cbb08
Update naming
milesha Oct 29, 2024
a958122
Fix poetry
milesha Oct 29, 2024
08f2d20
Fix poetry
milesha Oct 29, 2024
a75d1ba
Fix poetry for github workflows
milesha Oct 29, 2024
42e4344
Fix poetry for github workflows
milesha Oct 29, 2024
16c5420
Fix poetry for github workflows
milesha Oct 29, 2024
96e8687
Fix poetry for github workflows
milesha Oct 29, 2024
bde758f
Fix poetry for github workflows
milesha Oct 29, 2024
af5ae94
Fix poetry for github workflows
milesha Oct 29, 2024
e2e9097
Fix MockChatModel bug
milesha Oct 29, 2024
4b4cfe0
Delete autocommit from the workflow
milesha Oct 29, 2024
2efdc4c
update client
FelixTJDietrich Nov 4, 2024
5592ccf
Merge branch 'develop' into feature/generate-java-client
FelixTJDietrich Nov 4, 2024
547798e
format pom
FelixTJDietrich Nov 4, 2024
17cbc72
Merge branch 'feature/generate-java-client' of github.com:ls1intum/He…
FelixTJDietrich Nov 4, 2024
584c179
update workflow
FelixTJDietrich Nov 4, 2024
90c43c6
update workflows
FelixTJDietrich Nov 4, 2024
852369c
update comment
FelixTJDietrich Nov 4, 2024
ea17bea
chore: update API specs and client
github-actions[bot] Nov 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types: [opened, synchronize, labeled, reopened]
paths:
- 'server/application-server/**'
- '.github/workflows/generate-api-client.yml'
- '.github/workflows/generate-application-server-client.yml'
push:
paths:
- 'server/application-server/openapi.yaml'
Expand All @@ -15,7 +15,7 @@ on:

jobs:
generate-api-client:
name: Verify API Specs and Client (add autocommit-openapi label to PR to auto-commit changes)
name: Verify API Specs and Client of the Application Server (add autocommit-openapi label to PR to auto-commit changes)
runs-on: ubuntu-latest

steps:
Expand All @@ -40,8 +40,8 @@ jobs:
- name: Install dependencies
run: npm install

- name: Generate API client
run: npm run generate:api
- name: Generate API client for the application server
run: npm run generate:api:application-server

- name: Check for changes in the API
id: check_changes
Expand Down
100 changes: 100 additions & 0 deletions .github/workflows/generate-intelligence-service-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: OpenAPI

on:
pull_request:
types: [opened, synchronize, labeled, reopened]
paths:
- 'server/application-server/**'
- '.github/workflows/generate-intelligence-service-client.yml'
push:
paths:
- 'server/intelligence-service/openapi.yaml'
- 'server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice/**'
branches: [develop]
workflow_dispatch:

jobs:
generate-api-client:
name: Verify API Specs and Client of the Intelligence Service (add autocommit-openapi label to PR to auto-commit changes)
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
persist-credentials: false
fetch-depth: 0

- name: Set up Python 3.12
uses: actions/setup-python@v2
with:
python-version: 3.12

- name: Install dependencies
run: npm install

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
virtualenvs-path: .venv
installer-parallel: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Python dependencies
working-directory: server/intelligence-service
run: poetry install --no-interaction --no-root

- name: Generate API client for the application server
working-directory: server/intelligence-service
run: poetry run npm run generate:api:intelligence-service

- name: Check for changes in the API
id: check_changes
run: |
echo "Checking for changes in the API client directory..."
git add .
if git diff --cached --quiet; then
echo "No changes detected in the API client directory."
echo "NO_CHANGES_DETECTED=true" >> $GITHUB_ENV
else
echo "Changes detected in the API client directory."
echo "NO_CHANGES_DETECTED=false" >> $GITHUB_ENV
exit 1
fi

- name: Commit files
if: ${{ always() && contains(github.event.pull_request.labels.*.name, 'autocommit-openapi') }}
run: |
echo "Committing and pushing changes..."
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git commit -a -m "chore: update API specs and client"

- name: Push changes
if: ${{ always() && contains(github.event.pull_request.labels.*.name, 'autocommit-openapi') }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_PAT }}
branch: ${{ github.event.pull_request.head.ref }}

- name: Remove autocommit-openapi label
if: ${{ always() && contains(github.event.pull_request.labels.*.name, 'autocommit-openapi') }}
run: |
echo "Removing the autocommit-openapi label..."
curl --silent --fail-with-body -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/autocommit-openapi
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,7 @@ node_modules/

application-local.yml

server/application-server/postgres-data/
server/application-server/postgres-data/

# Java-Client creation temporary
tmp
153 changes: 149 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@
"webapp/*"
],
"scripts": {
"generate:api:clean": "rimraf webapp/src/app/core/modules/openapi",
"generate:api:application-server:clean": "rimraf webapp/src/app/core/modules/openapi",
"generate:api:intelligence-service:clean": "rimraf server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice",
"generate:api:clean": "npm run generate:api:intelligence-service:clean && npm run generate:api:application-server:clean",

"generate:api:application-server-specs": "cd server/application-server && mvn verify -DskipTests=true -Dapp.profiles=specs",
"generate:api:intelligence-service-specs": "python -m server.intelligence-service.app.generate_openapi_yaml",
"generate:api:specs": "npm run generate:api:application-server-specs && npm run generate:api:intelligence-service-specs",

"generate:api:application-server-client": "npx openapi-generator-cli generate -i server/application-server/openapi.yaml -g typescript-angular -o webapp/src/app/core/modules/openapi --additional-properties fileNaming=kebab-case,withInterfaces=true --generate-alias-as-model",
"generate:api": "npm run generate:api:application-server-specs && npm run generate:api:clean && npm run generate:api:application-server-client"
"generate:api:intelligence-service-client": "npx openapi-generator-cli generate -i server/intelligence-service/openapi.yaml -g java --library resttemplate --api-package de.tum.in.www1.hephaestus.intelligenceservice.api --model-package de.tum.in.www1.hephaestus.intelligenceservice.model --invoker-package de.tum.in.www1.hephaestus.intelligenceservice --additional-properties useJakartaEe=true,performBeanValidation=true,generateClientAsBean=true,hideGenerationTimestamp=true --package-name de.tum.in.www1.hephaestus.intelligenceservice -o tmp/java-client && shx cp -r tmp/java-client/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice server/application-server/src/main/java/de/tum/in/www1/hephaestus && rimraf tmp",
"generate:api:clients": "npm run generate:api:intelligence-service-client && npm run generate:api:application-server-client",

"generate:api:application-server": "npm run generate:api:application-server-specs && npm run generate:api:application-server:clean && npm run generate:api:application-server-client",
"generate:api:intelligence-service": "npm run generate:api:intelligence-service:clean && npm run generate:api:intelligence-service-specs && npm run generate:api:intelligence-service-client",
"generate:api": "npm run generate:api:intelligence-service && npm run generate:api:application-server"
},
"devDependencies": {
"@openapitools/openapi-generator-cli": "2.13.5",
"rimraf": "6.0.1"
"rimraf": "6.0.1",
"shx": "0.3.4"
}
}
Loading
Loading