Swagger不能正确反映Django Rest框架中的POST端点定义
我有一个小问题Swagger不能正确反映Django Rest框架中的POST端点定义,django,django-rest-framework,swagger,Django,Django Rest Framework,Swagger,我有一个小问题 class SmallEndpointViewSet(APIView): def post(self, request, *args, **kwargs): //add the request.data data to the db def delete(self, request, pk, format=None): // remove the data[pk] from db 在URL.py中 urlpatterns = [
class SmallEndpointViewSet(APIView):
def post(self, request, *args, **kwargs):
//add the request.data data to the db
def delete(self, request, pk, format=None):
// remove the data[pk] from db
在URL.py中
urlpatterns = [
url(
r'^small-endpoint/(?P<pk>\d+)/$',
mystuff_views.SmallEndpointViewSet.as_view(),
name='small-endpoint'
),
url(
r'^small-endpoint/$',
mystuff_views.SmallEndpointViewSet.as_view(),
name='small-endpoint'
),
]
但随后我收到错误TypeError:as_view()正好接受1个参数(给定2个)
我相信as_view的APIView版本不接收参数,这很好。我真正想要的是大摇大摆地正确地反映出POST调用不需要和id
我该怎么做
url(
r'^small-endpoint/$',
mystuff_views.SmallEndpointViewSet.as_view({
'post': 'create'
}),
name='small-endpoint'
),