File tree 3 files changed +11
-8
lines changed
3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 2
2
from typing import Dict
3
3
from typing import Hashable
4
4
from typing import Mapping
5
+ from typing import Optional
5
6
from typing import Type
6
7
from typing import TypeVar
7
8
8
- from jsonschema .protocols import Validator
9
9
from jsonschema_spec import Spec as JsonschemaSpec
10
10
from jsonschema_spec import default_handlers
11
- from openapi_spec_validator import openapi_v30_spec_validator
11
+ from openapi_spec_validator .validation import openapi_spec_validator_proxy
12
+ from openapi_spec_validator .validation .protocols import SupportsValidation
12
13
13
14
TSpec = TypeVar ("TSpec" , bound = "Spec" )
14
15
@@ -24,7 +25,7 @@ def create(
24
25
url : str = "" ,
25
26
ref_resolver_handlers : Dict [str , Any ] = default_handlers ,
26
27
separator : str = SPEC_SEPARATOR ,
27
- validator : Validator = openapi_v30_spec_validator ,
28
+ validator : Optional [ SupportsValidation ] = openapi_spec_validator_proxy ,
28
29
) -> TSpec :
29
30
if validator is not None :
30
31
validator .validate (data , spec_url = url )
Original file line number Diff line number Diff line change 3
3
from typing import Dict
4
4
from typing import Hashable
5
5
from typing import Mapping
6
+ from typing import Optional
6
7
7
8
from jsonschema_spec import default_handlers
8
- from openapi_spec_validator import openapi_v30_spec_validator
9
+ from openapi_spec_validator .validation import openapi_spec_validator_proxy
10
+ from openapi_spec_validator .validation .protocols import SupportsValidation
9
11
10
12
from openapi_core .spec .paths import Spec
11
13
@@ -16,9 +18,9 @@ def create_spec(
16
18
handlers : Dict [str , Any ] = default_handlers ,
17
19
validate_spec : bool = True ,
18
20
) -> Spec :
19
- validator = None
21
+ validator : Optional [ SupportsValidation ] = None
20
22
if validate_spec :
21
- validator = openapi_v30_spec_validator
23
+ validator = openapi_spec_validator_proxy
22
24
23
25
return Spec .create (
24
26
spec_dict ,
Original file line number Diff line number Diff line change 1
1
import pytest
2
- from jsonschema . exceptions import ValidationError
2
+ from openapi_spec_validator . validation . exceptions import ValidatorDetectError
3
3
4
4
from openapi_core .spec import Spec
5
5
6
6
7
7
class TestEmpty :
8
8
def test_raises_on_invalid (self ):
9
- with pytest .raises (ValidationError ):
9
+ with pytest .raises (ValidatorDetectError ):
10
10
Spec .create ("" )
You can’t perform that action at this time.
0 commit comments