feat: improve on api structure, add openapi tags (#2295)

this logically groups api endpoints and gioves them specific openapi tags. which makes them nice on the `/docs` endpoint and makes the `api.py` more approachable
* add wallets list endpoint
* remove trailing slashes from endpoints
* fixup topup url
* fix trailing slash on auth
* backwards compatibility
This commit is contained in:
dni ⚡ 2024-03-28 08:59:28 +01:00 committed by GitHub
parent 1dd096213e
commit 741ecac78b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 930 additions and 818 deletions

View file

@ -20,7 +20,7 @@ from lnbits.core.crud import (
)
from lnbits.core.models import CreateInvoice
from lnbits.core.services import update_wallet_balance
from lnbits.core.views.api import api_payments_create_invoice
from lnbits.core.views.payment_api import api_payments_create_invoice
from lnbits.db import DB_TYPE, SQLITE, Database
from lnbits.settings import settings
from tests.helpers import (

View file

@ -5,13 +5,13 @@ from lnbits.settings import settings
@pytest.mark.asyncio
async def test_admin_get_settings_permission_denied(client, from_user):
response = await client.get(f"/admin/api/v1/settings/?usr={from_user.id}")
response = await client.get(f"/admin/api/v1/settings?usr={from_user.id}")
assert response.status_code == 401
@pytest.mark.asyncio
async def test_admin_get_settings(client, superuser):
response = await client.get(f"/admin/api/v1/settings/?usr={superuser.id}")
response = await client.get(f"/admin/api/v1/settings?usr={superuser.id}")
assert response.status_code == 200
result = response.json()
assert "super_user" not in result
@ -21,7 +21,7 @@ async def test_admin_get_settings(client, superuser):
async def test_admin_update_settings(client, superuser):
new_site_title = "UPDATED SITETITLE"
response = await client.put(
f"/admin/api/v1/settings/?usr={superuser.id}",
f"/admin/api/v1/settings?usr={superuser.id}",
json={"lnbits_site_title": new_site_title},
)
assert response.status_code == 200
@ -34,7 +34,7 @@ async def test_admin_update_settings(client, superuser):
@pytest.mark.asyncio
async def test_admin_update_noneditable_settings(client, superuser):
response = await client.put(
f"/admin/api/v1/settings/?usr={superuser.id}",
f"/admin/api/v1/settings?usr={superuser.id}",
json={"super_user": "UPDATED"},
)
assert response.status_code == 400

View file

@ -8,7 +8,7 @@ from lnbits.core.crud import get_standalone_payment, update_payment_details
from lnbits.core.models import CreateInvoice, Payment
from lnbits.core.services import fee_reserve_total
from lnbits.core.views.admin_api import api_auditor
from lnbits.core.views.api import api_payment
from lnbits.core.views.payment_api import api_payment
from lnbits.settings import settings
from lnbits.wallets import get_wallet_class