some fix in docsyrings
parent
078d6d0c7a
commit
4ba1a31dee
|
@ -3,21 +3,27 @@ import logging
|
|||
from fastapi import FastAPI
|
||||
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, async_sessionmaker
|
||||
|
||||
from fastfood_two.app.depends.config import get_settings
|
||||
from fastfood_two.app.depends.session import (
|
||||
create_engine,
|
||||
create_session_maker,
|
||||
get_session,
|
||||
)
|
||||
from fastfood_two.common.logger import configure_logger
|
||||
from fastfood_two.config import Config
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
configure_logger(level=logging.INFO)
|
||||
|
||||
|
||||
def init_dependencies(app: FastAPI) -> None:
|
||||
"""Initialize FastAPI dependencies."""
|
||||
"""Initialize FastAPI dependencies.
|
||||
|
||||
# app.dependency_overrides[Settings] = get_settings
|
||||
:param app: FastAPI application
|
||||
:type app: FastAPI
|
||||
"""
|
||||
|
||||
app.dependency_overrides[Config] = get_settings
|
||||
|
||||
app.dependency_overrides[AsyncEngine] = create_engine
|
||||
app.dependency_overrides[async_sessionmaker[AsyncSession]] = create_session_maker
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
import os
|
||||
from functools import lru_cache
|
||||
|
||||
from fastfood_two.config import Config
|
||||
from fastfood_two.storage.pg_storage.config import PostgresConfig
|
||||
|
||||
|
||||
@lru_cache()
|
||||
def get_settings() -> Config:
|
||||
"""Возвращает настройки приложения"""
|
||||
return Config(
|
||||
db=PostgresConfig(
|
||||
user=os.getenv("DB_USER", "test_user"),
|
||||
password=os.getenv("DB_PASS", "test_password"),
|
||||
host=os.getenv("DB_HOST", "localhost"),
|
||||
port=int(os.getenv("DB_PORT", 5432)),
|
||||
dbname=os.getenv("DB_NAME", "test_db"),
|
||||
),
|
||||
)
|
|
@ -2,5 +2,9 @@ from fastapi import FastAPI
|
|||
|
||||
|
||||
def init_errorhandlers(app: FastAPI) -> None:
|
||||
"""Initialize FastAPI error handlers."""
|
||||
"""Initialize FastAPI error handlers.
|
||||
|
||||
:param app: FastAPI application
|
||||
:type app: FastAPI
|
||||
"""
|
||||
pass
|
||||
|
|
|
@ -7,7 +7,11 @@ from fastfood_two.routers.summary import router as summary_router
|
|||
|
||||
|
||||
def init_routers(app: FastAPI) -> None:
|
||||
"""Initialize FastAPI routers."""
|
||||
"""Initialize FastAPI routers.
|
||||
|
||||
:param app: FastAPI application
|
||||
:type app: FastAPI
|
||||
"""
|
||||
base_router = APIRouter(
|
||||
prefix="/api/v1",
|
||||
)
|
||||
|
|
|
@ -2,7 +2,11 @@ import logging
|
|||
|
||||
|
||||
def configure_logger(level=logging.INFO) -> None:
|
||||
"""Configure the logger output string."""
|
||||
"""Configure the logger output string.
|
||||
|
||||
:param level: Logging level
|
||||
:type level: int | logging.level INFO, WARNING, ERROR, CRITICAL, DEBUG
|
||||
"""
|
||||
|
||||
logging.basicConfig(
|
||||
level=level,
|
||||
|
|
|
@ -7,8 +7,3 @@ class MenuResponse:
|
|||
id: UUID
|
||||
name: str
|
||||
description: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class MenusResponse:
|
||||
menus: list[MenuResponse]
|
|
@ -1,8 +1,10 @@
|
|||
from fastapi import APIRouter
|
||||
|
||||
from fastfood_two.contracts.responses import MenuResponse
|
||||
|
||||
router = APIRouter(prefix="/menu", tags=["Menu"])
|
||||
|
||||
|
||||
@router.get("/")
|
||||
async def get_menus():
|
||||
return
|
||||
@router.get("/", response_model=list[MenuResponse])
|
||||
async def get_all_menus() -> list[MenuResponse]:
|
||||
return []
|
||||
|
|
Loading…
Reference in New Issue