File tree Expand file tree Collapse file tree 3 files changed +16
-14
lines changed Expand file tree Collapse file tree 3 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -234,27 +234,21 @@ def additionalProperties(
234234 yield ValidationError (error % extras_msg (extras ))
235235
236236
237- def readOnly (
237+ def write_readOnly (
238238 validator : Validator ,
239239 ro : bool ,
240240 instance : Any ,
241241 schema : Mapping [Hashable , Any ],
242242) -> Iterator [ValidationError ]:
243- if not getattr (validator , "write" , True ) or not ro :
244- return
245-
246243 yield ValidationError (f"Tried to write read-only property with { instance } " )
247244
248245
249- def writeOnly (
246+ def read_writeOnly (
250247 validator : Validator ,
251248 wo : bool ,
252249 instance : Any ,
253250 schema : Mapping [Hashable , Any ],
254251) -> Iterator [ValidationError ]:
255- if not getattr (validator , "read" , True ) or not wo :
256- return
257-
258252 yield ValidationError (f"Tried to read write-only property with { instance } " )
259253
260254
Original file line number Diff line number Diff line change 4949 "$ref" : _keywords .ref ,
5050 # fixed OAS fields
5151 "discriminator" : oas_keywords .not_implemented ,
52- "readOnly" : oas_keywords .readOnly ,
53- "writeOnly" : oas_keywords .writeOnly ,
52+ "readOnly" : oas_keywords .not_implemented ,
53+ "writeOnly" : oas_keywords .not_implemented ,
5454 "xml" : oas_keywords .not_implemented ,
5555 "externalDocs" : oas_keywords .not_implemented ,
5656 "example" : oas_keywords .not_implemented ,
6868 OAS30Validator ,
6969 validators = {
7070 "required" : oas_keywords .read_required ,
71- "readOnly" : oas_keywords .not_implemented ,
72- "writeOnly" : oas_keywords .writeOnly ,
71+ "writeOnly" : oas_keywords .read_writeOnly ,
7372 },
7473)
7574OAS30WriteValidator = extend (
7675 OAS30Validator ,
7776 validators = {
7877 "required" : oas_keywords .write_required ,
79- "readOnly" : oas_keywords .readOnly ,
80- "writeOnly" : oas_keywords .not_implemented ,
78+ "readOnly" : oas_keywords .write_readOnly ,
8179 },
8280)
8381
Original file line number Diff line number Diff line change @@ -596,6 +596,11 @@ def test_read_only(self):
596596 format_checker = oas30_format_checker ,
597597 )
598598 assert validator .validate ({"some_prop" : "hello" }) is None
599+ validator = OAS30Validator (
600+ schema ,
601+ format_checker = oas30_format_checker ,
602+ )
603+ assert validator .validate ({"some_prop" : "hello" }) is None
599604
600605 def test_write_only (self ):
601606 schema = {
@@ -617,6 +622,11 @@ def test_write_only(self):
617622 format_checker = oas30_format_checker ,
618623 )
619624 assert validator .validate ({"some_prop" : "hello" }) is None
625+ validator = OAS30Validator (
626+ schema ,
627+ format_checker = oas30_format_checker ,
628+ )
629+ assert validator .validate ({"some_prop" : "hello" }) is None
620630
621631 def test_required_read_only (self ):
622632 schema = {
You can’t perform that action at this time.
0 commit comments