|
3 | 3 | from typing import Type
|
4 | 4 |
|
5 | 5 | from jsonschema import _legacy_validators
|
6 |
| -from jsonschema import _utils |
7 | 6 | from jsonschema import _validators
|
8 | 7 | from jsonschema.protocols import Validator
|
9 | 8 | from jsonschema.validators import Draft202012Validator
|
10 | 9 | from jsonschema.validators import create
|
11 | 10 | from jsonschema.validators import extend
|
| 11 | +from jsonschema_specifications import REGISTRY as SPECIFICATIONS |
12 | 12 |
|
13 | 13 | from openapi_schema_validator import _format as oas_format
|
14 | 14 | from openapi_schema_validator import _types as oas_types
|
15 | 15 | from openapi_schema_validator import _validators as oas_validators
|
16 | 16 | from openapi_schema_validator._types import oas31_type_checker
|
17 | 17 |
|
18 | 18 | OAS30Validator = create(
|
19 |
| - meta_schema=_utils.load_schema("draft4"), |
| 19 | + meta_schema=SPECIFICATIONS.contents( |
| 20 | + "http://json-schema.org/draft-04/schema#", |
| 21 | + ), |
20 | 22 | validators={
|
21 | 23 | "multipleOf": _validators.multipleOf,
|
22 | 24 | # exclusiveMaximum supported inside maximum_draft3_draft4
|
|
97 | 99 | type_checker=oas31_type_checker,
|
98 | 100 | format_checker=oas_format.oas31_format_checker,
|
99 | 101 | )
|
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