帮助您使用json模式验证api端点请求/响应的简单库
aiohttp_validate的Python项目详细描述
aiohttp_验证
帮助您使用jsonschema验证api端点请求/响应的简单库。文档也可以在https://aiohttp-validate.readthedocs.io找到。
安装
从pypi安装:
pip install aiohttp_validate
使用量
验证text tokenization microservice:
的完整示例from aiohttp_validate import validate @validate( request_schema={ "type": "object", "properties": { "text": {"type": "string"}, }, "required": ["text"], "additionalProperties": False }, response_schema={ "type": "array", "items": { "type": "array", "items": { "type": "array", "items": {"type": "string"} } } } ) async def tokenize_text_handler(request, *args): return tokenize_text(request["text"])
功能
- decorator(可选)验证对aiohttp端点的请求及其响应。
- 轻松地与aiohttp_swaggerify集成,自动用swagger记录端点。
- 验证错误是标准化的,您的服务的客户机可以很容易地对其进行分析,而且还具有可读性。
发展中
安装要求和启动测试:
pip install -r requirements-dev.txt py.test
学分
该包受hamza faran编写的Tornado-JSON的影响 分析错误的代码由Ruslan Karalkin
许可证
- 自由软件:麻省理工学院许可证
历史记录
1.0.0(2016-12-12)
- 更好的文件。
- 更新要求。
- 离开阿尔法!
0.1.0(2016-10-12)
- pypi上的第一个版本。