![](/img/trans.png)
[英]How to add method description in Swagger UI in PyCharm with Flask-RESTX
[英]How to set username and password for basic auth in flask restx swagger?
我正在嘗試向我的 flask rest-x 應用程序添加基本授權。 參考https://github.com/python-restx/flask-restx/issues/271我做了代碼修改。
但是這里並沒有明確說明如何設置用戶名和密碼。 同樣在 swagger 用戶界面中,我看到基本身份驗證的登錄使用任何用戶名和密碼。
我曾嘗試搜索多個資源,但無法找到如何設置用戶名和密碼並對其進行身份驗證的方法。 請幫忙解決同樣的問題。
Flask restx version: 0.5.1
試試下面的代碼
from flask_restx import Api
blueprint = Blueprint("api", __name__)
authorizations = {
"Authorization": {
"description": "Inputs: Basic \\email\\>",
"type": "apiKey",
"in": "header",
"name": "Authorization",
}
}
api = Api(
blueprint,
title="Dummy API",
version="1.0",
authorizations=authorizations,
security="Authorization",
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.