Django REST Swagger - Gera 2 GET methods

Asked

Viewed 41 times

0

I am implementing a REST API with Django REST Swagger 2.2.0.

For a given endpoint I have defined that the following methods are available:

http_method_names = ['post', 'put', 'get']

However, in Swagger, 2 versions of the GET method appear:

1 - http://dominio/nome_metodo
2 - http://dominio/nome_metodo/{id}

How do I get Swagger to hide Method 2?

1 answer

0

If the class you are using inherits from Modelviewset automatically these urls will be generated. One solution is to achieve multiple inheritance with others cdrf

from rest_framework.mixins import ListModelMixin, UpdateModelMixin, CreateModelMixin
from rest_framework.views import  GenericViewSet
Class MinhaViewSet(ListModelMixin, UpdateModelMixin, CreateModelMixin, GenericViewSet):
   ...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.