Python 中的 OpenAPI (原名 Swagger) 客户端和转换器,具有类型安全、动态且符合规范的特点。
A python client for Swagger enabled REST API. It wouldn't be easier to try Swagger REST API by Swagger-UI. However, when it's time to unittest your API, the first option you find would be Swagger-codegen, but the better option is us.
This project is developed after swagger-py, which is a nicely implemented one, and inspired many aspects of this project. Another project is flex, which focuses on parameter validation, try it if you can handle other parts by yourselves. For other projects related to Swagger tools in python, check here.
pyswagger is much easier to use (compared to swagger-codegen, you don't need to prepare a scala environment) and tries hard to fully supports Swagger Spec in all aspects.
pyswagger.tests.contrib.client for details
Before running this script, please make sure requests is installed on your environment.
…We support pip installtion.
pip install pyswaggerAdditional dependencies must be prepared before firing a request. If you are going to access a remote/local web server, you must install requests first.
pip install requestsIf you want to test a local tornado server, please make sure tornado is ready on your environment
pip install tornadoWe also provide native client for flask app, but to use it, flask is also required
pip install flaskAll exported API are described in following sections.
import logging
logger = logging.getLogger('pyswagger')
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
console = logging.StreamHandler()
console.setLevel(logging.DEBUG)
console.setFormatter(formatter)
logger.addHandler(console)
logger.setLevel(logging.DEBUG)
... your stuff
develop would be acceptedenv preparation
pip install -r requirement-dev.txtunit testing
python -m pytest -s -v --cov=pyswagger --cov-config=.coveragerc pyswagger/tests暂无开放 Issues,或尚未同步最近议题。