我已将 swagger 与 django rest 框架集成,但 swagger 文档不会创建输入框来发布数据以进行发布请求。
我的解析器设置,
REST_FRAMEWORK = {
'DEFAULT_PARSER_CLASSES': (
'rest_framework.parsers.JSONParser',
'rest_framework.parsers.FormParser',
'rest_framework.parsers.MultiPartParser',
),
}
这是我的视图类片段,`
class TeamViewList(APIView, BaseView):
"""
Class based view to handle all operations related to Team Model
"""
logger = logging.getLogger(__name__)
def get_serializer(self):
return serializers.TeamSerializer
def post(self, request):
"""
To create a new team
"""
try:
网址映射:
urlpatterns = [
url(r'^role/$', rest_views.UserTeamRoleView.as_view(), name='user_team_role'),
url(r'^teams/$', rest_views.TeamViewList.as_view(), name='team_list'),
url(r'^teams/(?P<name>[_a-zA-Z0-9\-]+)$', rest_views.TeamViewDetail.as_view(), name='team_detail'),
]
无法将 json 有效负载作为输入传递给发布请求。