api-contract
v1.0.0
Published
Simple API JSON contract validator
Downloads
57
Maintainers
Readme
API contract
A simple library/command-line tool to verify API responses.
Usage
Sample configuration
[
{
"method": "get",
"endpoint": "https://api.github.com/users/MunGell",
"schema": "tests/test-schema.json"
}
]
Sample schema
{
"type": "object",
"properties": {
"login": {
"type": "string"
},
"id": {
"type": "number"
},
"avatar_url": {
"type": "string"
},
"gravatar_id": {
"type": "string"
},
"url": {
"type": "string"
},
"html_url": {
"type": "string"
},
"followers_url": {
"type": "string"
}
},
"additionalProperties": true
}
Documentation
- Information on schema format could be found here: https://github.com/webpack-contrib/schema-utils
- Configuration file is an array of tested endpoints (objects) with following parameters:
method
- request method e.g. get, post, headendpoint
- URL to requestschema
- path to the schema filedata
- (optional) data object for post, patch and put requestconfig
- (optional) additional request configuration object
Licence
MIT