Checks OpenAPI specification file integrity and validate request and responses of API implementation
4.0K
This project aimed to validate OpenAPI 3+ specification file and also check and validate REST API requests and responses that must fit given specification file.
Base used core library is Python 3 openapi-core.
--parameters is given, then substitute path parameters (path parts in {curly} brackets), GET parameters (url part after ? sign), POST payload (request body) in requests and test specific url with given parameters. Multiple sets of parameters for one path are supported, please see openapi-checker file for examples and description--api cli parameter), receive responses and validate that both requests and responses are fits with given OpenAPI specification fileCheck specification integrity only, specification located on URL:
sudo docker run --rm andyceo/openapi-checker https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml
Check specification integrity (local file) and requests and responses of implemented API (URL):
sudo docker run --rm -v /path/to/openapi.yaml:/app/openapi.yaml andyceo/openapi-checker openapi.yaml --api http://127.0.0.1:81
Check specification integrity (local file) and requests and responses of an implemented API (URL), substitute parameters in specification with values given in parameters.yml local file:
sudo docker run --rm \
-v /path/to/openapi.yaml:/app/openapi.yaml \
-v /path/to/parameters.yaml:/app/parameters.yaml \
andyceo/openapi-checker openapi.yaml --api http://127.0.0.1:81 --parameters parameters.yaml
sudo docker build -t openapi-checker:latest .
You can use this image from Docker Hub: andyceo/openapi-checker
You should have Python 3 and pip utility installed on your system.
To be able to execute openapi-checker.py script on your system, just install needed packages with pip:
pip install -r requirements.txt
And after that you can check your OpenAPI:
/path/to/openapi-checker https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml --api http://127.0.0.1:8080
Content type
Image
Digest
Size
31.4 MB
Last updated
almost 8 years ago
docker pull andyceo/openapi-checker