22from base64 import b64encode
33from typing import Any
44from typing import cast
5+ from unittest .mock import patch
56
67import pytest
78from jsonschema import SchemaError
3435from openapi_schema_validator ._dialects import OAS32_BASE_DIALECT_ID
3536from openapi_schema_validator ._dialects import OAS32_BASE_DIALECT_METASCHEMA
3637from openapi_schema_validator ._dialects import register_openapi_dialect
37- from openapi_schema_validator .validators import check_openapi_schema
3838
3939
4040class TestOAS30ValidatorFormatChecker :
@@ -1087,7 +1087,7 @@ def test_check_schema_accepts_oas32_discriminator_default_mapping(self):
10871087 },
10881088 }
10891089
1090- check_openapi_schema ( OAS32Validator , schema )
1090+ OAS32Validator . check_schema ( schema )
10911091
10921092 def test_oas31_check_schema_rejects_discriminator_default_mapping (self ):
10931093 schema = {
@@ -1099,7 +1099,21 @@ def test_oas31_check_schema_rejects_discriminator_default_mapping(self):
10991099 }
11001100
11011101 with pytest .raises (SchemaError ):
1102- check_openapi_schema (OAS31Validator , schema )
1102+ OAS31Validator .check_schema (schema )
1103+
1104+ def test_oas32_check_schema_does_not_fetch_remote_metaschemas (self ):
1105+ schema = {
1106+ "type" : "object" ,
1107+ "discriminator" : {
1108+ "propertyName" : "kind" ,
1109+ "defaultMapping" : "#/components/schemas/Pet" ,
1110+ },
1111+ }
1112+
1113+ with patch ("urllib.request.urlopen" ) as urlopen :
1114+ OAS32Validator .check_schema (schema )
1115+
1116+ urlopen .assert_not_called ()
11031117
11041118
11051119class TestOAS30StrictValidator :
0 commit comments