The `RefResolver` class provides HTTP/HTTPS-based resolution for external JSON schema references. It enables validation of JSON data against schemas that reference remote schema definitions, with built-in caching and timeout protection.
## Why Use RefResolver?
When working with JSON schemas, you may encounter `$ref` properties that point to external schema definitions hosted remotely:
The resolver maintains a class-level cache to share fetched schemas across instances:
```ruby
# Access the cache
Labkit::JsonSchema::RefResolver.cache
# Clear the cache if needed
Labkit::JsonSchema::RefResolver.cache.clear
```
## Use Case Example
The `RefResolver` is used in the User Experience SLI Registry [lib/labkit/user_experience_sli/registry.rb](lib/labkit/user_experience_sli/registry.rb) to validate user experience definitions against a JSON schema.
## Implementation Details
- Only HTTP and HTTPS schemes are supported. Other schemes (FTP, file://, etc.) will raise an error.
- The resolver configures SSL certificate validation using the system's default certificate store with the `PARTIAL_CHAIN` flag, which validates certificate chains and expiration while being more lenient with certain certificate configurations.
- The class-level cache is shared across all instances. In multi-threaded environments, consider using appropriate synchronization mechanisms if cache consistency is critical.