Skip to content

Commit 293d517

Browse files
jqnatividadStranger6667
authored andcommitted
Allow URL schema resolving with rustls TLS
Fixes #353
1 parent 044935d commit 293d517

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

jsonschema/src/resolver.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,22 @@ impl SchemaResolver for DefaultResolver {
7676
) -> Result<Arc<Value>, SchemaResolverError> {
7777
match url.scheme() {
7878
"http" | "https" => {
79-
#[cfg(all(feature = "reqwest", not(feature = "resolve-http")))]
79+
#[cfg(not(any(feature = "resolve-http", all(feature="reqwest", feature="rustls"), test)))]
8080
{
81-
compile_error!("the `reqwest` feature does not enable HTTP schema resolving anymore, use the `resolve-http` feature instead");
81+
compile_error!(
82+
r#"the `reqwest` feature alone does not enable HTTP schema resolving anymore.
83+
Use the `resolve-http` feature which enables `native-tls` as well;
84+
or both `reqwest` and `rustls` features together, if you prefer rustls."#
85+
);
8286
}
8387

84-
#[cfg(any(feature = "resolve-http", test))]
88+
#[cfg(any(feature = "resolve-http", all(feature="reqwest", feature="rustls"), test))]
8589
{
8690
let response = reqwest::blocking::get(url.as_str())?;
8791
let document: Value = response.json()?;
8892
Ok(Arc::new(document))
8993
}
90-
#[cfg(not(any(feature = "resolve-http", test)))]
94+
#[cfg(not(any(feature = "resolve-http", all(feature="reqwest", feature="rustls"), test)))]
9195
Err(anyhow::anyhow!("`resolve-http` feature or a custom resolver is required to resolve external schemas via HTTP"))
9296
}
9397
"file" => {

0 commit comments

Comments
 (0)