feat: Updated endpoint endpoints/names.post.py via AI

This commit is contained in:
Backend IM Bot 2025-04-12 21:32:24 +00:00
parent badeb5d57e
commit 4e528f862a
2 changed files with 6 additions and 5 deletions

View File

@ -1,11 +1,12 @@
from fastapi import APIRouter, status
from fastapi import APIRouter
from typing import List
from schemas.fruit import FruitNamesResponse
from helpers.fruit_helpers import get_all_fruit_names
router = APIRouter()
@router.post("/names", status_code=status.HTTP_200_OK, response_model=List[str])
async def get_names():
"""Return all fruit names"""
@router.post("/names", status_code=200, response_model=List[FruitNamesResponse])
async def get_fruit_names():
"""Get all fruit names"""
fruit_names = get_all_fruit_names()
return fruit_names

View File

@ -47,7 +47,7 @@ def get_fruit_by_name(db: Session, name: str) -> Optional[Fruit]:
def get_all_fruit_names(db: Session) -> List[str]:
"""
Retrieves a list of all fruit names.
This is the preferred method for getting fruit names.
Note: This method is deprecated in favor of get_all_fruits() which returns complete fruit objects.
Args:
db (Session): The database session.