Exemple #1
0
    def test_schema_match_their_examples(self, schema_path_with_example):
        schema = Schema.get_schema(schema_path_with_example)
        validator = Schema.get_validator(schema_path_with_example)
        examples = schema["examples"]

        for example in examples:
            validator.validate_all(example)
Exemple #2
0
def schema_with_examples():
    for file_name in schema_file_names():
        schema = Schema.get_schema(file_name)

        if "examples" in schema:
            yield file_name

        defs = schema.get("$defs")
        if not defs:
            continue

        for key, sub_schema in defs.items():
            if "examples" in sub_schema:
                yield f"{file_name}#/$defs/{key}"
Exemple #3
0
    def test_get_schema(self):
        schema = Schema.get_schema("core.json#/$defs/userId")

        assert isinstance(schema, dict)
        assert schema["type"] == "string"
Exemple #4
0
def get_schema_example(schema_path):
    return deepcopy(Schema.get_schema(schema_path)["examples"][0])
Exemple #5
0
 def test_schema_is_a_valid_schema(self, schema_path):
     schema = Schema.get_schema(schema_path)
     Draft7Validator.check_schema(schema)