简体   繁体   English

API文档-Django Rest Swagger-GET和POST的不同参数

[英]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 . 我正在使用Django Rest Swagger来记录由Django Rest Framework制作的API。 My APIClass has two methods: get and post. 我的APIClass有两种方法:get和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: 但是我想要的是this ,它不能很好地生成文档:

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. Josep您更新的方法文档是正确的。 The issue you report is well-known in the django-rest-swagger community. 您报告的问题在django-rest-swagger社区中众所周知。 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. 不幸的是,Gibbons先生没有将此修补程序合并到master中,但是您可以像其他许多人一样进行分叉和修补。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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