Let's assume that we have for example such URL - localhost:8000/object?name=STH
. Anyone have an idea how can I display object
with name
equals STH
using Django Swagger Documentation?
class ObjectList(GenericAPIView):
serializer_class = ObjectSerializer
def get(self, request):
try:
t = request.GET['sth']
object = Object.objects.filter(sth=sth)
except:
object = Object.objects.all()
serializer = ObjectSerializer(object, many=True)
return Response(serializer.data)
I am trying in this way but it's not visible in my Swagger:
URL: url(r'^object-data$', views.ObjectList.as_view()),
class ObjectList(GenericAPIView):
serializer_class = ObjectSerializer
filter_backends = (DjangoFilterBackend, )
filter_fields = ('sth', )
At this moment my Swagger looks as shown below. I would like to have sth
instead of pages
. I have no idea why it is there.
I am using djang-filter package that integrates nicely with rest framework and it also has support for swagger docs, you get auto-generated filtering columns for that endpoint in swagger.