将多个文件合并到一个文件中。
swaggertools的Python项目详细描述
此库允许您将多文件扩展规范合并到 单人间。
快速启动
例如,这两个文件:
# swagger.yml /paths: /users: {$ref: grafts/users.yml#/resources/collection} # grafts/users.yml /resources: collection: get: 200: post: 201:
将合并为:
# swagger.yml /paths: /users: get: 200: post: 201:
wich可用于根据editor.swagger.io验证api。
安装
pip install swaggertools
用法
作为命令行:
swagger-tools /path/to/swagger.yml
进入python脚本:
from swaggertools import resolve with open('/path/to/swagger.yml') as filehandler: app = resolve(filehandler) print(app.to_yaml())