16 lines
541 B
Python
16 lines
541 B
Python
from fastapi import APIRouter, Depends, status
|
|
from sqlalchemy.orm import Session
|
|
from typing import List
|
|
from core.database import get_db
|
|
from schemas.fruit import FruitSchema
|
|
from helpers.fruit_helpers import get_all_fruits
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/fruits", response_model=List[FruitSchema], status_code=status.HTTP_200_OK)
|
|
async def get_fruits(db: Session = Depends(get_db)):
|
|
fruits = get_all_fruits(db)
|
|
for fruit in fruits:
|
|
if hasattr(fruit, 'is_ripe'):
|
|
delattr(fruit, 'is_ripe')
|
|
return fruits |