Пример #1
0
def test_validate_openapi():
    schema = """
    {
        "openapi": "3.0.0",
        "info": {"title": "", "version": ""},
        "paths": {}
    }
    """
    validate(schema, format="openapi", encoding="json")
Пример #2
0
def test_validate_autodetermine_failed():
    schema = """
    {
        "info": {"title": "", "version": ""},
        "paths": {}
    }
    """
    with pytest.raises(ValidationError):
        validate(schema, encoding="json")
Пример #3
0
def test_validate_autodetermine_swagger():
    schema = """
    {
        "swagger": "2.0",
        "info": {"title": "", "version": ""},
        "paths": {}
    }
    """
    validate(schema, encoding="json")
Пример #4
0
def test_validate_with_bad_encoding():
    schema = """
    {
        "openapi": "3.0.0",
        "info": {"title": "", "version": ""},
        "paths": {}
    }
    """
    with pytest.raises(ValueError):
        validate(schema, format="openapi", encoding="xxx")
Пример #5
0
def test_validate_openapi_datastructure():
    schema = {
        "openapi": "3.0.0",
        "info": {
            "title": "",
            "version": ""
        },
        "paths": {}
    }
    validate(schema, format="openapi")
Пример #6
0
def test_infer_json():
    """
    If 'encoding=' is omitted, then it should inferred from the content.
    """
    schema = """
    {
        "openapi": "3.0.0",
        "info": {"title": "", "version": ""},
        "paths": {}
    }
    """
    validate(schema, format="openapi")
Пример #7
0
def test_infer_yaml():
    """
    If 'encoding=' is omitted, then it should inferred from the content.
    """
    schema = """
        openapi: "3.0.0"
        info:
            title: ""
            version: ""
        paths: {}
    """
    validate(schema, format="openapi")
Пример #8
0
def test_validate_unneccessary_encoding():
    """
    Passing 'encoding=' is invalid if 'schema' is a dict already.
    """
    schema = {
        "openapi": "3.0.0",
        "info": {
            "title": "",
            "version": ""
        },
        "paths": {}
    }
    with pytest.raises(ValueError):
        validate(schema, format="openapi", encoding="json")