Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ Allowed values are ``auto`` (default), ``jsonschema``, and
``jsonschema-rs``.
Invalid values raise a warning and fall back to ``auto``.

If you select the ``jsonschema-rs`` backend, make sure the optional
``jsonschema-rs`` package is installed:

.. code-block:: bash

pip install jsonschema-rs

Related projects
################

Expand Down
2 changes: 1 addition & 1 deletion docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Performance note:
You can tune resolved-path caching with
``OPENAPI_SPEC_VALIDATOR_RESOLVED_CACHE_MAXSIZE``.
Default is ``128``; set ``0`` to disable.

You can also select schema validator backend with
``OPENAPI_SPEC_VALIDATOR_SCHEMA_VALIDATOR_BACKEND``
(``auto``/``jsonschema``/``jsonschema-rs``).
3 changes: 2 additions & 1 deletion docs/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,6 @@ Schema validator backend can be selected with:
OPENAPI_SPEC_VALIDATOR_SCHEMA_VALIDATOR_BACKEND=jsonschema-rs

Allowed values are ``auto`` (default), ``jsonschema``, and
``jsonschema-rs``.
``jsonschema-rs`` (requires the ``jsonschema-rs`` Python package to be
installed, for example via ``pip install jsonschema-rs``).
Invalid values raise a warning and fall back to ``auto``.
7 changes: 2 additions & 5 deletions openapi_spec_validator/schemas/backend/jsonschema_rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, schema: dict[str, Any], validator: Any):

Args:
schema: JSON Schema to validate against
cls: JSON Schema validator
validator: JSON Schema validator
"""
if not HAS_JSONSCHEMA_RS:
raise ImportError(
Expand Down Expand Up @@ -149,10 +149,7 @@ def create_validator(schema: dict[str, Any]) -> JsonschemaRsValidatorWrapper:
module = _get_jsonschema_rs_module()
validator_cls: Any = module.validator_cls_for(schema)

validator = validator_cls(
schema,
validate_formats=True,
)
validator = validator_cls(schema)
return JsonschemaRsValidatorWrapper(schema, validator=validator)


Expand Down
2 changes: 1 addition & 1 deletion tests/bench/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def main():
settings = OpenAPISpecValidatorSettings()

print("Spec schema validator backend selection:")
print(" Configured backend mode: " f"{settings.schema_validator_backend}")
print(f" Configured backend mode: {settings.schema_validator_backend}")
print(f" Effective backend: {schemas.get_validator_backend()}")

# Benchmark custom specs
Expand Down