Skip to content

Commit 71bafd7

Browse files
committed
drop oas30 read write properties
1 parent 563fea0 commit 71bafd7

File tree

2 files changed

+0
-122
lines changed

2 files changed

+0
-122
lines changed

openapi_schema_validator/validators.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -97,41 +97,3 @@
9797
type_checker=oas31_type_checker,
9898
format_checker=oas_format.oas31_format_checker,
9999
)
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)

tests/integration/test_validators.py

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -284,90 +284,6 @@ def test_required(self, validator_class):
284284
validator.validate({"another_prop": "bla"})
285285
assert validator.validate({"some_prop": "hello"}) is None
286286

287-
def test_read_only(self, validator_class):
288-
schema = {
289-
"type": "object",
290-
"properties": {"some_prop": {"type": "string", "readOnly": True}},
291-
}
292-
293-
with pytest.warns(DeprecationWarning):
294-
validator = validator_class(
295-
schema, format_checker=oas30_format_checker, write=True
296-
)
297-
with pytest.raises(
298-
ValidationError,
299-
match="Tried to write read-only property with hello",
300-
):
301-
validator.validate({"some_prop": "hello"})
302-
with pytest.warns(DeprecationWarning):
303-
validator = validator_class(
304-
schema, format_checker=oas30_format_checker, read=True
305-
)
306-
assert validator.validate({"some_prop": "hello"}) is None
307-
308-
def test_write_only(self, validator_class):
309-
schema = {
310-
"type": "object",
311-
"properties": {"some_prop": {"type": "string", "writeOnly": True}},
312-
}
313-
314-
with pytest.warns(DeprecationWarning):
315-
validator = validator_class(
316-
schema, format_checker=oas30_format_checker, read=True
317-
)
318-
with pytest.raises(
319-
ValidationError,
320-
match="Tried to read write-only property with hello",
321-
):
322-
validator.validate({"some_prop": "hello"})
323-
with pytest.warns(DeprecationWarning):
324-
validator = validator_class(
325-
schema, format_checker=oas30_format_checker, write=True
326-
)
327-
assert validator.validate({"some_prop": "hello"}) is None
328-
329-
def test_required_read_only(self, validator_class):
330-
schema = {
331-
"type": "object",
332-
"properties": {"some_prop": {"type": "string", "readOnly": True}},
333-
"required": ["some_prop"],
334-
}
335-
336-
with pytest.warns(DeprecationWarning):
337-
validator = validator_class(
338-
schema, format_checker=oas30_format_checker, read=True
339-
)
340-
with pytest.raises(
341-
ValidationError, match="'some_prop' is a required property"
342-
):
343-
validator.validate({"another_prop": "hello"})
344-
with pytest.warns(DeprecationWarning):
345-
validator = validator_class(
346-
schema, format_checker=oas30_format_checker, write=True
347-
)
348-
assert validator.validate({"another_prop": "hello"}) is None
349-
350-
def test_required_write_only(self, validator_class):
351-
schema = {
352-
"type": "object",
353-
"properties": {"some_prop": {"type": "string", "writeOnly": True}},
354-
"required": ["some_prop"],
355-
}
356-
357-
with pytest.warns(DeprecationWarning):
358-
validator = validator_class(
359-
schema, format_checker=oas30_format_checker, write=True
360-
)
361-
with pytest.raises(
362-
ValidationError, match="'some_prop' is a required property"
363-
):
364-
validator.validate({"another_prop": "hello"})
365-
with pytest.warns(DeprecationWarning):
366-
validator = validator_class(
367-
schema, format_checker=oas30_format_checker, read=True
368-
)
369-
assert validator.validate({"another_prop": "hello"}) is None
370-
371287
def test_oneof_required(self, validator_class):
372288
instance = {
373289
"n3IwfId": "string",

0 commit comments

Comments
 (0)