python 如何使用Flask-RESTX在PyCharm的Swagger UI中添加方法描述

2exbekwf  于 2023-04-04  发布在  Python
关注(0)|答案(2)|浏览(227)

我正在使用Swagger作为我的API工具框架,我刚刚找到了这个页面:https://petstore.swagger.io/并了解了每个方法如何具有描述。
例如:POST: pet/add a new Pet to the store描述。
我想在PyCharm中添加这样的描述,使用Flask-RESTX。我该怎么做呢?我阅读了RESTX的规范页面,但没有找到任何有用的帮助。

m2xkgtsf

m2xkgtsf1#

Flask-swagger提供了一个方法(swagger),用于检查Flask应用程序中包含带有Swagger 2.0 Operation对象的YAML文档字符串的端点。
这是一种添加描述和摘要的方法。

class Data(Resource):
   @api.doc(description="getSomething")
   def get(self):
      """getsomething"""
      ....

然后添加描述和总结。

kqlmhetl

kqlmhetl2#

你应该有一个swagger.yml。

summary: <your description here>

Basic Structure

相关问题