From 2aa9c3b0c370ebaf1c468ae34e3603951ec13035 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Tekuri Date: Tue, 2 Apr 2024 14:52:06 +0530 Subject: [PATCH] loader: should load latest from metaschemas dir --- src/loader.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/loader.rs b/src/loader.rs index ead42dc..fbcf2ff 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -7,7 +7,7 @@ use once_cell::sync::Lazy; use serde_json::Value; use url::Url; -use crate::compiler::CompileError; +use crate::{compiler::CompileError, draft::latest}; /// A trait for loading json from given `url` pub trait UrlLoader { @@ -63,6 +63,10 @@ impl DefaultUrlLoader { .strip_prefix("http://json-schema.org/") .or_else(|| url.as_str().strip_prefix("https://json-schema.org/")); if let Some(meta) = meta { + if meta == "schema" { + let latest = Url::parse(latest().url).expect("draft url must be valid url"); + return self.load(&latest); + } if let Some(content) = STD_METAFILES.get(meta) { return serde_json::from_str::(content).map_err(|e| { CompileError::LoadUrlError {