Skip to content

Commit 223020d

Browse files
committed
jsonschema 4.18 compatibility
1 parent ac2d9c7 commit 223020d

File tree

4 files changed

+688
-765
lines changed

4 files changed

+688
-765
lines changed

Diff for: .github/workflows/python-test.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ jobs:
2828
id: full-python-version
2929
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
3030

31-
- name: Bootstrap poetry
32-
run: |
33-
curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python - -y
34-
echo "$HOME/.local/bin" >> $GITHUB_PATH
31+
- name: Set up poetry
32+
uses: Gr1N/setup-poetry@v8
3533

3634
- name: Configure poetry
3735
run: poetry config virtualenvs.in-project true

Diff for: openapi_schema_validator/validators.py

+4-40
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
from typing import Type
44

55
from jsonschema import _legacy_validators
6-
from jsonschema import _utils
76
from jsonschema import _validators
87
from jsonschema.protocols import Validator
98
from jsonschema.validators import Draft202012Validator
109
from jsonschema.validators import create
1110
from jsonschema.validators import extend
11+
from jsonschema_specifications import REGISTRY as SPECIFICATIONS
1212

1313
from openapi_schema_validator import _format as oas_format
1414
from openapi_schema_validator import _types as oas_types
1515
from openapi_schema_validator import _validators as oas_validators
1616
from openapi_schema_validator._types import oas31_type_checker
1717

1818
OAS30Validator = create(
19-
meta_schema=_utils.load_schema("draft4"),
19+
meta_schema=SPECIFICATIONS.contents(
20+
"http://json-schema.org/draft-04/schema#",
21+
),
2022
validators={
2123
"multipleOf": _validators.multipleOf,
2224
# exclusiveMaximum supported inside maximum_draft3_draft4
@@ -97,41 +99,3 @@
9799
type_checker=oas31_type_checker,
98100
format_checker=oas_format.oas31_format_checker,
99101
)
100-
101-
102-
def _patch_validator_with_read_write_context(cls: Type[Validator]) -> None:
103-
"""Adds read/write context to jsonschema validator class"""
104-
# subclassing validator classes is not intended to
105-
# be part of their public API and will raise error
106-
# See https://github.com/python-openapi/openapi-schema-validator/issues/48
107-
original_init = cls.__init__
108-
original_evolve = cls.evolve
109-
110-
def __init__(self: Validator, *args: Any, **kwargs: Any) -> None:
111-
self.read = kwargs.pop("read", None)
112-
if self.read is not None:
113-
warnings.warn(
114-
"read property is deprecated. "
115-
"Use OAS30ReadValidator instead.",
116-
DeprecationWarning,
117-
)
118-
self.write = kwargs.pop("write", None)
119-
if self.write is not None:
120-
warnings.warn(
121-
"write property is deprecated. "
122-
"Use OAS30WriteValidator instead.",
123-
DeprecationWarning,
124-
)
125-
original_init(self, *args, **kwargs)
126-
127-
def evolve(self: Validator, **changes: Any) -> Validator:
128-
validator = original_evolve(self, **changes)
129-
validator.read = self.read
130-
validator.write = self.write
131-
return validator
132-
133-
cls.__init__ = __init__
134-
cls.evolve = evolve
135-
136-
137-
_patch_validator_with_read_write_context(OAS30Validator)

0 commit comments

Comments
 (0)