Generate router modules for all 27 API categories from the OpenAPI spec. Each router will:
- Use the existing
ProcountorClientviaapp/dependencies.py - Define endpoint stubs that extract path/query params and forward to the client
- Use generic
dict[str, Any]for request/response bodies - Include docstrings from the OpenAPI spec summaries
-
Parse OpenAPI spec - Extract all paths, methods, parameters, and summaries grouped by tag
-
Generate router modules - Create
app/routers/directory with one file per tag:invoices.py(26 endpoints)ledger_receipts.py(8 endpoints)business_partners.py(15 endpoints)payments.py(14 endpoints)payrolls.py(14 endpoints)employees.py(23 endpoints)products.py(10 endpoints)company.py(10 endpoints)persons.py(8 endpoints)bank_statements.py(7 endpoints)dimensions.py(5 endpoints)attachments.py(5 endpoints)users.py(5 endpoints)bank_accounts.py(4 endpoints)currencies.py(4 endpoints)factoring_contracts.py(4 endpoints)vats.py(3 endpoints)reference_payments.py(3 endpoints)reports.py(3 endpoints)integrations.py(3 endpoints)sie_file.py(2 endpoints)fiscal_years.py(2 endpoints)chart_of_accounts.py(1 endpoint)journal.py(1 endpoint)session_info.py(1 endpoint)health.py(1 endpoint)- (webhooks already implemented in
app/webhooks.py)
-
Register all routers - Update
app/main.pyto import and include all 26 new routers -
Remove generic proxy - Delete
app/routers.pysince specific routers will replace it -
Update docs - Update README with new endpoint structure
app/main.py- register all routers with appropriate prefixes/tagsapp/routers/*.py- new router modules (26 files)- Delete:
app/routers.py(replaced by specific routers)
# app/routers/invoices.py
from typing import Any
from fastapi import APIRouter, Depends, Path, Query
from ..dependencies import procountor_client
from ..procountor_client import ProcountorClient
router = APIRouter(prefix="/invoices", tags=["Invoices"])
@router.get("")
async def get_invoices(
client: ProcountorClient = Depends(procountor_client),
status: str | None = Query(None),
) -> dict[str, Any]:
"""Search invoices."""
response = await client.request("GET", "/invoices", params={"status": status})
response.raise_for_status()
return response.json()
@router.get("/{invoice_id}")
async def get_invoice(
invoice_id: int = Path(...),
client: ProcountorClient = Depends(procountor_client),
) -> dict[str, Any]:
"""Get invoice by ID."""
response = await client.request("GET", f"/invoices/{invoice_id}")
response.raise_for_status()
return response.json()