2013-08-05 42 views
0

如何將描述添加到雲端點方法?如何將描述添加到雲端點方法?

只是通過觀察,我發現API explorer使用方法docstring來描述。

enter image description here

在某些情況下,我們使用的裝飾,其防止doscring beeing從API Explorer中正常解析。

代碼示例:

@endpoints.method(ScoreRequestMessage, ScoreResponseMessage, 
        path='scores', http_method='POST', 
        name='scores.insert') 
@do_some_checks 
def scores_insert(self, request): 
    """ 
    Exposes an API endpoint to insert a score for the current user. 

    """ 
    entity = Score.put_from_message(request) 
    return entity.to_message()    

是否有提供的API資源管理器的端點方法描述的方法嗎?

回答

2

如果你的問題是應用裝飾器後文檔字符串丟失,你應該在裝飾器中使用裝飾器functools.wraps。這樣你將保留函數名和文檔字符串。

相關問題