diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c20fdef6..c1b015d9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,6 +24,11 @@ jobs: with: node-version: "22" + - name: "Create OpenAPI Spec" + run: | + pip install -r backend_py/requirements.txt + python3 -m backend_py.scripts.export_openapi + - name: "Build Project" run: | ./create_release.sh @@ -32,7 +37,9 @@ jobs: if: startsWith(github.ref, 'refs/tags/') uses: softprops/action-gh-release@v2 with: - files: release.tar.gz + files: | + release.tar.gz + openapi.json generate_release_notes: true draft: true prerelease: false diff --git a/.gitignore b/.gitignore index b5daef25..3aadeef6 100644 --- a/.gitignore +++ b/.gitignore @@ -312,17 +312,7 @@ poetry.toml # LSP config files pyrightconfig.json -### VirtualEnv ### -# Virtualenv -# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ -[Bb]in -[Ii]nclude -[Ll]ib -[Ll]ib64 -[Ll]ocal -[Ss]cripts -pyvenv.cfg -pip-selfcheck.json +# Removed venv ignores # End of https://www.toptal.com/developers/gitignore/api/python,virtualenv,data,pycharm,powershell @@ -336,3 +326,5 @@ pi-gen /recordings/ !frontend/src/lib/ + +openapi.json diff --git a/backend_py/requirements.txt b/backend_py/requirements.txt index 1cf8a826..5cec6d30 100644 --- a/backend_py/requirements.txt +++ b/backend_py/requirements.txt @@ -1,15 +1,11 @@ -#gevent==22.10.2 linuxpy==0.13.0 natsort==8.4.0 PyEventEmitter==1.0.5 -rpi_hardware_pwm==0.2.2 fastapi pydantic python-socketio -dbus-python==1.2.18 uvicorn sdbus==0.14.0 sdbus-networkmanager==2.0.0 -rtp==0.0.4 pyserial colorlog==6.10.1 diff --git a/backend_py/run.py b/backend_py/run.py index 5a6f97c0..e4fa59d1 100644 --- a/backend_py/run.py +++ b/backend_py/run.py @@ -33,12 +33,12 @@ async def lifespan(app: FastAPI): # noqa: ANN201 # FastAPI application -app = FastAPI( +fastapi_app = FastAPI( lifespan=lifespan, title="DWE OS API", description="API for DWE OS", version="0.1.0" ) # CORS -app.add_middleware( +fastapi_app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=False, @@ -51,7 +51,7 @@ async def lifespan(app: FastAPI): # noqa: ANN201 server = Server( FeatureSupport(ttyd=True, wifi=True, serial=True), sio, - app, + fastapi_app, data_dir=".", settings_path=".", log_level=logging.DEBUG, @@ -59,7 +59,7 @@ async def lifespan(app: FastAPI): # noqa: ANN201 ) # Combine FastAPI and Socket.IO ASGI apps -app = socketio.ASGIApp(sio, other_asgi_app=app) +app = socketio.ASGIApp(sio, other_asgi_app=fastapi_app) # Run with Uvicorn if __name__ == "__main__": diff --git a/backend_py/scripts/export_openapi.py b/backend_py/scripts/export_openapi.py new file mode 100644 index 00000000..a556562a --- /dev/null +++ b/backend_py/scripts/export_openapi.py @@ -0,0 +1,6 @@ +import json + +from backend_py.run import fastapi_app + +with open("openapi.json", "w") as f: + json.dump(fastapi_app.openapi(), f, indent=2) diff --git a/install_requirements.sh b/install_requirements.sh index 697094e9..39fd3d12 100755 --- a/install_requirements.sh +++ b/install_requirements.sh @@ -29,7 +29,7 @@ install_ttyd() { local version="1.6.3" local filename="ttyd.x86_64" - + # set filename based on architecture case $arch in x86_64) @@ -44,7 +44,7 @@ install_ttyd() { esac echo "Downloading ttyd version ${version} for ${arch}..." - + # create temporary directory local temp_dir=$(mktemp -d) cd "$temp_dir" @@ -71,7 +71,7 @@ install_ttyd() { rm -rf "$temp_dir" echo "Successfully installed ttyd version ${version}" - + # verify installation if command -v ttyd >/dev/null 2>&1; then echo "ttyd is now available at: $(which ttyd)" @@ -88,8 +88,6 @@ sudo apt-get update -y # Install python and gstreamer dependencies echo "Installing Python dependencies..." sudo apt-get install python3 python3-venv -y -# For dbus-python -sudo apt-get install build-essential libdbus-glib-1-dev libdbus-1-dev libpython3-dev -y echo "Installing GStreamer dependencies..." sudo apt-get install -y libglib2.0-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-plugins-ugly libimage-exiftool-perl @@ -106,4 +104,4 @@ else echo "ttyd installed from repositories" fi -echo "Requirements installed." \ No newline at end of file +echo "Requirements installed."