Welcome to Swagger Tester’s documentation!¶
Contents:
swagger-tester¶
Swagger-tester will test automatically your swagger API. Swagger API made with connexion (https://github.com/zalando/connexion) are supported directly without running the API server. In the case you use connexion it will automatically run a test server from your swagger file.
To run the test, swagger-tester will detect every path and actions of your API. And for each, it will send a request and check if the response match the swagger file specification.
Example Usage¶
from swagger_tester import swagger_test
# Dict containing the error you don't want to raise.
# By default, every status_code over other than 1xx, 2xx or 3xx
# will be considered as an error.
authorize_error = {
'post': {
'/pet/{petId}': [200],
'/pet': [200]
},
'put': {
'/user/{username}': [200],
'/pet': [200]
},
'delete': {
'/pet/{petId}': [200],
'/store/order/{orderId}': [200],
'/user/{username}': [200]
}
}
# Run the test with connexion
# An AssertionError will be raise in case of error.
swagger_test('path_to_your_swagger.yaml', authorize_error=authorize_error)
# Or if you have a running API
swagger_test(app_url='http://petstore.swagger.io/v2', authorize_error=authorize_error)
Documentation¶
More documentation is available at https://swagger-tester.readthedocs.org/en/latest/.
Setup¶
make install or pip install swagger-tester
License¶
swagger-tester is licensed under http://opensource.org/licenses/MIT.
Installation¶
At the command line:
$ easy_install swagger_tester
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv swagger_tester
$ pip install swagger_tester
Usage¶
To use Swagger Tester in a project:
from swagger_tester import swagger_test
# Dict containing the error you don't want to raise.
# By default, every status_code over other than 1xx, 2xx or 3xx
# will be considered as an error.
authorize_error = {
'get': {
'/pet/': ['400', '404']
}
}
# Run the test
# An AssertionError will be raise in case of error.
swagger_test('path_to_your_swagger.yaml', authorize_error=authorize_error)
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/cyprieng/swagger_tester/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement it.
Write Documentation¶
Swagger Tester could always use more documentation, whether as part of the official Swagger Tester docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/cyprieng/swagger_tester/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up swagger_tester for local development.
Fork the swagger_tester repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/swagger_tester.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv swagger_tester $ cd swagger_tester/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 swagger_tester tests $ python setup.py test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check https://travis-ci.org/cyprieng/swagger_tester/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Cyprien Guillemot <cyprien.guillemot@gmail.com>
Contributors¶
None yet. Why not be the first?
History¶
0.2.7 (2016-11-22)¶
- TODO
0.2.6 (2016-5-20)¶
- Fix repeated base path bug
0.2.5 (2016-3-25)¶
- Add support for headers parameters.
0.2.4 (2016-3-23)¶
- Improve the check of status code when ‘default’ is in the specification.
0.2.3 (2016-2-10)¶
- Fix some errors (like file upload).
0.2.2 (2016-2-3)¶
- Fix validation of standard types.
0.2.1 (2016-1-31)¶
- Change license to MIT.
0.2.0 (2016-1-31)¶
- Now support swagger APIs not made with connexion.
0.1 (2016-1-29)¶
- First release on PyPI.