首页 > 解决方案 > 身份验证类不可见的 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 }

标签: djangodjango-rest-frameworkdjango-rest-swagger

解决方案


推荐阅读