@@ -225,6 +225,42 @@ def test_required(self):
225225 validator .validate ({"another_prop" : "bla" })
226226 assert validator .validate ({"some_prop" : "hello" }) is None
227227
228+ def test_read_only (self ):
229+ schema = {
230+ "type" : "object" ,
231+ "properties" : {"some_prop" : {"type" : "string" , "readOnly" : True }},
232+ }
233+
234+ validator = OAS30Validator (
235+ schema , format_checker = oas30_format_checker , write = True
236+ )
237+ with pytest .raises (
238+ ValidationError , match = "Tried to write read-only property with hello"
239+ ):
240+ validator .validate ({"some_prop" : "hello" })
241+ validator = OAS30Validator (
242+ schema , format_checker = oas30_format_checker , read = True
243+ )
244+ assert validator .validate ({"some_prop" : "hello" }) is None
245+
246+ def test_write_only (self ):
247+ schema = {
248+ "type" : "object" ,
249+ "properties" : {"some_prop" : {"type" : "string" , "writeOnly" : True }},
250+ }
251+
252+ validator = OAS30Validator (
253+ schema , format_checker = oas30_format_checker , read = True
254+ )
255+ with pytest .raises (
256+ ValidationError , match = "Tried to read write-only property with hello"
257+ ):
258+ validator .validate ({"some_prop" : "hello" })
259+ validator = OAS30Validator (
260+ schema , format_checker = oas30_format_checker , write = True
261+ )
262+ assert validator .validate ({"some_prop" : "hello" }) is None
263+
228264 def test_required_read_only (self ):
229265 schema = {
230266 "type" : "object" ,
0 commit comments