django - 身份验证类不可见的 django-rest-swagger 2.2.0 端点
问题描述
我正在开发一个 django 应用程序,它有一堆定义了自定义和基本身份验证类的端点,但是 swagger 只显示没有身份验证类并且具有权限类 = AllowAny 的端点。
如何在没有任何身份验证/权限的情况下使所有端点在“docs/”端点上可见?
Django==2.1.7
djangorestframework==3.9.1
jango-rest-swagger==2.2.0
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.AllowAny',
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
),
'DEFAULT_PARSER_CLASSES': (
'rest_framework.parsers.JSONParser',
'rest_framework.parsers.FormParser',
'rest_framework.parsers.MultiPartParser',
)
}
SWAGGER_SETTINGS = {
'exclude_namespaces': [], # List URL namespaces to ignore
'api_version': '', # Specify your API's version. Might be useful in future
'api_path': '/', # Specify the path to your API not a root level
'enabled_methods': [ # Specify which methods to enable in Swagger UI
'get',
'post',
'put',
'patch',
'delete'
],
'token_type': 'Bearer',
'api_key': {}, # An API key
'is_authenticated': False, # Set to True to enforce user authentication,
'is_superuser': False, # Set to True to enforce admin only access
}
解决方案
推荐阅读
- typescript - 如何在打字稿中结合其他功能键入功能
- python-3.x - 猴子修补列表子类在深度复制时导致无限递归
- scala - 在 Scala 2.13 中。如何在宏中可靠地记录信息/警告/错误?
- react-native - 为什么我不能使用多个反应上下文?
- c# - PInvoke 从指针到结构的封送值
- python - 使用python在任务管理器中运行同一应用程序进程的Taskkill多个实例
- python - 当光标悬停在 Python (tkinter) 中的画布上时显示消息
- scala - Spark 3.0 scala.None$ 不是字符串模式的有效外部类型
- kubernetes - Kubernetes minikube 自动缩放中是否提供中断功能?
- ruby - 由于 mac 上的 rubyracer 错误,无法安装 Jekyll