Tadeas Kosek
commited on
Commit
·
be8d0ca
1
Parent(s):
3482f6a
fixes vol3
Browse files- app.py +2 -38
- interfaces/api/dependencies.py +4 -1
app.py
CHANGED
|
@@ -109,44 +109,8 @@ app = FastAPI(
|
|
| 109 |
]
|
| 110 |
)
|
| 111 |
|
| 112 |
-
#
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
def custom_openapi():
|
| 116 |
-
if app.openapi_schema:
|
| 117 |
-
return app.openapi_schema
|
| 118 |
-
|
| 119 |
-
openapi_schema = get_openapi(
|
| 120 |
-
title=app.title,
|
| 121 |
-
version=app.version,
|
| 122 |
-
description=app.description,
|
| 123 |
-
routes=app.routes,
|
| 124 |
-
tags=app.openapi_tags
|
| 125 |
-
)
|
| 126 |
-
|
| 127 |
-
# Add Bearer token security scheme
|
| 128 |
-
openapi_schema["components"]["securitySchemes"] = {
|
| 129 |
-
"HTTPBearer": {
|
| 130 |
-
"type": "http",
|
| 131 |
-
"scheme": "bearer",
|
| 132 |
-
"bearerFormat": "JWT",
|
| 133 |
-
"description": "Enter your JWT Bearer token"
|
| 134 |
-
}
|
| 135 |
-
}
|
| 136 |
-
|
| 137 |
-
# Apply security to protected endpoints
|
| 138 |
-
for path, path_item in openapi_schema["paths"].items():
|
| 139 |
-
for method, operation in path_item.items():
|
| 140 |
-
if method.lower() in ["get", "post", "put", "patch", "delete"]:
|
| 141 |
-
# Apply security to all endpoints except public ones
|
| 142 |
-
if not (path.endswith("/info") or path.endswith("/health") or path == "/" or path.endswith("/openapi.json") or path.endswith("/docs") or path.endswith("/redoc")):
|
| 143 |
-
# Check if the operation has dependencies that include authentication
|
| 144 |
-
operation["security"] = [{"HTTPBearer": []}]
|
| 145 |
-
|
| 146 |
-
app.openapi_schema = openapi_schema
|
| 147 |
-
return app.openapi_schema
|
| 148 |
-
|
| 149 |
-
app.openapi = custom_openapi
|
| 150 |
|
| 151 |
# Configure middleware
|
| 152 |
configure_cors(app)
|
|
|
|
| 109 |
]
|
| 110 |
)
|
| 111 |
|
| 112 |
+
# Let FastAPI handle OpenAPI generation automatically
|
| 113 |
+
# The HTTPBearer scheme in dependencies.py will be automatically detected
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
# Configure middleware
|
| 116 |
configure_cors(app)
|
interfaces/api/dependencies.py
CHANGED
|
@@ -10,7 +10,10 @@ from infrastructure.services.container import ServiceContainer
|
|
| 10 |
from infrastructure.services.jwt_validation_service import JWTValidationService
|
| 11 |
|
| 12 |
# Create HTTPBearer scheme that will be recognized by OpenAPI
|
| 13 |
-
bearer_scheme = HTTPBearer(
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
class ExtractionRequest(BaseModel):
|
| 16 |
"""Request model for audio extraction."""
|
|
|
|
| 10 |
from infrastructure.services.jwt_validation_service import JWTValidationService
|
| 11 |
|
| 12 |
# Create HTTPBearer scheme that will be recognized by OpenAPI
|
| 13 |
+
bearer_scheme = HTTPBearer(
|
| 14 |
+
bearerFormat="JWT",
|
| 15 |
+
description="JWT Bearer token authentication"
|
| 16 |
+
)
|
| 17 |
|
| 18 |
class ExtractionRequest(BaseModel):
|
| 19 |
"""Request model for audio extraction."""
|