From 8e1d5d9936ee5830e1c38b0abfbf73382923b6d8 Mon Sep 17 00:00:00 2001 From: Andrea Waltlova Date: Thu, 31 Oct 2024 12:34:24 +0100 Subject: [PATCH] Split endpoints to two folders and return mock data Signed-off-by: Andrea Waltlova --- app/main.py | 17 +++++++++++++---- app/v1/{ => released}/__init__.py | 0 app/v1/{ => released}/endpoints.py | 0 app/v1/upcoming/__init__.py | 0 app/v1/upcoming/endpoints.py | 16 ++++++++++++++++ 5 files changed, 29 insertions(+), 4 deletions(-) rename app/v1/{ => released}/__init__.py (100%) rename app/v1/{ => released}/endpoints.py (100%) create mode 100644 app/v1/upcoming/__init__.py create mode 100644 app/v1/upcoming/endpoints.py diff --git a/app/main.py b/app/main.py index d583796..92fc92d 100644 --- a/app/main.py +++ b/app/main.py @@ -1,9 +1,18 @@ -from fastapi import FastAPI +from fastapi import APIRouter, FastAPI -from app.v1.endpoints import v1_router +from app.v1.released.endpoints import v1_router as released_v1_router +from app.v1.upcoming.endpoints import v1_router as upcoming_v1_router # Initialize FastAPI app app = FastAPI() -# Include the routers under versioned paths -app.include_router(v1_router, prefix="/v1") +# Create a main API router with the /api prefix +api_router = APIRouter() + +# Include individual service routers under the main API router +api_router.include_router(released_v1_router, prefix="/v1/released", tags=["released"]) +api_router.include_router(upcoming_v1_router, prefix="/v1/upcoming", tags=["upcoming"]) + +# Include the main API router in the FastAPI app with the prefix +app.include_router(api_router, prefix="/api") + diff --git a/app/v1/__init__.py b/app/v1/released/__init__.py similarity index 100% rename from app/v1/__init__.py rename to app/v1/released/__init__.py diff --git a/app/v1/endpoints.py b/app/v1/released/endpoints.py similarity index 100% rename from app/v1/endpoints.py rename to app/v1/released/endpoints.py diff --git a/app/v1/upcoming/__init__.py b/app/v1/upcoming/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/v1/upcoming/endpoints.py b/app/v1/upcoming/endpoints.py new file mode 100644 index 0000000..a08ac7e --- /dev/null +++ b/app/v1/upcoming/endpoints.py @@ -0,0 +1,16 @@ +from fastapi import APIRouter + +v1_router = APIRouter() + +@v1_router.get("/get-future-data") +async def get_relevant(): + # TODO: This is a dummy function that returns a list of changes that are planned for the future. + # In a real application, this data would be fetched from a database or some other source. + return { + "changes": [ + {"type": "feature", "description": "New feature 1", "release": "9.0"}, + {"type": "retirement", "description": "Retiring feature 2", "release": "10.0"}, + {"type": "bugfix", "description": "Fixing bug 3", "release": "8.6"}, + {"type": "deprecation", "description": "Deprecating feature 4", "release": "9.0"}, + ] + }