Breaking Changes
-
All builder methods on
ValidationOptionsnow take ownership ofselfinstead of&mut self.
This change enables better support for non-blocking retrieval of external resources during the process of building a validator.
Update your code to chain the builder methods instead of reusing the options instance:// Before (0.28.x) let mut options = jsonschema::options(); options.with_draft(Draft::Draft202012); options.with_format("custom", my_format); let validator = options.build(&schema)?; // After (0.29.0) let validator = jsonschema::options() .with_draft(Draft::Draft202012) .with_format("custom", my_format) .build(&schema)?;
-
The
Retrievetrait'sretrievemethod now accepts URI references as&Uri<String>instead of&Uri<&str>.
This aligns with the async version and simplifies internal URI handling. The behavior and available methods remain the same, this is purely a type-level change.// Before fn retrieve(&self, uri: &Uri<&str>) -> Result<Value, Box<dyn std::error::Error + Send + Sync>> // After fn retrieve(&self, uri: &Uri<String>) -> Result<Value, Box<dyn std::error::Error + Send + Sync>>
-
Simplified
Registrycreation API:- Removed
RegistryOptions::try_newandRegistryOptions::try_from_resourcesin favor ofRegistry::build - Removed
Registry::try_with_resource_and_retriever- useRegistry::options().retriever()instead - Registry creation is now consistently done through the builder pattern
// Before (0.28.x) let registry = Registry::options() .draft(Draft::Draft7) .try_new( "http://example.com/schema", resource )?; let registry = Registry::options() .draft(Draft::Draft7) .try_from_resources([ ("http://example.com/schema", resource) ].into_iter())?; let registry = Registry.try_with_resource_and_retriever( "http://example.com/schema", resource, retriever )?; // After (0.29.0) let registry = Registry::options() .draft(Draft::Draft7) .build([ ("http://example.com/schema", resource) ])?; let registry = Registry::options() .draft(Draft::Draft7) .build([ ("http://example.com/schema", resource) ])?; let registry = Registry::options() .retriever(retriever) .build(resources)?;
- Removed
Added
- Support non-blocking retrieval for external resources during schema resolution via the new
resolve-asyncfeature. #385 - Re-export
referencing::Registryasjsonschema::Registry. ValidationOptions::with_registrythat allows for providing a predefinedreferencing::Registry. #682
Performance
- Significantly improved validator compilation speed by using pointer-based references to schema fragments instead of cloning them during traversal.
- Faster anchors & sub-resources lookups during validator compilation.