Skip to content

Commit e3387e3

Browse files
committed
More responses for docs
1 parent 46b2b7b commit e3387e3

5 files changed

Lines changed: 17 additions & 8 deletions

File tree

app/api/v1/bankomat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def set_pin(
457457
return {"detail": "PIN updated"}
458458

459459

460-
@router.get("/statement/{target_slug}")
460+
@router.get("/statement/{target_slug}", response_class=Response)
461461
def get_statement(
462462
target_slug: str,
463463
from_year: int = Query(...),
@@ -522,7 +522,7 @@ def get_statement(
522522
raise HTTPException(500, f"PDF generation failed: {e}") from e
523523

524524

525-
@router.get("/statement-all")
525+
@router.get("/statement-all", response_class=Response)
526526
def get_statement_all(
527527
from_year: int = Query(...),
528528
from_month: int = Query(...),

app/api/v1/products.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
ProductStocktaking,
3333
ProductUpdate,
3434
PurchaseBody,
35+
PurchaseResponse,
3536
)
3637

3738
router = APIRouter()
@@ -333,7 +334,7 @@ def delete_alias(
333334

334335
# --- Purchase (checkout device) ---
335336

336-
@router.post("/products/{ean}/purchase")
337+
@router.post("/products/{ean}/purchase", response_model=PurchaseResponse)
337338
def purchase_product(
338339
ean: str,
339340
body: PurchaseBody,
@@ -373,4 +374,4 @@ def purchase_product(
373374
))
374375
db.commit()
375376

376-
return {"detail": "Purchase successful", "product": product.name, "new_balance": float(user.balance)}
377+
return PurchaseResponse(detail="Purchase successful", product=product.name, new_balance=user.balance)

app/api/v1/rentals.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from app.schemas.common import MessageResponse
1212
from app.schemas.rental import (
1313
ActiveRentalResponse,
14+
RentalAuthorizeResponse,
1415
RentalCatalogItem,
1516
RentalItemCreate,
1617
RentalItemResponse,
@@ -133,7 +134,7 @@ def item_status(
133134

134135
# --- Rental operations ---
135136

136-
@router.get("/authorize/{nfc_id}")
137+
@router.get("/authorize/{nfc_id}", response_model=RentalAuthorizeResponse)
137138
def authorize_renter(
138139
nfc_id: int,
139140
device: Machine = Depends(get_current_device),

app/schemas/product.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ class PurchaseBody(BaseModel):
8080
nfc_id: int
8181

8282

83-
class ProductPurchase(BaseModel):
84-
nfc_id: int
85-
ean: str
83+
class PurchaseResponse(BaseModel):
84+
detail: str
85+
product: str
86+
new_balance: Decimal = Field(ge=0, examples=[Decimal("4.20")])
8687

8788

8889
class ProductPopularityResponse(BaseModel):

app/schemas/rental.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,9 @@ class RentalCatalogItem(BaseModel):
7777
uhf_tid: str
7878
name: str
7979
is_rented: bool
80+
81+
82+
class RentalAuthorizeResponse(BaseModel):
83+
authorized: bool
84+
user_id: int
85+
user_name: Optional[str]

0 commit comments

Comments
 (0)