|
19 | 19 | from openapi_schema_validator import OAS30Validator |
20 | 20 | from openapi_schema_validator import OAS30WriteValidator |
21 | 21 | from openapi_schema_validator import OAS31Validator |
| 22 | +from openapi_schema_validator import OAS32Validator |
22 | 23 | from openapi_schema_validator import oas30_format_checker |
23 | 24 | from openapi_schema_validator import oas30_strict_format_checker |
24 | 25 | from openapi_schema_validator import oas31_format_checker |
| 26 | +from openapi_schema_validator import oas32_format_checker |
25 | 27 |
|
26 | 28 |
|
27 | 29 | class TestOAS30ValidatorFormatChecker: |
@@ -1003,6 +1005,29 @@ def test_array_prefixitems_invalid(self, validator_class, value): |
1003 | 1005 | assert any(error in str(excinfo.value) for error in errors) |
1004 | 1006 |
|
1005 | 1007 |
|
| 1008 | +class TestOAS32ValidatorAliases: |
| 1009 | + """OAS 3.2 uses the same JSON Schema dialect as 3.1, so the validators are aliases.""" |
| 1010 | + |
| 1011 | + def test_validator_is_oas31(self): |
| 1012 | + assert OAS32Validator is OAS31Validator |
| 1013 | + |
| 1014 | + def test_format_checker_is_oas31(self): |
| 1015 | + assert oas32_format_checker is oas31_format_checker |
| 1016 | + |
| 1017 | + def test_basic_validation(self): |
| 1018 | + schema = { |
| 1019 | + "type": "object", |
| 1020 | + "required": ["name"], |
| 1021 | + "properties": {"name": {"type": "string"}}, |
| 1022 | + } |
| 1023 | + validator = OAS32Validator(schema, format_checker=oas32_format_checker) |
| 1024 | + |
| 1025 | + assert validator.validate({"name": "test"}) is None |
| 1026 | + |
| 1027 | + with pytest.raises(ValidationError): |
| 1028 | + validator.validate({"not_name": "test"}) |
| 1029 | + |
| 1030 | + |
1006 | 1031 | class TestOAS30StrictValidator: |
1007 | 1032 | """ |
1008 | 1033 | Tests for OAS30StrictValidator which follows OAS spec strictly: |
|
0 commit comments