Skip to content

Commit

Permalink
Allow URL schema resolving with rustls TLS
Browse files Browse the repository at this point in the history
Fixes #353
  • Loading branch information
jqnatividad authored and Stranger6667 committed Apr 10, 2022
1 parent 044935d commit 293d517
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions jsonschema/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,22 @@ impl SchemaResolver for DefaultResolver {
) -> Result<Arc<Value>, SchemaResolverError> {
match url.scheme() {
"http" | "https" => {
#[cfg(all(feature = "reqwest", not(feature = "resolve-http")))]
#[cfg(not(any(feature = "resolve-http", all(feature="reqwest", feature="rustls"), test)))]
{
compile_error!("the `reqwest` feature does not enable HTTP schema resolving anymore, use the `resolve-http` feature instead");
compile_error!(
r#"the `reqwest` feature alone does not enable HTTP schema resolving anymore.
Use the `resolve-http` feature which enables `native-tls` as well;
or both `reqwest` and `rustls` features together, if you prefer rustls."#
);
}

#[cfg(any(feature = "resolve-http", test))]
#[cfg(any(feature = "resolve-http", all(feature="reqwest", feature="rustls"), test))]
{
let response = reqwest::blocking::get(url.as_str())?;
let document: Value = response.json()?;
Ok(Arc::new(document))
}
#[cfg(not(any(feature = "resolve-http", test)))]
#[cfg(not(any(feature = "resolve-http", all(feature="reqwest", feature="rustls"), test)))]
Err(anyhow::anyhow!("`resolve-http` feature or a custom resolver is required to resolve external schemas via HTTP"))
}
"file" => {
Expand Down

0 comments on commit 293d517

Please sign in to comment.