Skip to content

Commit 7d2d2e5

Browse files
yifanYifan Zhang
andauthored
Add security in openapi (#18)
Co-authored-by: Yifan Zhang <freqyifan@gmail.com>
1 parent dce8ad4 commit 7d2d2e5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

apihub/server.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,13 @@ def custom_openapi(app=api):
388388
openapi_schema["info"]["x-logo"] = {
389389
"url": "https://raw.githubusercontent.com/yifan/apihub/master/images/APIHub-logo.png"
390390
}
391+
392+
# patch security not defined in path
393+
for path in openapi_schema["paths"].values():
394+
for operation in path.values():
395+
if "security" not in operation:
396+
operation["security"] = [{"BasicAuth": []}]
397+
391398
paths, components_schemas, security_schemes = get_paths()
392399
openapi_schema["paths"].update(paths)
393400
openapi_schema["components"]["schemas"].update(components_schemas)

0 commit comments

Comments
 (0)