You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: Improve performance by using a faster library for parsing json schemas #1086
Use fastjsonschema instead of jsonschema, or even jsonschema-rs. jsonschema-rs claims to be 30x to 390x faster than jsonschema (3x to 7x faster than fastjsonschema).
Why is this needed?
I have an OpenAPI spec that's moderately big, roughly 1.6M and parsing it with OpenAPI takes about 15s on my computer. I unfortunately can't share it, but I can share the profiling on it.
For one-time use it would be fine, but we use it in tests to validate responses, so this adds quite a bit of runtime to tests.
References
This profiling of just loading the OpenAPI yaml file, using OpenAPI.from_file_path("<path>")
Hi @mikicz , thanks for your comment. I see in your profiling that your bottleneck is specification validation on the OpenAPI initialization. You can turn off the validation if you are sure your specification is valid. Please read the documentation how to disable spec validation.
If your intention is it use specification validation feature but make it faster then that would require changes in openapi-spec-validator and openapi-schema-validator which are entirely based on jsonschema.
After little bit more investigation and profiling I found out the issue with suboptimal reference resolution in jsonschema-path library. The fix should have more impact than switching to jsonschema-rs.
Hi! Thanks for still looking at this! I have indeed found that just disabling spec validation does help quite a bit. Nonetheless I have tried to profile the current release and the pre-release with our spec file.
The headline is that I do not see any major time improvement - tho I can imagine my setup being less than ideal - I only ran once per variant instead of running multiple times. See pyinstrument profiling:
Activity
p1c2u commentedon Jan 30, 2026
Hi @mikicz , thanks for your comment. I see in your profiling that your bottleneck is specification validation on the OpenAPI initialization. You can turn off the validation if you are sure your specification is valid. Please read the documentation how to disable spec validation.
If your intention is it use specification validation feature but make it faster then that would require changes in
openapi-spec-validatorandopenapi-schema-validatorwhich are entirely based onjsonschema.p1c2u commentedon Feb 1, 2026
After little bit more investigation and profiling I found out the issue with suboptimal reference resolution in
jsonschema-pathlibrary. The fix should have more impact than switching tojsonschema-rs.p1c2u/jsonschema-path#208
p1c2u commentedon Feb 17, 2026
Betea version with performance improvements was released. Feel free to test it.
mikicz commentedon Feb 17, 2026
Hi! Thanks for still looking at this! I have indeed found that just disabling spec validation does help quite a bit. Nonetheless I have tried to profile the current release and the pre-release with our spec file.
With validation:
Without validation:
Old dependencies:
New dependencies:
The headline is that I do not see any major time improvement - tho I can imagine my setup being less than ideal - I only ran once per variant instead of running multiple times. See pyinstrument profiling:
old.txt
new.txt
new_without_validation.txt
old_without_validation.txt
p1c2u commentedon Feb 17, 2026
Thanks for sharing your results. The improvement should only be visible when the spec validation is enabled.
I’ve prepared a PoC for the jsonschema-rs version. It’s definitely worth moving forward, but it requires more time.