File tree 3 files changed +16
-14
lines changed
3 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -234,27 +234,21 @@ def additionalProperties(
234
234
yield ValidationError (error % extras_msg (extras ))
235
235
236
236
237
- def readOnly (
237
+ def write_readOnly (
238
238
validator : Validator ,
239
239
ro : bool ,
240
240
instance : Any ,
241
241
schema : Mapping [Hashable , Any ],
242
242
) -> Iterator [ValidationError ]:
243
- if not getattr (validator , "write" , True ) or not ro :
244
- return
245
-
246
243
yield ValidationError (f"Tried to write read-only property with { instance } " )
247
244
248
245
249
- def writeOnly (
246
+ def read_writeOnly (
250
247
validator : Validator ,
251
248
wo : bool ,
252
249
instance : Any ,
253
250
schema : Mapping [Hashable , Any ],
254
251
) -> Iterator [ValidationError ]:
255
- if not getattr (validator , "read" , True ) or not wo :
256
- return
257
-
258
252
yield ValidationError (f"Tried to read write-only property with { instance } " )
259
253
260
254
Original file line number Diff line number Diff line change 49
49
"$ref" : _keywords .ref ,
50
50
# fixed OAS fields
51
51
"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 ,
54
54
"xml" : oas_keywords .not_implemented ,
55
55
"externalDocs" : oas_keywords .not_implemented ,
56
56
"example" : oas_keywords .not_implemented ,
68
68
OAS30Validator ,
69
69
validators = {
70
70
"required" : oas_keywords .read_required ,
71
- "readOnly" : oas_keywords .not_implemented ,
72
- "writeOnly" : oas_keywords .writeOnly ,
71
+ "writeOnly" : oas_keywords .read_writeOnly ,
73
72
},
74
73
)
75
74
OAS30WriteValidator = extend (
76
75
OAS30Validator ,
77
76
validators = {
78
77
"required" : oas_keywords .write_required ,
79
- "readOnly" : oas_keywords .readOnly ,
80
- "writeOnly" : oas_keywords .not_implemented ,
78
+ "readOnly" : oas_keywords .write_readOnly ,
81
79
},
82
80
)
83
81
Original file line number Diff line number Diff line change @@ -596,6 +596,11 @@ def test_read_only(self):
596
596
format_checker = oas30_format_checker ,
597
597
)
598
598
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
599
604
600
605
def test_write_only (self ):
601
606
schema = {
@@ -617,6 +622,11 @@ def test_write_only(self):
617
622
format_checker = oas30_format_checker ,
618
623
)
619
624
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
620
630
621
631
def test_required_read_only (self ):
622
632
schema = {
You can’t perform that action at this time.
0 commit comments