fix swagger

This commit is contained in:
johnpccd 2025-05-24 07:20:06 +02:00
parent e8e750bc7d
commit 872fa74f18

12
main.py
View File

@ -103,16 +103,22 @@ def custom_openapi():
routes=app.routes,
)
# Initialize components if not present
if "components" not in openapi_schema:
openapi_schema["components"] = {}
# Add API key security scheme
openapi_schema["components"] = {
"securitySchemes": {
openapi_schema["components"]["securitySchemes"] = {
"ApiKeyAuth": {
"type": "apiKey",
"in": "header",
"name": "X-API-Key"
}
}
}
# Ensure schemas are included
if "schemas" not in openapi_schema["components"]:
openapi_schema["components"]["schemas"] = {}
# Apply security to all endpoints except auth endpoints
for path in openapi_schema["paths"]: