Skip to content

Commit da9c9cb

Browse files
Copilotp1c2u
andcommitted
Address review feedback: fix docstring, trailing whitespace, f-string, install docs, validate_formats
Co-authored-by: p1c2u <1679024+p1c2u@users.noreply.github.com>
1 parent 629f4e2 commit da9c9cb

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

README.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ Allowed values are ``auto`` (default), ``jsonschema``, and
141141
``jsonschema-rs``.
142142
Invalid values raise a warning and fall back to ``auto``.
143143

144+
If you select the ``jsonschema-rs`` backend, make sure the optional
145+
``jsonschema-rs`` package is installed:
146+
147+
.. code-block:: bash
148+
149+
pip install jsonschema-rs
150+
144151
Related projects
145152
################
146153

docs/cli.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Performance note:
7373
You can tune resolved-path caching with
7474
``OPENAPI_SPEC_VALIDATOR_RESOLVED_CACHE_MAXSIZE``.
7575
Default is ``128``; set ``0`` to disable.
76-
76+
7777
You can also select schema validator backend with
7878
``OPENAPI_SPEC_VALIDATOR_SCHEMA_VALIDATOR_BACKEND``
7979
(``auto``/``jsonschema``/``jsonschema-rs``).

docs/python.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,6 @@ Schema validator backend can be selected with:
8383
OPENAPI_SPEC_VALIDATOR_SCHEMA_VALIDATOR_BACKEND=jsonschema-rs
8484
8585
Allowed values are ``auto`` (default), ``jsonschema``, and
86-
``jsonschema-rs``.
86+
``jsonschema-rs`` (requires the ``jsonschema-rs`` Python package to be
87+
installed, for example via ``pip install jsonschema-rs``).
8788
Invalid values raise a warning and fall back to ``auto``.

openapi_spec_validator/schemas/backend/jsonschema_rs.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __init__(self, schema: dict[str, Any], validator: Any):
5757
5858
Args:
5959
schema: JSON Schema to validate against
60-
cls: JSON Schema validator
60+
validator: JSON Schema validator
6161
"""
6262
if not HAS_JSONSCHEMA_RS:
6363
raise ImportError(
@@ -149,10 +149,7 @@ def create_validator(schema: dict[str, Any]) -> JsonschemaRsValidatorWrapper:
149149
module = _get_jsonschema_rs_module()
150150
validator_cls: Any = module.validator_cls_for(schema)
151151

152-
validator = validator_cls(
153-
schema,
154-
validate_formats=True,
155-
)
152+
validator = validator_cls(schema)
156153
return JsonschemaRsValidatorWrapper(schema, validator=validator)
157154

158155

tests/bench/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def main():
309309
settings = OpenAPISpecValidatorSettings()
310310

311311
print("Spec schema validator backend selection:")
312-
print(" Configured backend mode: " f"{settings.schema_validator_backend}")
312+
print(f" Configured backend mode: {settings.schema_validator_backend}")
313313
print(f" Effective backend: {schemas.get_validator_backend()}")
314314

315315
# Benchmark custom specs

0 commit comments

Comments
 (0)