Skip to content

Commit 35e7b4a

Browse files
vyuroshchinp1c2u
authored andcommitted
fix review
1 parent 49ad680 commit 35e7b4a

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

openapi_schema_validator/shortcuts.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ def validate(
1515
*args: Any,
1616
**kwargs: Any
1717
) -> None:
18+
"""
19+
Validate an instance against a given schema using the specified validator class.
20+
"""
1821
schema_dict = cast(dict[str, Any], schema)
1922
cls.check_schema(schema_dict)
2023
validator = cls(schema_dict, *args, **kwargs)
21-
errors = list(validator.evolve(schema=schema_dict).iter_errors(instance))
22-
if errors:
23-
error = best_match(errors)
24-
error.message = f"Validation failed: {error.message}"
24+
error = best_match(
25+
validator.evolve(schema=schema_dict).iter_errors(instance)
26+
)
27+
if error is not None:
2528
raise error

openapi_schema_validator/validators.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Any
22
from typing import cast
3+
34
from jsonschema import _keywords
45
from jsonschema import _legacy_keywords
56
from jsonschema.validators import Draft202012Validator

tests/unit/test_shortcut.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
23
from openapi_schema_validator import validate
34

45

0 commit comments

Comments
 (0)