2014-09-04 31 views
1


我使用Django的休息揚鞭來記錄我的API,它與Django的REST框架製造。 我的APIClass有兩種方法:get和post。我希望文檔能夠注意到這種差異,但它似乎期望兩者具有相同的參數。看:API文檔 - Django的休息揚鞭 - 不同的params用於在GET和POST

這是生成文檔以及

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

但我要的是,這是生成文檔得好:

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

我該怎麼辦?任何想法??非常感謝! ;-)

回答

0

Josep您更新的方法文檔是正確的。您報告的問題在django-rest-swagger社區中是衆所周知的。有關修復,請參閱this commit。不幸的是,吉本斯先生並沒有將這種修復方法合併到主人手中,但你可以像其他人一樣進行修補和修補。

+0

儘管此鏈接可能會回答問題,但最好在此處包含答案的重要部分,並提供供參考的鏈接。如果鏈接頁面更改,則僅鏈接答案可能會失效。 – Sasa 2014-10-22 19:08:53