improve on openapi metadata (#1795)

This commit is contained in:
dni ⚡
2023-08-24 10:52:12 +01:00
committed by GitHub
parent 4e6f229db2
commit 39d717e34c
7 changed files with 54 additions and 25 deletions
+12 -8
View File
@@ -6,12 +6,12 @@ from subprocess import Popen
from typing import Optional
from urllib.parse import urlparse
from fastapi import Body, Depends
from fastapi import Depends
from fastapi.responses import FileResponse
from starlette.exceptions import HTTPException
from lnbits.core.crud import get_wallet
from lnbits.core.models import User
from lnbits.core.models import CreateTopup, User
from lnbits.core.services import (
get_balance_delta,
update_cached_settings,
@@ -25,7 +25,12 @@ from .. import core_app, core_app_extra
from ..crud import delete_admin_settings, get_admin_settings, update_admin_settings
@core_app.get("/admin/api/v1/audit", dependencies=[Depends(check_admin)])
@core_app.get(
"/admin/api/v1/audit",
name="Audit",
description="show the current balance of the node and the LNbits database",
dependencies=[Depends(check_admin)],
)
async def api_auditor():
try:
delta, node_balance, total_balance = await get_balance_delta()
@@ -86,14 +91,13 @@ async def api_restart_server() -> dict[str, str]:
@core_app.put(
"/admin/api/v1/topup/",
name="Topup",
status_code=HTTPStatus.OK,
dependencies=[Depends(check_super_user)],
)
async def api_topup_balance(
id: str = Body(...), amount: int = Body(...)
) -> dict[str, str]:
async def api_topup_balance(data: CreateTopup) -> dict[str, str]:
try:
await get_wallet(id)
await get_wallet(data.id)
except Exception:
raise HTTPException(
status_code=HTTPStatus.FORBIDDEN, detail="wallet does not exist."
@@ -104,7 +108,7 @@ async def api_topup_balance(
status_code=HTTPStatus.FORBIDDEN, detail="VoidWallet active"
)
await update_wallet_balance(wallet_id=id, amount=int(amount))
await update_wallet_balance(wallet_id=data.id, amount=int(data.amount))
return {"status": "Success"}