|
15 | 15 | from openapi_schema_validator import _types as oas_types |
16 | 16 | from openapi_schema_validator._dialects import OAS31_BASE_DIALECT_ID |
17 | 17 | from openapi_schema_validator._dialects import OAS31_BASE_DIALECT_METASCHEMA |
| 18 | +from openapi_schema_validator._dialects import OAS32_BASE_DIALECT_ID |
| 19 | +from openapi_schema_validator._dialects import OAS32_BASE_DIALECT_METASCHEMA |
18 | 20 | from openapi_schema_validator._dialects import register_openapi_dialect |
19 | 21 | from openapi_schema_validator._specifications import ( |
20 | 22 | REGISTRY as OPENAPI_SPECIFICATIONS, |
@@ -134,6 +136,20 @@ def _build_oas31_validator() -> Any: |
134 | 136 | ) |
135 | 137 |
|
136 | 138 |
|
| 139 | +def _build_oas32_validator() -> Any: |
| 140 | + validator = extend( |
| 141 | + OAS31Validator, |
| 142 | + {}, |
| 143 | + format_checker=oas_format.oas32_format_checker, |
| 144 | + ) |
| 145 | + return register_openapi_dialect( |
| 146 | + validator=validator, |
| 147 | + dialect_id=OAS32_BASE_DIALECT_ID, |
| 148 | + version_name="oas32", |
| 149 | + metaschema=OAS32_BASE_DIALECT_METASCHEMA, |
| 150 | + ) |
| 151 | + |
| 152 | + |
137 | 153 | OAS30Validator = _build_oas30_validator() |
138 | 154 | OAS30StrictValidator = extend( |
139 | 155 | OAS30Validator, |
@@ -162,13 +178,7 @@ def _build_oas31_validator() -> Any: |
162 | 178 | ) |
163 | 179 |
|
164 | 180 | OAS31Validator = _build_oas31_validator() |
| 181 | +OAS32Validator = _build_oas32_validator() |
165 | 182 |
|
166 | | -# OAS 3.2 uses JSON Schema Draft 2020-12 as its base dialect, same as |
167 | | -# OAS 3.1. The OAS-specific vocabulary differs slightly (e.g. xml keyword |
168 | | -# changes), but since xml is not_implemented in the current validators, |
169 | | -# the behavior is equivalent. |
170 | | -OAS32Validator = extend( |
171 | | - OAS31Validator, |
172 | | - {}, |
173 | | - format_checker=oas_format.oas32_format_checker, |
174 | | -) |
| 183 | +OAS31Validator.check_schema = classmethod(check_openapi_schema) |
| 184 | +OAS32Validator.check_schema = classmethod(check_openapi_schema) |
0 commit comments