Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions openapi_schema_validator/_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ def write_readOnly(
instance: Any,
schema: Mapping[str, Any],
) -> Iterator[ValidationError]:
if not ro:
return
yield ValidationError(f"Tried to write read-only property with {instance}")


Expand All @@ -250,6 +252,8 @@ def read_writeOnly(
instance: Any,
schema: Mapping[str, Any],
) -> Iterator[ValidationError]:
if not wo:
return
yield ValidationError(f"Tried to read write-only property with {instance}")


Expand Down
26 changes: 26 additions & 0 deletions tests/integration/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,32 @@ def test_required_write_only(self):
)
assert validator.validate({"another_prop": "hello"}) is None

def test_read_only_false(self):
schema = {
"type": "object",
"properties": {"some_prop": {"type": "string", "readOnly": False}},
}

validator = OAS30WriteValidator(
schema,
format_checker=oas30_format_checker,
)
assert validator.validate({"some_prop": "hello"}) is None

def test_write_only_false(self):
schema = {
"type": "object",
"properties": {
"some_prop": {"type": "string", "writeOnly": False}
},
}

validator = OAS30ReadValidator(
schema,
format_checker=oas30_format_checker,
)
assert validator.validate({"some_prop": "hello"}) is None


class TestOAS31ValidatorFormatChecker:
@pytest.fixture
Expand Down
Loading