RAML规范的Python参考实现ramlfications详解
2017-06-27 10:12
309 查看
ramlfications是RAML规范的一个参考实现,使用Python语言编写。
1. ramlfications的组成
类库
命令行工具
通过ramlfications的类库,能够开发解析并验证RAML文件的Python软件。
通过ramlfications的命令行工具,可以验证RAML API,并以树状结构可视化显示。
2. ramlfications的安装
3. ramlfications的更新
安装ramlfications后,可以直接通过ramlfications命令更新。
4. ramlfications类库的用法
1).解析
通过Python代码解析RAML文件
通过配置文件,定制解析RAML文件
通过配置文件,可以使RAML API支持额外的协议或响应代码,或定制的认证模式(但是不推荐)
定义配置文件my-config.ini示例如下:
结合配置文件解析RAML文件如下:
2).验证
验证RAML文件是否遵循RAML 1.0规范。
5. ramlfications命令行工具的用法
ramlfications命令行工具的基本使用格式
ramlfications命令行工具的3个基本命令:
validate
tree
$ ramlfications -c /path/to/my-config.ini tree /path/to/my-api.raml [-C|--color light|dark] [-v|vv|vvv] [-o|--output fileName]
update
参考链接:
https://github.com/spotify/ramlfications https://ramlfications.readthedocs.io/en/latest/index.html
1. ramlfications的组成
类库
命令行工具
通过ramlfications的类库,能够开发解析并验证RAML文件的Python软件。
通过ramlfications的命令行工具,可以验证RAML API,并以树状结构可视化显示。
2. ramlfications的安装
pip install ramlfications
3. ramlfications的更新
安装ramlfications后,可以直接通过ramlfications命令更新。
$ ramlfications update
4. ramlfications类库的用法
1).解析
通过Python代码解析RAML文件
import ramlfications RAML_FILE = "/path/to/my-api.raml" api = ramlfications.parse(RAML_FILE) api.title api.version
通过配置文件,定制解析RAML文件
通过配置文件,可以使RAML API支持额外的协议或响应代码,或定制的认证模式(但是不推荐)
定义配置文件my-config.ini示例如下:
[main] validate = True [custom] append = True resp_codes = 420, 421, 422 auth_schemes = oauth_3_0, oauth_4_0 media_types = application/vnd.github.v3, foo/bar protocols = FTP raml_versions = 0.8
结合配置文件解析RAML文件如下:
import ramlfications RAML_FILE = "/path/to/my-api.raml" CONFIG_FILE = "/path/to/my-config.ini" api = ramlfications.parse(RAML_FILE, CONFIG_FILE)
2).验证
验证RAML文件是否遵循RAML 1.0规范。
from ramlfications import validate RAML_FILE = "/path/to/my-api.raml" validate(RAML_FILE)
5. ramlfications命令行工具的用法
ramlfications命令行工具的基本使用格式
$ ramlfications [OPTIONS] COMMAND [ARGS]
ramlfications命令行工具的3个基本命令:
validate
$ ramlfications validate /path/to/my-api.raml或
$ ramlfications -c /path/to/my-config.ini validate /path/to/my-api.raml
tree
$ ramlfications tree /path/to/my-api.raml [-C|--color light|dark] [-v|vv|vvv] [-o|--output fileName]或
$ ramlfications -c /path/to/my-config.ini tree /path/to/my-api.raml [-C|--color light|dark] [-v|vv|vvv] [-o|--output fileName]
update
$ ramlfications update
参考链接:
https://github.com/spotify/ramlfications https://ramlfications.readthedocs.io/en/latest/index.html
相关文章推荐
- Linux守护进程设计规范及python实现
- python编码规范工具PyLint (未亲测,但是头部分具有参考价值)
- 一个简单的 python 实现 图片同步脚本 ,对于有图片群集的项目有参考价值
- Java Portlet规范的参考实现-Pluto项目介绍(1)
- Linux守护进程设计规范及python实现
- apriori算法的代码,python实现,参考《机器学习实战》
- Java bean validation 规范与参考实现
- Python 实现抽象类的两种方式+邮件提醒+动态导入模块+反射(参考Django中间件源码)
- Java bean validation 规范与参考实现
- Linux守护进程设计规范及python实现http://blog.csdn.net/dysj4099/article/details/18219411
- Python实现将不规范的英文名字首字母大写
- Linux守护进程设计规范及python实现
- 2017.05.10回顾 numpy学习 其他python woe iv实现参考
- Linux守护进程设计规范及python实现
- Python命名规范参考
- python实现命令行火车票查看器--参考实验楼文档
- Python实现将不规范的英文名字首字母大写
- 在python种实现类的静态方法
- [参考+原创]实现TREEVIEW的右键选中功能
- (16)Shark工作流的实现和WMFC&OMG规范的对比