From 736cd533ececa61c6207c17bd8b67f9141371c39 Mon Sep 17 00:00:00 2001 From: Sergey Vanyushkin Date: Mon, 19 Aug 2024 08:15:02 +0000 Subject: [PATCH] ADD init routers --- src/fastfood_two/app/routers.py | 18 ++++++++++++++++-- src/fastfood_two/routers/dish.py | 6 +++--- src/fastfood_two/routers/submenu.py | 6 +++--- src/fastfood_two/routers/summary.py | 8 ++++++++ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/fastfood_two/app/routers.py b/src/fastfood_two/app/routers.py index 9c6a693..33f94f3 100644 --- a/src/fastfood_two/app/routers.py +++ b/src/fastfood_two/app/routers.py @@ -1,6 +1,20 @@ -from fastapi import FastAPI +from fastapi import APIRouter, FastAPI + +from fastfood_two.routers.dish import router as dish_router +from fastfood_two.routers.menu import router as menu_router +from fastfood_two.routers.submenu import router as submenu_router +from fastfood_two.routers.summary import router as summary_router def init_routers(app: FastAPI) -> None: """Initialize FastAPI routers.""" - pass + base_router = APIRouter( + prefix="/api/v1", + ) + + base_router.include_router(menu_router) + base_router.include_router(submenu_router) + base_router.include_router(dish_router) + base_router.include_router(summary_router) + + app.include_router(base_router) diff --git a/src/fastfood_two/routers/dish.py b/src/fastfood_two/routers/dish.py index 5d06b09..2962313 100644 --- a/src/fastfood_two/routers/dish.py +++ b/src/fastfood_two/routers/dish.py @@ -1,8 +1,8 @@ from fastapi import APIRouter -router = APIRouter(prefix="/dish", tags=["Dish"]) +router = APIRouter(prefix="/{menu_id}/submenu/{submenu_id}/dish", tags=["Dish"]) @router.get("/") -async def get_dishes(): - return +async def get_dishes(menu_id, submenu_id): + return menu_id, submenu_id diff --git a/src/fastfood_two/routers/submenu.py b/src/fastfood_two/routers/submenu.py index 7d7814e..7b73261 100644 --- a/src/fastfood_two/routers/submenu.py +++ b/src/fastfood_two/routers/submenu.py @@ -1,8 +1,8 @@ from fastapi import APIRouter -router = APIRouter(prefix="/submenu", tags=["Dish"]) +router = APIRouter(prefix="/{menu_id}/submenu", tags=["Submenu"]) @router.get("/") -async def get_dish(): - return +async def get_submenu(menu_id): + return menu_id diff --git a/src/fastfood_two/routers/summary.py b/src/fastfood_two/routers/summary.py index e69de29..841cb05 100644 --- a/src/fastfood_two/routers/summary.py +++ b/src/fastfood_two/routers/summary.py @@ -0,0 +1,8 @@ +from fastapi import APIRouter + +router = APIRouter(prefix="/summary", tags=["Summary"]) + + +@router.get("/") +async def get_summary(): + return