![](/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.