from app.routers import channels, auth, playlist, priorities from fastapi import FastAPI from fastapi.openapi.utils import get_openapi app = FastAPI( title="IPTV Updater API", description="API for IPTV Updater service", version="1.0.0", ) def custom_openapi(): if app.openapi_schema: return app.openapi_schema openapi_schema = get_openapi( title=app.title, version=app.version, description=app.description, routes=app.routes, ) # Ensure components object exists if "components" not in openapi_schema: openapi_schema["components"] = {} # Add schemas if they don't exist if "schemas" not in openapi_schema["components"]: openapi_schema["components"]["schemas"] = {} # Add security scheme component openapi_schema["components"]["securitySchemes"] = { "Bearer": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } } # Add global security requirement openapi_schema["security"] = [{"Bearer": []}] # Set OpenAPI version explicitly openapi_schema["openapi"] = "3.1.0" app.openapi_schema = openapi_schema return app.openapi_schema app.openapi = custom_openapi @app.get("/") async def root(): return {"message": "IPTV Updater API"} # Include routers app.include_router(auth.router) app.include_router(channels.router) app.include_router(playlist.router) app.include_router(priorities.router)