"""FastAPI test app that registers the AFI fixture."""

from __future__ import annotations

from fastapi import FastAPI

from mizan_fastapi import (
    MizanError,
    mizan_exception_handler,
    mizan_validation_handler,
    router as mizan_router,
)

from fixture import register_fixture


def make_app() -> FastAPI:
    """Build a fresh FastAPI app with the AFI fixture registered."""
    register_fixture()

    app = FastAPI()
    app.include_router(mizan_router, prefix="/api/mizan")
    app.add_exception_handler(MizanError, mizan_exception_handler)
    from fastapi.exceptions import RequestValidationError
    app.add_exception_handler(RequestValidationError, mizan_validation_handler)
    return app
