使用swagger/openapi规范为api mocker节点模块生成配置和测试数据。
api-mocker-generator的Python项目详细描述
API Mocker配置和测试 基于swagger/openapi规范的数据生成器。
安装
$ pip install api-mocker-generator
用法
usage: local_main.py [-h] --swagger SWAGGER --output OUTPUT [--verbose] optional arguments: -h, --help show this help message and exit --swagger SWAGGER Location of swagger document. Could be HTTP endpoint or local file system --output OUTPUT Output directory for configuration and mocked responses --verbose
命令示例
$ api-mocker-generator --swagger http://localhost:8080/api-docs --output ./out
在开发期间在本地运行
$ python local_main.py --swagger http://localhost:8080/api-docs --output ./out
详细调试
要为调试打开详细输出,请设置--verbose参数。
将更新发布到pypi
对于维护者,在 api_mocker_generator.py并运行以下命令:
docker build -f ./Dockerfile.buildenv -t namuan/api_mocker_generator:build . docker run --rm -it --entrypoint python namuan/api_mocker_generator:build setup.py publish
提示时输入pypi.org repo的用户名和密码