从sphinx文档生成夸张的定义
sphinx-swagger的Python项目详细描述
直接从基于httpdomain的 文档。
用法
- 通过添加^{tt1},在conf.py中启用扩展$ 到extensions列表
- 运行swaggerbuilder(例如,setup.py swagger)
- 使用生成的swagger.json
setuptools命令
此库安装名为swagger的新命令 从setup.py实用程序。它运行狮身人面像来产生招摇 输出文件。它类似于运行sphinx-build-b swagger,除了 它可以访问您的包元数据,因此您不必 在两个地方配置它!
这是使用此软件包的推荐方法。
您可以在项目的setup.cfg中配置输出文件名 [swagger]部分:
[swagger] output-file = static/swagger.json
这使得直接将它包含到构建的工件中变得更容易 在setup.py中将其添加为package_data。记得把它加到 您的manifest.in也在中。
配置
此扩展包含一些有用的配置值,可以是 从sphinx配置文件中设置。
swagger_description: | |
---|---|
Sets the description of the application in the generated swagger file. If this is not set, then the “description” value in ^{tt8}$ will be used if it is set. | |
swagger_file: | Sets the name of the generated swagger file. The file is always generated in the sphinx output directory – usually build/sphinx/swagger. The default file name is swagger.json. |
swagger_license: | |
A dictionary that describes the license that governs the API. This is written as-is to the License section of the API document. It should contain two keys – name and url. |