File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -241,6 +241,8 @@ def write_readOnly(
241241 instance : Any ,
242242 schema : Mapping [str , Any ],
243243) -> Iterator [ValidationError ]:
244+ if not ro :
245+ return
244246 yield ValidationError (f"Tried to write read-only property with { instance } " )
245247
246248
@@ -250,6 +252,8 @@ def read_writeOnly(
250252 instance : Any ,
251253 schema : Mapping [str , Any ],
252254) -> Iterator [ValidationError ]:
255+ if not wo :
256+ return
253257 yield ValidationError (f"Tried to read write-only property with { instance } " )
254258
255259
Original file line number Diff line number Diff line change @@ -670,6 +670,32 @@ def test_required_write_only(self):
670670 )
671671 assert validator .validate ({"another_prop" : "hello" }) is None
672672
673+ def test_read_only_false (self ):
674+ schema = {
675+ "type" : "object" ,
676+ "properties" : {"some_prop" : {"type" : "string" , "readOnly" : False }},
677+ }
678+
679+ validator = OAS30WriteValidator (
680+ schema ,
681+ format_checker = oas30_format_checker ,
682+ )
683+ assert validator .validate ({"some_prop" : "hello" }) is None
684+
685+ def test_write_only_false (self ):
686+ schema = {
687+ "type" : "object" ,
688+ "properties" : {
689+ "some_prop" : {"type" : "string" , "writeOnly" : False }
690+ },
691+ }
692+
693+ validator = OAS30ReadValidator (
694+ schema ,
695+ format_checker = oas30_format_checker ,
696+ )
697+ assert validator .validate ({"some_prop" : "hello" }) is None
698+
673699
674700class TestOAS31ValidatorFormatChecker :
675701 @pytest .fixture
You can’t perform that action at this time.
0 commit comments