@@ -10,14 +10,22 @@ Validate
1010
1111.. code-block :: python
1212
13- validate(instance, schema, cls = OAS32Validator, allow_remote_references = False , ** kwargs)
13+ validate(
14+ instance,
15+ schema,
16+ cls = OAS32Validator,
17+ allow_remote_references = False ,
18+ check_schema = True ,
19+ ** kwargs,
20+ )
1421
1522 The first argument is always the value you want to validate.
1623The second argument is always the OpenAPI schema object.
1724The ``cls `` keyword argument is optional and defaults to ``OAS32Validator ``.
1825Use ``cls `` when you need a specific validator version/behavior.
1926The ``allow_remote_references `` keyword argument is optional and defaults to
2027``False ``.
28+ The ``check_schema `` keyword argument is optional and defaults to ``True ``.
2129Common forwarded keyword arguments include:
2230
2331- ``registry `` for explicit external reference resolution context
@@ -28,6 +36,13 @@ remote ``$ref`` retrieval.
2836Set ``allow_remote_references=True `` only if you explicitly accept
2937jsonschema's default remote retrieval behavior.
3038
39+ For trusted pre-validated schemas in hot paths, set ``check_schema=False `` to
40+ skip schema checking.
41+
42+ The shortcut keeps an internal compiled-validator cache.
43+ Use ``OPENAPI_SCHEMA_VALIDATOR_VALIDATE_CACHE_MAX_SIZE `` to control cache
44+ capacity (default: ``128 ``).
45+
3146To validate an OpenAPI schema:
3247
3348.. code-block :: python
@@ -171,10 +186,14 @@ Schema errors vs instance errors
171186--------------------------------
172187
173188The high-level ``validate(...) `` helper checks schema validity before instance
174- validation, following ``jsonschema.validate(...) `` behavior.
189+ validation by default (``check_schema=True ``), following
190+ ``jsonschema.validate(...) `` behavior.
175191Malformed schema values (for example an invalid regex in ``pattern ``) raise
176192``SchemaError ``.
177193
194+ When ``check_schema=False ``, schema checking is skipped and malformed schemas
195+ may instead fail during validation with lower-level errors.
196+
178197If you instantiate a validator class directly and call ``.validate(...) ``,
179198schema checking is not performed automatically, matching
180199``jsonschema `` validator-class behavior.
0 commit comments