Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 1.15 KB

README.md

File metadata and controls

38 lines (26 loc) · 1.15 KB

HttpRunner Schemas

LICENSE Build Status

Repository of all schemas for JSON structures compatible with HttpRunner.

Versions

Usage

All the schemas in this repository are valid JSON Schemas, compliant with the JSON-Schema, Draft 6.

As such, they can be used with jsonschema to validate arbitrary JSON blobs, as show below:

import json
import requests
from jsonschema import validate
from jsonschema.exceptions import ValidationError

schema = requests.get('http://schema.httprunner.org/json/v1.json').json()

json_path = "tests/data/demo_validate_pass.json"  # Whatever needs to be validated.
with open(json_path) as f:
    test_input = json.load(f)

try:
    validate(test_input, schema)
except ValidationError:
    print('It is not a valid collection!')
else:
    print('It is a valid collection!')