Ejemplo n.º 1
0
def test_validate_openapi():
    schema = """
    {
        "openapi": "3.0.0",
        "info": {"title": "", "version": ""},
        "paths": {}
    }
    """
    validate(schema, format="openapi", encoding="json")
Ejemplo n.º 2
0
def test_validate_autodetermine_failed():
    schema = """
    {
        "info": {"title": "", "version": ""},
        "paths": {}
    }
    """
    with pytest.raises(ValidationError):
        validate(schema, encoding="json")
Ejemplo n.º 3
0
def test_validate_autodetermine_swagger():
    schema = """
    {
        "swagger": "2.0",
        "info": {"title": "", "version": ""},
        "paths": {}
    }
    """
    validate(schema, encoding="json")
Ejemplo n.º 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")
Ejemplo n.º 5
0
def test_validate_openapi_datastructure():
    schema = {
        "openapi": "3.0.0",
        "info": {
            "title": "",
            "version": ""
        },
        "paths": {}
    }
    validate(schema, format="openapi")
Ejemplo n.º 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")
Ejemplo n.º 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")
Ejemplo n.º 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")