|
21 | 21 | from pathlib import Path |
22 | 22 | from typing import Any |
23 | 23 |
|
24 | | -from jsonschema_path import SchemaPath |
25 | 24 | from jsonschema_path.typing import Schema |
26 | 25 |
|
27 | 26 | from openapi_spec_validator import schemas |
28 | 27 | from openapi_spec_validator import validate |
29 | 28 | from openapi_spec_validator.readers import read_from_filename |
30 | | -from openapi_spec_validator.shortcuts import get_validator_cls |
31 | 29 |
|
32 | 30 |
|
33 | 31 | @dataclass |
@@ -110,11 +108,7 @@ def get_spec_version(spec: Schema) -> str: |
110 | 108 | def run_once(spec: Schema) -> float: |
111 | 109 | """Run validation once and return elapsed time.""" |
112 | 110 | t0 = time.perf_counter() |
113 | | - cls = get_validator_cls(spec) |
114 | | - sp = SchemaPath.from_dict(spec) |
115 | | - v = cls(sp) |
116 | | - v.validate() |
117 | | - # validate(spec) |
| 111 | + validate(spec) |
118 | 112 | return time.perf_counter() - t0 |
119 | 113 |
|
120 | 114 |
|
@@ -271,8 +265,8 @@ def get_synthetic_specs_iterator( |
271 | 265 | configs: list[tuple[int, int, str]], |
272 | 266 | ) -> Iterator[tuple[dict[str, Any], str, float]]: |
273 | 267 | """Iterator over synthetic specs based on provided configurations.""" |
274 | | - for paths, schemas, size in configs: |
275 | | - spec = generate_synthetic_spec(paths, schemas) |
| 268 | + for paths, schema_count, size in configs: |
| 269 | + spec = generate_synthetic_spec(paths, schema_count) |
276 | 270 | yield spec, f"synthetic_{size}", 0 |
277 | 271 |
|
278 | 272 |
|
@@ -348,7 +342,10 @@ def main(): |
348 | 342 | results.append(result.as_dict()) |
349 | 343 | if result.success: |
350 | 344 | print( |
351 | | - f" ✅ {result.median_s:.4f}s, {result.validations_per_sec:.2f} val/s" |
| 345 | + " ✅ {:.4f}s, {:.2f} val/s".format( |
| 346 | + result.median_s, |
| 347 | + result.validations_per_sec, |
| 348 | + ) |
352 | 349 | ) |
353 | 350 | else: |
354 | 351 | print(f" ❌ Error: {result.error}") |
|
0 commit comments