fix swagger
This commit is contained in:
parent
e8e750bc7d
commit
872fa74f18
12
main.py
12
main.py
@ -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"]:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user