Skip to content

Commit

Permalink
loader: should load latest from metaschemas dir
Browse files Browse the repository at this point in the history
  • Loading branch information
santhosh-tekuri committed Apr 2, 2024
1 parent f53abcf commit 2aa9c3b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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::<Value>(content).map_err(|e| {
CompileError::LoadUrlError {
Expand Down

0 comments on commit 2aa9c3b

Please sign in to comment.