Skip to content

Commit 4bdf8a4

Browse files
committed
Reduce OAS 3.0 evolve overhead
evolve runs on every descend; avoid the Mapping ABC check for plain dicts and test the rarer $schema key first.
1 parent 7322036 commit 4bdf8a4

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎openapi_schema_validator/validators.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,11 @@ def _build_oas32_validator() -> Any:
255255
def _evolve_oas30(validator: Any, **changes: Any) -> Any:
256256
schema = changes.get("schema", validator.schema)
257257
# jsonschema selects a validator from $schema before filtering keywords.
258+
# Runs on every descend: check the common dict case without the ABC.
258259
if (
259-
isinstance(schema, Mapping)
260-
and "$ref" in schema
260+
(type(schema) is dict or isinstance(schema, Mapping))
261261
and "$schema" in schema
262+
and "$ref" in schema
262263
):
263264
schema = dict(schema)
264265
del schema["$schema"]

0 commit comments

Comments
 (0)