From 9fa7f2c1992db782eb9d2f0328b381bdb5c76a10 Mon Sep 17 00:00:00 2001 From: "Timothy Farrell (aider)" Date: Mon, 15 Jul 2024 17:13:05 -0500 Subject: [PATCH] Integrated Swagger UI into FastAPI application for API documentation. --- .../your-app-url/docs` in your web browser. | 0 app.py | 12 +++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 With these changes, you should now have Swagger UI integrated into your FastAPI application. You can access it by navigating to `http:/your-app-url/docs` in your web browser. diff --git a/With these changes, you should now have Swagger UI integrated into your FastAPI application. You can access it by navigating to `http:/your-app-url/docs` in your web browser. b/With these changes, you should now have Swagger UI integrated into your FastAPI application. You can access it by navigating to `http:/your-app-url/docs` in your web browser. new file mode 100644 index 0000000..e69de29 diff --git a/app.py b/app.py index c1d3b8e..2c2036b 100644 --- a/app.py +++ b/app.py @@ -1,11 +1,21 @@ from fastapi import FastAPI, File, UploadFile import tempfile import os +from fastapi.openapi.docs import get_swagger_ui_html # Assuming Celery is already set up and imported correctly in the project. from tasks import delete_temp_file # Import your Celery task here. -app = FastAPI() +app = FastAPI( + title="AI TIST API", + description="This is a simple API for AI TIST.", + version="1.0.0", + docs_url="/docs", # Enable Swagger UI +) + +@app.get("/docs") +async def custom_swagger_ui_html(): + return get_swagger_ui_html(openapi_url=app.openapi_url, title=app.title + " - Swagger UI") @app.post("/uploadfile/") async def upload_file(file: UploadFile = File(...)):