简体   繁体   中英

API Documentation - Django Rest Swagger - Different params for GET and POST


I am using Django Rest Swagger to document my API which is made with Django Rest Framework . My APIClass has two methods: get and post. And I want the documentation to note this difference but it seems that it expect both to have the same params . Look:

This is generating documentation well :

class Product(APIView):
    """
    Do something with product
    param1 -- Product name
    param2 -- Category
    """

    def get(self, request, format=None):
       ...

    def post(self, request, format=None):
       ...

Screenshot2

But what I want is this , which is not generating documentation well:

class Product(APIView):

    def get(self, request, format=None):
       """
       Get products
       param1 -- Parameter for filtering by category
       """
       ...

    def post(self, request, format=None):

       """
       Create a new product
       param1 -- Product name
       param2 -- Category
       """
       ...

Screenshot1

How can I do it? Any idea?? Thanks so much! ;-)

Josep your updated method documentation is correct. The issue you report is well-known in the django-rest-swagger community. See this commit for the fix. Unfortunately Mr. Gibbons has not merged this fix into master, but you can certainly fork and patch as many other people have done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM