add response_validation_exception_handler

This commit is contained in:
grillazz
2025-08-23 20:04:23 +02:00
parent 8312f06c0b
commit e2f01f89c5
6 changed files with 62 additions and 34 deletions

View File

@@ -22,11 +22,12 @@ async def create_nonsense(
@router.get("/", response_model=NonsenseResponse)
async def find_nonsense(
async def get_nonsense(
name: str,
db_session: AsyncSession = Depends(get_db),
):
return await Nonsense.find(db_session, name)
nonsense = await Nonsense.get_by_name(db_session, name)
return nonsense
@router.delete("/")

View File

@@ -52,13 +52,8 @@ async def create_stuff(
@router.get("/{name}", response_model=StuffResponse)
async def find_stuff(name: str, db_session: AsyncSession = Depends(get_db)):
result = await Stuff.find(db_session, name)
if not result:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail=f"Stuff with name {name} not found.",
)
async def get_stuff(name: str, db_session: AsyncSession = Depends(get_db)):
result = await Stuff.get_by_name(db_session, name)
return result