python-openapi/openapi-schema-validator

readOnly and writeOnly with jsonschema4 doesn't work

p1c2u opened this issue · 0 comments

p1c2u commented

Given schema and validator:

schema = {
    "type": "object",
    "properties": {
        "some_prop": {
            "type": "string",
            "readOnly": True
        }
    },
    "required": ["some_prop"]
}
validator = OAS30Validator(schema, format_checker=oas30_format_checker, write=True)

For the following instance:

validator.validate({"some_prop": "hello"})

in jsonschem3 we get error (correct):

Tried to write read-only property with hello

In jsonschem4 we get no errors (incorrect)

The issue exists in all versions <0.3.0