generating openapi from backend and adding ci pipeline

This commit is contained in:
GotthardG
2024-12-13 10:45:04 +01:00
parent 530c9efae0
commit 20f341a9a9
4 changed files with 93 additions and 27 deletions

23
make_openapi_client.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
VERSION={0.1.0}
# Run whataver you need to generate FastAPI .json file
pushd backend
python -m main generate-openapi
popd
# Download OpenAPI generator
OPENAPI_VERSION=7.8.0
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${OPENAPI_VERSION}/openapi-generator-cli-${OPENAPI_VERSION}.jar -O openapi-generator-cli.jar
# Run OpenAPI generator (requires java to be installed - this is already configured on mx-aare-test)
java -jar openapi-generator-cli.jar generate -i /backend/openapi.json -o python-client/ -g python --additional-properties=packageName=aare-test,packageVersion=${VERSION}
# build python package
cd python-client
python3.11 -m venv .venv
source .venv/bin/activate
pip install twine build
python -m build
# upload the package into the package repository - this uses variables from CI pipeline, so it won't work offline
twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*