Sync project metadata with pyproject.toml
Updated scripts and backend to dynamically retrieve project name and version from `pyproject.toml`. This ensures consistent metadata across the OpenAPI client generation and the FastAPI application.
This commit is contained in:
parent
a3d23fbd1a
commit
e5ccbf6ef1
@ -4,13 +4,19 @@
|
|||||||
PYPROJECT_FILE="$(dirname "$0")/pyproject.toml"
|
PYPROJECT_FILE="$(dirname "$0")/pyproject.toml"
|
||||||
|
|
||||||
VERSION=$(grep -Po '(?<=version = ")[^"]*' "$PYPROJECT_FILE")
|
VERSION=$(grep -Po '(?<=version = ")[^"]*' "$PYPROJECT_FILE")
|
||||||
NAME=$(grep -Po '(?<=name = ")[^"]*' "$PYPROJECT_FILE")
|
NAME=$(grep -Po '(?<=name = ")[^"]*' "$PYPROJECT_FILE" | tr -d '\n')
|
||||||
|
|
||||||
if [[ -z "$VERSION" || -z "$NAME" ]]; then
|
if [[ -z "$VERSION" || -z "$NAME" ]]; then
|
||||||
echo "Error: Could not determine version or name from pyproject.toml"
|
echo "Error: Could not determine version or name from pyproject.toml"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Ensure NAME is valid (no spaces or newlines)
|
||||||
|
if ! [[ "$NAME" =~ ^[a-zA-Z0-9_-]+$ ]]; then
|
||||||
|
echo "Error: Invalid project name detected: '$NAME'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Using project name: $NAME"
|
echo "Using project name: $NAME"
|
||||||
echo "Using version: $VERSION"
|
echo "Using version: $VERSION"
|
||||||
|
|
||||||
@ -35,7 +41,8 @@ java -jar openapi-generator-cli.jar generate \
|
|||||||
-i "$(pwd)/openapi.json" \
|
-i "$(pwd)/openapi.json" \
|
||||||
-o python-client/ \
|
-o python-client/ \
|
||||||
-g python \
|
-g python \
|
||||||
--additional-properties=packageName="${NAME}client",projectName="${NAME}",packageVersion="${VERSION}"
|
--additional-properties=packageName="${NAME}client",projectName="${NAME}",packageVersion="${VERSION}" \
|
||||||
|
--additional-properties=authorName="Guillaume Gotthard",authorEmail="guillaume.gotthard@psi.ch"
|
||||||
|
|
||||||
# Check if the generator succeeded
|
# Check if the generator succeeded
|
||||||
if [[ ! -d python-client ]]; then
|
if [[ ! -d python-client ]]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user