Skip to content

Commit 68b2bfd

Browse files
committed
Rename env var
1 parent 25f3a57 commit 68b2bfd

File tree

8 files changed

+13
-9
lines changed

8 files changed

+13
-9
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ validating an instance. For trusted pre-validated schemas in hot paths, set
9696

9797
The ``validate`` helper keeps an internal compiled-validator cache. You can
9898
control cache size using the
99-
``OPENAPI_SCHEMA_VALIDATOR_VALIDATE_CACHE_MAX_SIZE`` environment variable
99+
``OPENAPI_SCHEMA_VALIDATOR_COMPILED_VALIDATOR_CACHE_MAX_SIZE`` environment variable
100100
(default: ``128``).
101101

102102
To validate an OpenAPI schema:

docs/contributing.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ Performance benchmark
7979
^^^^^^^^^^^^^^^^^^^^^
8080

8181
The ``validate`` shortcut uses an internal compiled-validator cache. You can
82-
adjust cache capacity with the ``OPENAPI_SCHEMA_VALIDATOR_VALIDATE_CACHE_MAX_SIZE``
82+
adjust cache capacity with the
83+
``OPENAPI_SCHEMA_VALIDATOR_COMPILED_VALIDATOR_CACHE_MAX_SIZE``
8384
environment variable (default: ``128``).
8485

8586
To collect a local benchmark report for validation performance, run:

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Configuration
8989

9090
Environment variables:
9191

92-
* ``OPENAPI_SCHEMA_VALIDATOR_VALIDATE_CACHE_MAX_SIZE``
92+
* ``OPENAPI_SCHEMA_VALIDATOR_COMPILED_VALIDATOR_CACHE_MAX_SIZE``
9393
Maximum number of compiled validators kept by the ``validate`` shortcut
9494
cache. Default: ``128``.
9595

docs/validation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ For trusted pre-validated schemas in hot paths, set ``check_schema=False`` to
4040
skip schema checking.
4141

4242
The shortcut keeps an internal compiled-validator cache.
43-
Use ``OPENAPI_SCHEMA_VALIDATOR_VALIDATE_CACHE_MAX_SIZE`` to control cache
43+
Use ``OPENAPI_SCHEMA_VALIDATOR_COMPILED_VALIDATOR_CACHE_MAX_SIZE`` to control cache
4444
capacity (default: ``128``).
4545

4646
To validate an OpenAPI schema:

openapi_schema_validator/_caches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@ def clear(self) -> None:
102102
self._cache.clear()
103103

104104
def _prune_if_needed(self) -> None:
105-
max_size = get_settings().validate_cache_max_size
105+
max_size = get_settings().compiled_validator_cache_max_size
106106
while len(self._cache) > max_size:
107107
self._cache.popitem(last=False)

openapi_schema_validator/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class OpenAPISchemaValidatorSettings(BaseSettings):
1111
extra="ignore",
1212
)
1313

14-
validate_cache_max_size: int = Field(default=128, ge=0)
14+
compiled_validator_cache_max_size: int = Field(default=128, ge=0)
1515

1616

1717
@lru_cache(maxsize=1)

openapi_schema_validator/shortcuts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ def validate(
8181
validator_kwargs.setdefault("registry", _LOCAL_ONLY_REGISTRY)
8282

8383
key = _VALIDATOR_CACHE.build_key(
84-
schema=schema,
84+
schema=schema_dict,
8585
cls=cls,
8686
args=args,
87-
kwargs=kwargs,
87+
kwargs=validator_kwargs,
8888
allow_remote_references=allow_remote_references,
8989
)
9090

tests/unit/test_shortcut.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ def test_validate_cache_max_size_from_env(monkeypatch):
181181
schema_a = {"type": "string"}
182182
schema_b = {"type": "integer"}
183183

184-
monkeypatch.setenv("OPENAPI_SCHEMA_VALIDATOR_VALIDATE_CACHE_MAX_SIZE", "1")
184+
monkeypatch.setenv(
185+
"OPENAPI_SCHEMA_VALIDATOR_COMPILED_VALIDATOR_CACHE_MAX_SIZE",
186+
"1",
187+
)
185188
reset_settings_cache()
186189

187190
with patch(

0 commit comments

Comments
 (0)